From 3ca1406e40a4b5cea3d24d5684b8daabf54d4534 Mon Sep 17 00:00:00 2001 From: Vincent Le Gallic Date: Sat, 11 May 2013 15:48:25 +0200 Subject: [PATCH] On idle toujours quand les gens tuent le canard. --- config.py | 1 + salesman.py | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/config.py b/config.py index ce840f0..98a699d 100644 --- a/config.py +++ b/config.py @@ -48,3 +48,4 @@ leave_messages=[u"On continuera à jouer plus tard ;)"] idle_time=20*60 # liste des bots, qui ne sont pas considérés comme de l'activité idle_bots=["deconnaisseur","Basile","historien","hung","salesman","Shadobot","Wen","___","Sanctuary","Saturnin"] +idle_messages=["^(pan|bang|bim)$"] diff --git a/salesman.py b/salesman.py index a9a9da9..342b93f 100755 --- a/salesman.py +++ b/salesman.py @@ -111,7 +111,7 @@ class Salesman(ircbot.SingleServerIRCBot): for c in self.chanlist: log(self.serveur,"JOIN %s"%(c)) serv.join(c) - self.update_activity(c,"") # la chaîne vide ne sera jamais un nom de bot et donc marchera toujours + self.update_activity(c,force=True) for c in self.play_channels: token=time.time()-3600 self.play_status[c]=[0,token] @@ -436,7 +436,7 @@ class Salesman(ircbot.SingleServerIRCBot): auteur = irclib.nm_to_n(ev.source()) canal = ev.target() message = ev.arguments()[0] - self.update_activity(canal,auteur) + self.update_activity(canal,auteur,message) try: test=bot_unicode(message) except UnicodeBotError: @@ -538,7 +538,7 @@ class Salesman(ircbot.SingleServerIRCBot): log(self.serveur,"%s kické de %s par %s (raison : %s)" %(victime,channel,auteur,raison)) time.sleep(5) serv.join(channel) - self.update_activity(channel,"") + self.update_activity(channel,force=True) # on ne dit rien au rejoin #l1,l2=config.kick_answers,config.kick_actions #n1,n2=len(l1),len(l2) @@ -580,8 +580,8 @@ class Salesman(ircbot.SingleServerIRCBot): return self.serv.get_nickname() nick = property(_getnick) - def update_activity(self,canal,pseudo): - if not pseudo in config.idle_bots: + def update_activity(self,canal,pseudo,message,force=False): + if force or (not pseudo in config.idle_bots and all([not re.match(ignore, message) for ignore in config.idle_messages])): self.last_activity[canal]=time.time() def is_active(self,canal): return time.time()-self.last_activity[canal]