]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/karma.rb
script, rss plugins: raise if main data could not be restored from the registry
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / karma.rb
index 148427a53cd15f36872f8c5abd2ba2ec7fc08bb4..43b3f2dc160f3a761fc48b83e2ba7215b55afaa8 100644 (file)
@@ -15,7 +15,7 @@ class KarmaPlugin < Plugin
 
     # import if old file format found
     if(File.exist?("#{@bot.botclass}/karma.rbot"))
-      puts "importing old karma data"
+      log "importing old karma data"
       IO.foreach("#{@bot.botclass}/karma.rbot") do |line|
         if(line =~ /^(\S+)<=>([\d-]+)$/)
           item = $1
@@ -52,7 +52,7 @@ class KarmaPlugin < Plugin
   
   
   def help(plugin, topic="")
-    "karma module: <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."
+    "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?
@@ -69,9 +69,12 @@ class KarmaPlugin < Plugin
         key.sub!(/^\((.*)\)$/, "\1")
         key.gsub!(/\s+/, " ")
         next unless(key.length > 0)
-        next if(key == m.sourcenick)
+        next if(key.downcase == m.sourcenick.downcase)
         if(change == "++")
           @registry[key] += 1
+          if key =~ /^#{@bot.nick}$/i
+            @bot.say m.replyto, @bot.lang.get("thanks")
+          end
         elsif(change == "--")
           @registry[key] -= 1
         end
@@ -79,6 +82,7 @@ class KarmaPlugin < Plugin
     end
   end
 end
+
 plugin = KarmaPlugin.new
 plugin.map 'karmastats', :action => 'stats'
 plugin.map 'karma :key', :defaults => {:key => false}