diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-01-30 12:55:19 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-01-30 12:55:19 +0000 |
commit | b2d2ceb4f15c215b506fd6d36a09f6487ec46772 (patch) | |
tree | eb5f975ea45c15080cadf9634ed90ff140a680ca /data | |
parent | bb135f4425abb5dc53b52a355b8994c0e8646d59 (diff) |
time plugin: provide commands to let the bot forget about timezones, and let the user know what happens when the timezone is set/forgotten
Diffstat (limited to 'data')
-rw-r--r-- | data/rbot/plugins/time.rb | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/data/rbot/plugins/time.rb b/data/rbot/plugins/time.rb index f13f5a80..9f8b8d7c 100644 --- a/data/rbot/plugins/time.rb +++ b/data/rbot/plugins/time.rb @@ -7,7 +7,7 @@ require 'tzinfo' class TimePlugin < Plugin def help(plugin, topic="") - "time <time zone> to get the local time of a certain location. <time zone> can be <Continent/City> or <two character country code>. time <nick> to see the local time of that person if their time zone is set. time admin set <nick> <time zone> to set the time zone for another user." + "time <time zone> to get the local time of a certain location. <time zone> can be <Continent/City> or <two character country code>. time <nick> to see the local time of that person if their time zone is set. time admin set <nick> <time zone> to set the time zone for another user. time [admin] reset [nick] to let the bot forget about the tzinfo about someone" end def initialize @@ -81,11 +81,23 @@ class TimePlugin < Plugin end end + def resetUserZone( m, params ) + s = resetZone( m, m.sourcenick) + end + def setAdminZone( m, params ) if params[:who] and params[:where].size > 0 then s = setZone( m, params[:who], params[:where].join('_') ) else - m.reply 'Requires a nick and the Continent/City or country code.' + m.reply "Requires a nick and the Continent/City or country code" + end + end + + def resetAdminZone( m, params ) + if params[:who] + s = resetZone( m, params[:who]) + else + m.reply "Requires a nick" end end @@ -97,10 +109,21 @@ class TimePlugin < Plugin return end @registry[ user ] = zone + m.reply "Ok, I'll remember that #{user} is on the #{zone} timezone" + end + + def resetZone( m, user ) + @registry.delete(user) + m.reply "Ok, I've forgotten #{user}'s timezone" end end plugin = TimePlugin.new -plugin.map 'time set *where', :action=> 'setUserZone', :defaults => {:where => false} -plugin.map 'time admin set :who *where', :action=> 'setAdminZone', :defaults => {:where => false, :who=>false}, :auth=> 'timeadmin' + +plugin.default_auth('admin', false) + +plugin.map 'time set [time][zone] [to] *where', :action=> 'setUserZone', :defaults => {:where => false} +plugin.map 'time reset [time][zone]', :action=> 'resetUserZone' +plugin.map 'time admin set [time][zone] [for] :who [to] *where', :action=> 'setAdminZone', :defaults => {:who => false, :where => false} +plugin.map 'time admin reset [time][zone] [for] :who', :action=> 'resetAdminZone', :defaults => {:who => false} plugin.map 'time *where', :action => 'showTime', :defaults => {:where => false} |