]> gitweb.pimeys.fr Git - bots/hung.git/blobdiff - hung.py
Fail float/int + compter le bonus qu'on annonce, c'est mieux
[bots/hung.git] / hung.py
diff --git a/hung.py b/hung.py
index 9517d2782ab66cddd546f147d8d74ce2ad1cd70d..2c3e7086dbb9955b8b5e970cf8e30a1a5b736911 100755 (executable)
--- a/hung.py
+++ b/hung.py
@@ -32,7 +32,7 @@ def get_config_logfile(serveur):
 
 def log(serveur,channel,auteur=None,message=None):
     f=open(get_config_logfile(serveur),"a")
-    if auteur==message==None:
+    if auteur == message == None:
         # alors c'est que c'est pas un channel mais juste une ligne de log
         chain="%s %s"%(time.strftime("%F %T"),channel)
     else:
@@ -51,7 +51,8 @@ def ignore_event(serv, ev):
         else:
             exceptit = bool(irclib.mask_matches(usermask, exceptmask))
         blackit = bool(irclib.mask_matches(usermask, blackmask))
-        return blackit and not exceptit
+        if blackit and not exceptit:
+            return True
 
 class UnicodeBotError(Exception):
     pass
@@ -530,7 +531,7 @@ class Hung(ircbot.SingleServerIRCBot):
         realword = self.reveal_word(serv, canal)
         nlettre=float(len([l for l in realword if not l in config.non_guess_chars]))
         contribs=["%s:%s%%%s"%(pseudo,str(int(100*contrib/nlettre)),("+bonus(%s)"%(bonusvalue))*(bonus==pseudo)) for pseudo,contrib in self.play_status[canal][2].items()]
-        contribs_score={pseudo:int(10*contrib/nlettre) for pseudo,contrib in self.play_status[canal][2].items()}
+        contribs_score={pseudo:int(10.0*contrib/nlettre)+(bonusvalue*(bonus==pseudo)) for pseudo,contrib in self.play_status[canal][2].items()}
         self.add_score(contribs_score)
         serv.privmsg(canal,"Contributions : %s"%("  ".join(contribs)) )
         self.play_status[canal]=[None,None,None]