From 67007d667863c145b09efb751d6237c3e5f8396e Mon Sep 17 00:00:00 2001 From: Vincent Le Gallic Date: Fri, 25 May 2012 00:45:29 +0200 Subject: [PATCH] leave messages --- hung.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hung.py b/hung.py index 8e864bf..6be04dd 100755 --- a/hung.py +++ b/hung.py @@ -60,6 +60,7 @@ u"B _ E, C R U E L _ O R L D!", u"B Y E, C R U E L _ O R L D!", u"B Y E, C R U E L W O R L D!", ] +config_leave_messages=["On finira la partie plus tard :p"] def log(serveur,channel,auteur=None,message=None): f=open(get_config_logfile(serveur),"a") @@ -175,7 +176,7 @@ class Hung(ircbot.SingleServerIRCBot): if auteur in self.ops and len(message)>1: if message[1] in self.chanlist: if not (message[1] in self.stay_channels) or auteur in self.overops: - serv.part(message[1]) + self.quitter(message[1]," ".join(message[2:])) self.chanlist.remove(message[1]) log(self.serveur,"priv",auteur," ".join(message)+"[successful]") else: @@ -346,7 +347,7 @@ class Hung(ircbot.SingleServerIRCBot): elif cmd in ["part","leave","dégage"]: if auteur in self.ops and (not (canal in self.stay_channels) or auteur in self.overops): - serv.part(canal,message="Éjecté par %s"%(auteur)) + self.quitter(canal) log(self.serveur,canal,auteur,message+"[successful]") if canal in self.chanlist: self.chanlist.remove(canal) @@ -428,6 +429,11 @@ class Hung(ircbot.SingleServerIRCBot): return mypseudo=serv.get_nickname() + def quitter(self,chan,leave_message=None): + if leave_message==None: + leave_message=random.choice(config_leave_messages) + self.serv.part(chan,leave_message.encode("utf8")) + def mourir(self): quit_message=random.choice(config_quit_messages) self.die(message=config_quit_message) -- 2.39.2