X-Git-Url: http://gitweb.pimeys.fr/?p=bots%2Fhistorien.git;a=blobdiff_plain;f=historien.py;h=06bdae96c570cde9e8fe8a6caf3798685df08a00;hp=7282f375d9a428fd9711e22958e00f8666fc7a17;hb=4658f1b4ad280cfd46f327b0eb37c3cb8af4acba;hpb=0fa2bfa097f78a5a2e243aab44e042d47afed6f9 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"]"