summaryrefslogtreecommitdiff
path: root/lib/rbot/keywords.rb
diff options
context:
space:
mode:
authorTom Gilbert <tom@linuxbrit.co.uk>2005-07-30 00:22:21 +0000
committerTom Gilbert <tom@linuxbrit.co.uk>2005-07-30 00:22:21 +0000
commit992ef2edbf3eed7cb1d7c4c22f72cd203aff2aa5 (patch)
treec34cc1bad75c9c226ac544fd4337e0acb5ac4a9b /lib/rbot/keywords.rb
parent676dd61e6b0bea5f506d064039a685944aefd6fb (diff)
Sat Jul 30 01:19:32 BST 2005 Tom Gilbert <tom@linuxbrit.co.uk>
* config module for configuring the running bot via IRC * BotConfig.register method for various modules and any plugin to register bot configuration which the new config module will expose for them. * various other tweaks as I continue to refactor..
Diffstat (limited to 'lib/rbot/keywords.rb')
-rw-r--r--lib/rbot/keywords.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/rbot/keywords.rb b/lib/rbot/keywords.rb
index 3305af29..70802e35 100644
--- a/lib/rbot/keywords.rb
+++ b/lib/rbot/keywords.rb
@@ -8,7 +8,7 @@ module Irc
# is, and has a single value of bar).
# Keywords can have multiple values, to_s() will choose one at random
class Keyword
-
+
# type of keyword (e.g. "is" or "are")
attr_reader :type
@@ -81,6 +81,10 @@ module Irc
# handle it, checks for a keyword command or lookup, otherwise the message
# is delegated to plugins
class Keywords
+ BotConfig.register('keyword.listen', :type => :boolean, :default => false,
+ :desc => "Should the bot listen to all chat and attempt to automatically detect keywords? (e.g. by spotting someone say 'foo is bar')")
+ BotConfig.register('keyword.address', :type => :boolean, :default => true,
+ :desc => "Should the bot require that keyword lookups are addressed to it? If not, the bot will attempt to lookup foo if someone says 'foo?' in channel")
# create a new Keywords instance, associated to bot +bot+
def initialize(bot)
@@ -415,7 +419,7 @@ module Irc
end
else
# in channel message, not to me
- if(m.message =~ /^'(.*)$/ || (!@bot.config["keyword.noaddress"] && m.message =~ /^(.*\S)\s*\?\s*$/))
+ if(m.message =~ /^'(.*)$/ || (!@bot.config["keyword.address"] && m.message =~ /^(.*\S)\s*\?\s*$/))
keyword m, $1, false if(@bot.auth.allow?("keyword", m.source))
elsif(@bot.config["keyword.listen"] == true && (m.message =~ /^(.*?)\s+(is|are)\s+(.*)$/))
# TODO MUCH more selective on what's allowed here