]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/keywords.rb
grouphug: log errors
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / keywords.rb
index 5ed5256544a7e4e32a30e4901fccdb4b04d0c66b..97fe4258e862d86b8001a0fa3d413df596deb212 100644 (file)
@@ -101,6 +101,9 @@ class Keywords < Plugin
   Config.register Config::IntegerValue.new('keyword.search_results',
     :default => 3,
     :desc => "How many search results to display at a time")
+  Config.register Config::ArrayValue.new('keyword.ignore_words',
+    :default => ["how", "that", "these", "they", "this", "what", "when", "where", "who", "why", "you"],
+    :desc => "A list of words that the bot should passively ignore.")
 
   # create a new KeywordPlugin instance, associated to bot +bot+
   def initialize
@@ -258,6 +261,11 @@ class Keywords < Plugin
     return false
   end
 
+  # is +word+ a passively ignored keyword?
+  def ignored_word?(word)
+    @bot.config["keyword.ignore_words"].include?(word)
+  end
+
   # m::     PrivMessage containing message info
   # key::   key being queried
   # quiet:: optional, if false, complain if +key+ is not found
@@ -544,10 +552,10 @@ class Keywords < Plugin
     # TODO option to do if(m.message =~ /^(.*)$/, ie try any line as a
     # keyword lookup.
     if m.message =~ /^(.*\S)\s*\?\s*$/ and (m.address? or not @bot.config["keyword.address"])
-      keyword_lookup m, $1, true if @bot.auth.allow?("keyword", m.source)
+      keyword_lookup m, $1, true if !ignored_word?($1) && @bot.auth.allow?("keyword", m.source)
     elsif @bot.config["keyword.listen"] && (m.message =~ /^(.*?)\s+(is|are)\s+(.*)$/)
       # TODO MUCH more selective on what's allowed here
-      keyword_command m, $1, $2, $3, true if @bot.auth.allow?("keycmd", m.source)
+      keyword_command m, $1, $2, $3, true if !ignored_word?($1) && @bot.auth.allow?("keycmd", m.source)
     end
   end
 end