]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
weather: config option for default units
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 26 Jan 2011 12:21:44 +0000 (13:21 +0100)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 26 Jan 2011 12:37:35 +0000 (13:37 +0100)
data/rbot/plugins/weather.rb

index cb0a2b186a955bdb61a5861c8ef30a8f71c35c45..afcf394c1a41edfd0d2b8f22be5d1b388c585e45 100644 (file)
@@ -71,6 +71,11 @@ class WeatherPlugin < Plugin
   Config.register Config::BooleanValue.new('weather.advisory',
     :default => true,
     :desc => "Should the bot report special weather advisories when any is present?")
+  Config.register Config::EnumValue.new('weather.units',
+    :values => ['metric', 'english', 'both'],
+    :default => 'both',
+    :desc => "Units to be used by default in Weather Underground reports")
+
 
   def help(plugin, topic="")
     case topic
@@ -125,15 +130,14 @@ class WeatherPlugin < Plugin
     end
 
     wu_units = String.new
-    if units
-      case units.to_sym
-      when :english, :metric
-        wu_units = "_#{units}"
-      when :both
-      else
-        m.reply "Ignoring unknown units #{units}"
-        wu_units = String.new
-      end
+
+    units ||= @bot.config['weather.units']
+    case units.to_sym
+    when :english, :metric
+      wu_units = "_#{units}"
+    when :both
+    else
+      m.reply "Ignoring unknown units #{units}"
     end
 
     case service