]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/karma.rb
quiz: stop quizzes and timers on cleanup
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / karma.rb
index 60b1dcf8a739e19c0dc8a3efebc476982775bc3c..93d2118996eb787343e3159687baef268b0cc988 100644 (file)
@@ -14,16 +14,17 @@ class KarmaPlugin < Plugin
     @registry.set_default(0)
 
     # import if old file format found
-    if(File.exist?("#{@bot.botclass}/karma.rbot"))
+    oldkarma = @bot.path 'karma.rbot'
+    if File.exist? oldkarma
       log "importing old karma data"
-      IO.foreach("#{@bot.botclass}/karma.rbot") do |line|
+      IO.foreach(oldkarma) do |line|
         if(line =~ /^(\S+)<=>([\d-]+)$/)
           item = $1
           karma = $2.to_i
           @registry[item] = karma
         end
       end
-      File.delete("#{@bot.botclass}/karma.rbot")
+      File.delete oldkarma
     end
   end
 
@@ -54,13 +55,13 @@ class KarmaPlugin < Plugin
     @registry[thing] = params[:val].to_i
     karma(m, params)
   end
-  
+
   def help(plugin, topic="")
     "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
@@ -86,7 +87,7 @@ class KarmaPlugin < Plugin
 
       if op && arg
         ac[arg] ||= 0
-        ac[arg] += (op == '--' ? -1 : 1)
+        ac[arg] += (op == '--' ? -1 : 1) unless arg.downcase == m.sourcenick.downcase
         op = arg = nil
       end
     end