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):
except UnicodeDecodeError:
raise UnicodeBotError
-def log(channel,auteur=None,message=None):
+def log(serveur,channel="prout",auteur=None,message=None):
#f=open(config_logfile,"a")
#if auteur==message==None:
# chain=channel
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
self.stay_channels=config_stay_channels
self.play_channels=config_play_channels
self.play_status={i:[0] for i in self.play_channels}
- self.quiet_channels={}
+ self.quiet_channels=[]
def give_me_my_pseudo(self,serv):
serv.privmsg("NickServ","RECOVER %s %s"%(config_pseudo,config_password))
if not canal in self.quiet_channels:
serv.privmsg(canal,
"%s: Euh, tu fais de la merde avec ton encodage là, j'ai failli crasher…"%(auteur))
- return
+ return
tryother=False
pour_moi,message=self.pourmoi(serv,message)
if pour_moi and message.split()!=[]:
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: