# File rbot/plugins/karma2.rb, line 32 def listener(m) if(m.type == "PRIVMSG" && m.public?) # in channel message, the kind we are interested in if(m.message =~ /(\+\+|--)/) string = m.message.sub(/\W(--|\+\+)(\(.*?\)|[^(++)(--)\s]+)/, "\2\1") seen = Hash.new while(string.sub!(/(\(.*?\)|[^(++)(--)\s]+)(\+\+|--)/, "")) key = $1 change = $2 next if seen[key] seen[key] = true key.sub!(/^\((.*)\)$/, "\1") key.gsub!(/\s+/, " ") next unless(key.length > 0) next if(key == m.sourcenick) if(change == "++") @karmas[key] += 1 elsif(change == "--") @karmas[key] -= 1 end end elsif(m.message =~ /karma\s+for\s+(\S+)\s*\?$/) thing=$1 karma = @karmas[thing] if(karma != 0) m.reply "karma for #{thing}: #{@karmas[thing]}" else m.reply "#{thing} has neutral karma" end end end end