class Whatson
Constants
- USER_AGENT
Public Class Methods
Source
# File plugins/whatson.rb, line 42 def command_pattern /whatson (.+)/i end
Source
# File plugins/whatson.rb, line 33 def dispatch_command(town_text, fetch:, fetch_rss: nil) parsed = parse_town(town_text) return { error: parsed[:error] } if parsed[:error] return { silent: true } if WhatsonTowns.silent?(parsed) reply = WhatsonSearch.search(parsed[:town], fetch: fetch, fetch_rss: fetch_rss) { reply: reply } end
Source
# File plugins/whatson.rb, line 29 def search(parsed, fetch:, fetch_rss: nil) WhatsonSearch.search(parsed[:town], fetch: fetch, fetch_rss: fetch_rss) end
Public Instance Methods
Source
# File plugins/whatson.rb, line 59 def execute(m, town) result = self.class.dispatch_command( town, fetch: method(:fetch_html), fetch_rss: method(:fetch_rss) ) return if result[:silent] return themed_flood_safe_reply(m, result[:error]) if result[:error] themed_flood_safe_reply(m, result[:reply]) end
Source
# File plugins/whatson.rb, line 51 def fetch_html(url) RabbotHttp.fetch(url, user_agent: USER_AGENT) end
Source
# File plugins/whatson.rb, line 55 def fetch_rss(url) RabbotHttp.fetch(url, user_agent: USER_AGENT) end
Source
# File plugins/whatson.rb, line 47 def search(parsed, fetch: method(:fetch_html), fetch_rss: method(:fetch_rss)) self.class.search(parsed, fetch: fetch, fetch_rss: fetch_rss) end