1 class WeatherPlugin < Plugin
3 def help(plugin, topic="")
4 "weather <ICAO> => display the current weather at the location specified by the ICAO code [Lookup your ICAO code at http://www.nws.noaa.gov/oso/siteloc.shtml] - this will also store the ICAO against your nick, so you can later just say \"weather\", weather => display the current weather at the location you last asked for"
9 # this plugin only wants to store strings
18 @metar_cache = Hash.new
21 def describe(m, where)
22 if @metar_cache.has_key?(where) &&
23 Time.now - @metar_cache[where].date < 3600
24 met = @metar_cache[where]
26 met = Utils.get_metar(where)
30 m.reply met.pretty_print
31 @metar_cache[where] = met
33 m.reply "couldn't find weather data for #{where}"
40 if @registry.has_key?(m.sourcenick)
41 where = @registry[m.sourcenick]
44 m.reply "I don't know where #{m.sourcenick} is!"
48 @registry[m.sourcenick] = where
54 plugin = WeatherPlugin.new
55 plugin.register("weather")