From: Giuseppe Bilotta Date: Wed, 26 Jan 2011 12:21:44 +0000 (+0100) Subject: weather: config option for default units X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=a6e1d47056be249989cbe40233422d4644d88739;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git weather: config option for default units --- 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