diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-09-05 20:07:38 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-09-05 20:07:38 +0200 |
commit | 107f1de91b246fbacbe7ad9de1281d0c25831e89 (patch) | |
tree | 5ef5312a059c0ec751102473a4a61f383e5382c8 /lib/rbot | |
parent | 362295025c0b9bb6ba98579047ab68b3fc5723a9 (diff) |
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.
Diffstat (limited to 'lib/rbot')
-rw-r--r-- | lib/rbot/ircbot.rb | 12 |
1 files 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 |