]> gitweb.pimeys.fr Git - bots/hung.git/commitdiff
leave messages
authorVincent Le Gallic <legallic@crans.org>
Thu, 24 May 2012 22:45:29 +0000 (00:45 +0200)
committerVincent Le Gallic <legallic@crans.org>
Thu, 24 May 2012 22:45:29 +0000 (00:45 +0200)
hung.py

diff --git a/hung.py b/hung.py
index 8e864bf9d6b44548c4600cc183eb089d36cdc8c8..6be04dd5658bbd25f462bb708f35626bc28639b2 100755 (executable)
--- 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)