]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
salut now only replies to salutations directed at him, unless salut.address_only...
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sat, 28 Oct 2006 08:28:52 +0000 (08:28 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sat, 28 Oct 2006 08:28:52 +0000 (08:28 +0000)
data/rbot/plugins/salut.rb

index 4827601948324570af93c22f154523f497444a9e..b8d9c4d76d5432054c6eecfe1bb29f5913e923b9 100644 (file)
@@ -18,6 +18,12 @@ class SalutPlugin < Plugin
     :desc => "Check for a salutation in all languages and not just in the one defined by core.language",\r
     :on_change => Proc.new {|bot, v| bot.plugins['salut'].reload}\r
   )\r
+  BotConfig.register BotConfigBooleanValue.new('salut.address_only',\r
+    :default => true, \r
+    :desc => "When set to true, the bot will only reply to salutations directed at him",\r
+    :on_change => Proc.new {|bot, v| bot.plugins['salut'].reload}\r
+  )\r
+\r
 \r
   def initialize\r
     @salutations = Hash.new\r
@@ -63,6 +69,9 @@ class SalutPlugin < Plugin
   end\r
 \r
   def listen(m)\r
+    if @bot.config['salut.address_only']\r
+      return unless m.address? or m.message =~ /#{Regexp.escape(@bot.nick)}/\r
+    end\r
     salut = nil\r
     [:both, :in, :out].each { |k|\r
       next unless @match[k]\r