From: Vincent Le Gallic Date: Sat, 26 May 2012 20:03:29 +0000 (+0200) Subject: On réagit si le siècle est bon. X-Git-Url: http://gitweb.pimeys.fr/?p=bots%2Fhistorien.git;a=commitdiff_plain;h=4658f1b4ad280cfd46f327b0eb37c3cb8af4acba On réagit si le siècle est bon. --- diff --git a/historien.py b/historien.py index 7282f37..06bdae9 100755 --- a/historien.py +++ b/historien.py @@ -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"]"