diff options
-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 |