]> gitweb.pimeys.fr Git - bots/historien.git/commitdiff
On réagit si le siècle est bon.
authorVincent Le Gallic <legallic@crans.org>
Sat, 26 May 2012 20:03:29 +0000 (22:03 +0200)
committerVincent Le Gallic <legallic@crans.org>
Sat, 26 May 2012 20:03:29 +0000 (22:03 +0200)
historien.py

index 7282f375d9a428fd9711e22958e00f8666fc7a17..06bdae96c570cde9e8fe8a6caf3798685df08a00 100755 (executable)
@@ -82,6 +82,9 @@ config_score_jour=4
 
 config_noscore=["[20-100]","[20-100]_"] # parce que 20-100 est nul en histoire
 
+class GoodCentury(Exception):
+    pass
+
 def reussi(message,answer,auteur):
     if auteur in config_level3:
         return answer in message
@@ -101,6 +104,8 @@ def reussi(message,answer,auteur):
                 score+=config_score_mois
                 if date[2]==realdate[2]:
                     score+=config_score_jour
+        elif date[0]/100 == realdate[0]/100:
+            raise GoodCentury
         return score
 
 def is_something(chain,matches,avant=u".*(?:^| )",apres=u"(?:$|\.| |,|;).*",case_sensitive=False,debug=False):
@@ -557,7 +562,11 @@ class Historien(ircbot.SingleServerIRCBot):
         if tryother:
             if self.play_status.get(canal,[-1])[0] in [1,2]:
                 answer=self.play_status[canal][1]
-                score_obtenu=reussi(message.decode("utf8"),answer,auteur)
+                try:
+                    score_obtenu=reussi(message.decode("utf8"),answer,auteur)
+                except GoodCentury:
+                    serv.privmsg(canal,"%s: C'est le bon siècle, mais pas la bonne année, cherche encore ;)"%(auteur))
+                    return
                 if score_obtenu:
                     if self.play_status[canal][0]==1:
                         bonusmsg=u" [+bonus_mois"*(score_obtenu>config_score_annee)+u"+bonus_jour"*(score_obtenu>config_score_annee+config_score_mois)+u"]"