]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
karma check for self++ now case insensitive
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sat, 16 Dec 2006 23:00:30 +0000 (23:00 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sat, 16 Dec 2006 23:00:30 +0000 (23:00 +0000)
data/rbot/plugins/azgame.rb
data/rbot/plugins/karma.rb

index ec80478923e61d892d48770d7cd2a0509bcb99ae..ae059f7c687673dc98b86f3843e3f107980d096f 100644 (file)
@@ -6,6 +6,9 @@
 # (C) 2006 Giuseppe Bilotta\r
 #\r
 # TODO allow manual addition of words\r
+# TODO scoring: base score is t = ceil(100*exp(-(n-1)^2/50^))+p for n attempts\r
+#               done by p players; players that didn't win but contributed\r
+#               with a attempts will get t*a/n points\r
 \r
 AZ_RULES = {\r
   :italian => {\r
@@ -80,7 +83,7 @@ class AzGamePlugin < Plugin
   def listen(m)\r
     return unless m.kind_of?(PrivMessage)\r
     return if m.channel.nil? or m.address?\r
-    k = m.channel.to_s # to_sym?\r
+    k = m.channel.downcase.to_s # to_sym?\r
     return unless @games.key?(k)\r
     return if m.params\r
     word = m.plugin.downcase\r
@@ -108,7 +111,7 @@ class AzGamePlugin < Plugin
   end\r
 \r
   def manual_word_check(m, params)\r
-    k = m.channel.to_s\r
+    k = m.channel.downcase.to_s\r
     word = params[:word].downcase\r
     if not @games.key?(k)\r
       m.reply "no A-Z game running here, can't check for #{word}, can I?"\r
@@ -123,7 +126,7 @@ class AzGamePlugin < Plugin
 \r
   def stop_game(m, params)\r
     return if m.channel.nil? # Shouldn't happen, but you never know\r
-    k = m.channel.to_s # to_sym?\r
+    k = m.channel.downcase.to_s # to_sym?\r
     if @games.key?(k)\r
       m.reply "the word in #{Bold}#{@games[k].range}#{Bold} was:   #{Bold}#{@games[k].word}"\r
       @games.delete(k)\r
@@ -134,7 +137,7 @@ class AzGamePlugin < Plugin
 \r
   def start_game(m, params)\r
     return if m.channel.nil? # Shouldn't happen, but you never know\r
-    k = m.channel.to_s # to_sym?\r
+    k = m.channel.downcase.to_s # to_sym?\r
     unless @games.key?(k)\r
       lang = (params[:lang] || @bot.config['core.language']).to_sym\r
       method = 'random_pick_'+lang.to_s\r
@@ -333,7 +336,7 @@ class AzGamePlugin < Plugin
       return false\r
     end\r
     debug p\r
-    if p =~ /<span class="hwd">#{word}<\/span>([^\n]+?)<span class="psa">#{rules[:good]}<\/span>/i\r
+    if p =~ /<span class="(?:hwd|srch)">#{word}<\/span>([^\n]+?)<span class="psa">#{rules[:good]}<\/span>/i\r
       debug "new word #{word}"\r
         wc[word.to_sym] = {:who => :dict}\r
         return true\r
@@ -383,7 +386,7 @@ class AzGamePlugin < Plugin
         lemmi = Array.new\r
         good = rules[:good]\r
         # We look for a lemma composed by a single word and of length at least two\r
-        p.scan(/<span class="hwd">(.*?)<\/span>([^\n]+?)<span class="psa">#{rules[:good]}<\/span>/i) { |prelemma, discard|\r
+        p.scan(/<span class="(?:hwd|srch)">(.*?)<\/span>([^\n]+?)<span class="psa">#{rules[:good]}<\/span>/i) { |prelemma, discard|\r
           lemma = prelemma.downcase\r
           debug "checking lemma #{lemma} (#{prelemma}) and discarding #{discard}"\r
           next if wc.key?(lemma.to_sym)\r
index 166a9df46a717e3afb4a0da0298e5f6633a35555..f4716e2bd24c75269e718fc80ec6cabaf8048483 100644 (file)
@@ -69,7 +69,7 @@ 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