From d6d906b714c52fc3bee8ff9e0090778bccfce3c7 Mon Sep 17 00:00:00 2001 From: dmitry kim Date: Thu, 26 Jun 2008 20:47:15 +0400 Subject: * plugins/bans: fix timed bans --- data/rbot/plugins/bans.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'data/rbot/plugins/bans.rb') 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 -- cgit v1.2.3