diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2011-01-26 13:21:44 +0100 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2011-01-26 13:37:35 +0100 |
commit | a6e1d47056be249989cbe40233422d4644d88739 (patch) | |
tree | 506e77d8ff620cdd0fe8137d7c4ff73c62335858 /data/rbot/plugins | |
parent | 5b6e6a93dc620315f69b3507bc86d8a806cdb968 (diff) |
weather: config option for default units
Diffstat (limited to 'data/rbot/plugins')
-rw-r--r-- | data/rbot/plugins/weather.rb | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/data/rbot/plugins/weather.rb b/data/rbot/plugins/weather.rb index cb0a2b18..afcf394c 100644 --- a/data/rbot/plugins/weather.rb +++ b/data/rbot/plugins/weather.rb @@ -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 |