diff options
author | dmitry kim <jason@nichego.net> | 2008-06-26 20:47:15 +0400 |
---|---|---|
committer | dmitry kim <jason@nichego.net> | 2008-06-26 20:47:15 +0400 |
commit | d6d906b714c52fc3bee8ff9e0090778bccfce3c7 (patch) | |
tree | e0dee81f504f98c33bf3b0d2c3c70e27fbc4d2c6 /data | |
parent | c20fe0172552682670b0a4d0704aeccd5f3bfe31 (diff) |
* plugins/bans: fix timed bans
Diffstat (limited to 'data')
-rw-r--r-- | data/rbot/plugins/bans.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/data/rbot/plugins/bans.rb b/data/rbot/plugins/bans.rb index 4e35d996..b25cb50b 100644 --- a/data/rbot/plugins/bans.rb +++ b/data/rbot/plugins/bans.rb @@ -401,15 +401,13 @@ class BansPlugin < Plugin case action when :ban - set_mode(channel, "+b", nick) - @bot.timer.add_once(timer) { set_mode(channel, "-b", nick) } if timer > 0 + set_temporary_mode(channel, 'b', nick, timer) when :unban set_mode(channel, "-b", nick) when :kick do_kick(channel, nick, reason) when :kickban - set_mode(channel, "+b", nick) - @bot.timer.add_once(timer) { set_mode(channel, "-b", nick) } if timer > 0 + set_temporary_mode(channel, 'b', nick, timer) do_kick(channel, nick, reason) when :silence, :quiet set_mode(channel, "+q", nick) @@ -424,6 +422,13 @@ class BansPlugin < Plugin @bot.mode(channel, mode, host) end + def set_temporary_mode(channel, mode, nick, timer) + host = channel.has_user?(nick) ? "*!*@" + channel.users[nick].host : nick + @bot.mode(channel, "+#{mode}", host) + return if timer == 0 + @bot.timer.add_once(timer) { @bot.mode(channel, "-#{mode}", host) } + end + def do_kick(channel, nick, reason="") @bot.kick(channel, nick, reason) end |