]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/weather.rb
webhook: include target ref for pull/merge requests
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / weather.rb
index 9d2b8aed5e3c368b49b62e30a3f6511d3fa8e4cd..7c1336f0d017dfd62655bb2d4d859e7a563bd649 100644 (file)
@@ -15,15 +15,15 @@ require 'rexml/document'
 
 # Wraps NOAA National Weather Service information
 class CurrentConditions
-  @@bot = Irc::Utils.bot
-    def initialize(station)
+    def initialize(station, bot)
         @station = station
+        @bot = bot
         @url = "http://www.nws.noaa.gov/data/current_obs/#{URI.encode @station.upcase}.xml"
         @current_conditions = String.new
     end
     def update
       begin
-        resp = @@bot.httputil.get_response(@url)
+        resp = @bot.httputil.get_response(@url)
         case resp
         when Net::HTTPSuccess
           cc_doc = (REXML::Document.new resp.body).root
@@ -130,7 +130,9 @@ class WeatherPlugin < Plugin
 
     wu_units = String.new
 
-    case (units || @bot.config['weather.units']).to_sym
+    units = @bot.config['weather.units'] unless units
+
+    case units.to_sym
     when :english, :metric
       wu_units = "_#{units}"
     when :both
@@ -159,7 +161,7 @@ class WeatherPlugin < Plugin
     if @nws_cache.has_key?(where) then
         met = @nws_cache[where]
     else
-        met = CurrentConditions.new(where)
+        met = CurrentConditions.new(where, @bot)
     end
     if met
       begin