]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
ircbot: irc.ignore_channels config option
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 28 Jan 2009 20:36:38 +0000 (21:36 +0100)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 28 Jan 2009 20:36:45 +0000 (21:36 +0100)
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).

lib/rbot/ircbot.rb

index b47c235b6b03ce3f50dbed12f0036b8fa4a0e712..d5d3828be2cdb208beea16014d748d9ba219c491 100644 (file)
@@ -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