From 107f1de91b246fbacbe7ad9de1281d0c25831e89 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Fri, 5 Sep 2008 20:07:38 +0200 Subject: quiet exception list Keep a track of exceptions to a global 'quiet' command so that user can use !quiet and !talk in here to make the bot only talk in one channel without quiet-ing it by hand in each one of the other channels. --- lib/rbot/ircbot.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 55b10d41..2830a5ac 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -591,6 +591,8 @@ class Bot # '*' means all channels # @quiet = Set.new + # but we always speak here + @not_quiet = Set.new # the nick we want, if it's different from the irc.nick config value # (e.g. as set by a !nick command) @@ -784,24 +786,30 @@ class Bot # checks if we should be quiet on a channel def quiet_on?(channel) - return @quiet.include?('*') || @quiet.include?(channel.downcase) + ch = channel.downcase + return (@quiet.include?('*') && !@not_quiet.include?(ch)) || @quiet.include?(ch) end def set_quiet(channel = nil) if channel ch = channel.downcase.dup + @not_quiet.delete(ch) @quiet << ch else @quiet.clear + @not_quiet.clear @quiet << '*' end end def reset_quiet(channel = nil) if channel - @quiet.delete channel.downcase + ch = channel.downcase.dup + @quiet.delete(ch) + @not_quiet << ch else @quiet.clear + @not_quiet.clear end end -- cgit v1.2.3