summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2009-01-28 21:36:38 +0100
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2009-01-28 21:36:45 +0100
commit575c4c14d527e4dc06e015ffce7aafd6307a7692 (patch)
tree340f57c0ebf0c4f17743dfbdfc93e7642e135967
parent810ada4dd1a8dfe894c90dfd135ac7b339864d21 (diff)
ircbot: irc.ignore_channels config option
In some circumstances the user might want to turn the bot into a pure logbot for some channels. This can now be achieved by adding that channel to the irc.ignore_channels config key, that makes the bot ignore all PRIVMSG to that channel (note that notices and service messages such as joins and parts are still acted on, just like for irc.ignore_users).
-rw-r--r--lib/rbot/ircbot.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index b47c235b..d5d3828b 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -306,6 +306,9 @@ class Bot
Config.register Config::ArrayValue.new('irc.ignore_users',
:default => [],
:desc => "Which users to ignore input from. This is mainly to avoid bot-wars triggered by creative people")
+ Config.register Config::ArrayValue.new('irc.ignore_channels',
+ :default => [],
+ :desc => "Which channels to ignore input in. This is mainly to turn the bot into a logbot that doesn't interact with users in any way (in the specified channels)")
Config.register Config::IntegerValue.new('core.save_every',
:default => 60, :validate => Proc.new{|v| v >= 0},
@@ -639,6 +642,11 @@ class Bot
# debug "Message target is #{data[:target].inspect}"
# debug "Bot is #{myself.inspect}"
+ @config['irc.ignore_channels'].each { |channel|
+ if m.target.downcase == channel.downcase
+ m.ignored = true
+ end
+ }
@config['irc.ignore_users'].each { |mask|
if m.source.matches?(server.new_netmask(mask))
m.ignored = true