]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/karma.rb
grouphug: log errors
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / karma.rb
index eecfbe26644629a88a5e417a76f4fabe1a68fdd9..d8d378e332c223ef54ea0997892905610ab73d15 100644 (file)
@@ -59,8 +59,8 @@ class KarmaPlugin < Plugin
     "karma module: Listens to everyone's chat. <thing>++/<thing>-- => increase/decrease karma for <thing>, karma for <thing>? => show karma for <thing>, karmastats => show stats. Karma is a community rating system - only in-channel messages can affect karma and you cannot adjust your own."
   end
 
-  def listen(m)
-    return unless m.kind_of?(PrivMessage) && m.public?
+  def message(m)
+    return unless m.public? && m.message.match(/\+\+|--/)
     arg = nil
     op = nil
     ac = Hash.new
@@ -71,7 +71,7 @@ class KarmaPlugin < Plugin
           if (tok =~ /^(?:--)(.*[^-].*)$/) || (tok =~ /^(.*[^-].*)(?:--)$/)
             op, arg = '--', $1
             next
-          elsif (tok =~ /^(?:\+\+)(.*[^+].*)$/) || (tok =~ /^(.*[^+].*)(?:\+\+)$/)
+          elsif (tok =~ /^(?:\+\+)(.*[^+].*)$/)||(tok =~ /^(.*[^+].*)(?:\+\+)$/)
             op, arg = '++', $1
             next
           end
@@ -94,7 +94,7 @@ class KarmaPlugin < Plugin
     ac.each do |k, v|
       next if v == 0
       @registry[k] += (v > 0 ? 1 : -1)
-      m.reply @bot.lang.get("thanks") if k == @bot.nick
+      m.reply @bot.lang.get("thanks") if k == @bot.nick && v > 0
     end
   end
 end