config_score_file="scores.pickle"
+config_tag_triggers=[u"t(|a)g",u"ta gueule",u"la ferme",u"ferme( |-)la",u"tais-toi",u"chut"]
+config_tag_actions=[u"se tait",u"ferme sa gueule",u"se la ferme",u"la ferme"]
+config_tag_answers=[u"J'me tais si j'veux !",
+u"Je t'entends pas :°",
+u"Héhé, try again",
+u"Non, j'ai pas envie",
+u"Peut-être quand toi tu la fermeras, et encore…"]
+
class UnicodeBotError(Exception):
pass
def bot_unicode(chain):
reg=reg.replace(u"œ",u"(œ|oe)").replace(u"æ",u"(æ|ae)")
return reg
+def is_something(chain,matches,avant=u".*(?:^| )",apres=u"(?:$|\.| |,|;).*",case_sensitive=False,debug=False):
+ if case_sensitive:
+ chain=unicode(chain,"utf8")
+ else:
+ chain=unicode(chain,"utf8").lower()
+ allmatches="("+"|".join(matches)+")"
+ reg=(avant+allmatches+apres).lower()
+ o=re.match(reg,chain)
+ return o
+
+def is_tag(chain):
+ return is_something(chain,config_tag_triggers)
+
class RefuseError(Exception):
pass
serv.privmsg(canal,"%s: pas ici…"%(auteur))
if cmd=="indice" and canal in self.play_channels:
self.give_indice(serv,canal,None)
+ if is_tag(message) and not canal in self.quiet_channels:
+ if auteur in self.ops:
+ action=random.choice(config_tag_actions)
+ serv.action(canal,action.encode("utf8"))
+ self.quiet_channels.append(canal)
+ else:
+ answer=random.choice(config_tag_answers)
+ for ligne in answer.split("\n"):
+ serv.privmsg(canal,"%s: %s"%(auteur,ligne.encode("utf8")))
else:
tryother=True
else: