Skip to content

Instantly share code, notes, and snippets.

@Ramblurr
Created May 21, 2009 13:09
Show Gist options
  • Save Ramblurr/115451 to your computer and use it in GitHub Desktop.
Save Ramblurr/115451 to your computer and use it in GitHub Desktop.
#-- vim:sw=2:et
#++
# :title: the fucking weather plugin for rbot
#
# Author:: Casey Link <unnamedrambler@gmail.com>
# Copyright:: (C) 2009 Casey Link
#
# License:: GPL 2+
require 'cgi'
class FUWeather < Plugin
FUURL = "http://www.thefuckingweather.com/?zipcode="
FUREGEX = /.*&deg;\?\!<br><br>(.*)<br><span.*/m
def help(plugin, topic="")
"fuweather <city/zipcode> (or: howthefuckisit in <city/zipcode>)=> get the fucking weather for <city/zipcode>"
end
def getit(m, params)
opts = { :cache => false }
city = params[:city].to_s
searchfor = CGI.escape city
url = FUURL + searchfor
resp = @bot.httputil.get_response(url, opts)
unless resp
m.reply "there was a fucking error"
return
end
results = resp.body.scan(FUREGEX)
if results.length == 0
m.reply "no fucking weather found for #{city}"
return
end
weather = results[0]
m.reply "#{weather}"
end
end
plugin = FUWeather.new
plugin.map "fuweather *city", :action => 'getit', :threaded => true
plugin.map "howthefuckisit *city", :action => 'getit', :threaded => true
plugin.map "howthefuckisit in *city", :action => 'getit', :threaded => true
plugin.map "howthefuckisitin *city", :action => 'getit', :threaded => true
plugin.map "htfii *city", :action => 'getit', :threaded => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment