diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-04-14 21:09:06 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-04-14 21:09:06 +0200 |
commit | 39fa281fa05a8b3c1e56954c5db4dcabcc1b6d8e (patch) | |
tree | 2bcc943e707daed7037cb8027204cb8401195a96 /data/rbot/plugins | |
parent | 4b0cec11264b27473f9d05c0cd510166364a0fb7 (diff) |
uno plugin: command to transfer game ownership
Diffstat (limited to 'data/rbot/plugins')
-rw-r--r-- | data/rbot/plugins/games/uno.rb | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/data/rbot/plugins/games/uno.rb b/data/rbot/plugins/games/uno.rb index 5ae780c7..01db7ff4 100644 --- a/data/rbot/plugins/games/uno.rb +++ b/data/rbot/plugins/games/uno.rb @@ -161,7 +161,7 @@ class UnoGame attr_reader :picker # the IRC user that created the game - attr_reader :manager + attr_accessor :manager def initialize(plugin, channel, manager) @channel = channel @@ -906,6 +906,26 @@ class UnoPlugin < Plugin } end + def transfer_ownership(m, p) + unless @games.key?(m.channel) + m.reply _("There is no %{uno} game running here") % { :uno => UnoGame::UNO } + return + end + g = @games[m.channel] + old = g.manager + new = m.channel.get_user(p[:nick]) + if new + g.manager = new + @bot.auth.irc_to_botuser(old).reset_temp_permission('uno::manage', m.channel) + @bot.auth.irc_to_botuser(new).set_temp_permission('uno::manage', true, m.channel) + m.reply _("%{uno} game ownership transferred from %{old} to %{nick}") % { + :uno => UnoGame::UNO, :old => old, :nick => p[:nick] + } + else + m.reply _("who is this %{nick} you want me to transfer game ownership to?") % p + end + end + def end_game(m, p) unless @games.key?(m.channel) m.reply _("There is no %{uno} game running here") % { :uno => UnoGame::UNO } @@ -1139,6 +1159,7 @@ pg.map 'uno drop', :private => false, :action => :drop_player, :auth_path => 'ma pg.map 'uno giveup', :private => false, :action => :drop_player, :auth_path => 'manage::drop::self!' pg.map 'uno drop :nick', :private => false, :action => :drop_player, :auth_path => 'manage::drop::other!' pg.map 'uno replace :old [with] :new', :private => false, :action => :replace_player, :auth_path => 'manage' +pg.map 'uno transfer [game [ownership]] [to] :nick', :private => false, :action => :transfer_ownership, :auth_path => 'manage' pg.map 'uno stock', :private => false, :action => :print_stock pg.map 'uno chanstats', :private => false, :action => :do_chanstats pg.map 'uno stats [:nick]', :private => false, :action => :do_pstats |