From 4658f1b4ad280cfd46f327b0eb37c3cb8af4acba Mon Sep 17 00:00:00 2001 From: Vincent Le Gallic Date: Sat, 26 May 2012 22:03:29 +0200 Subject: [PATCH] =?utf8?q?On=20r=C3=A9agit=20si=20le=20si=C3=A8cle=20est?= =?utf8?q?=20bon.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- historien.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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"]" -- 2.39.2