From 5b9b138da2be9fff2473d21afac12f6c268392a5 Mon Sep 17 00:00:00 2001 From: Vincent Le Gallic Date: Mon, 26 Nov 2012 20:59:56 +0100 Subject: [PATCH] =?utf8?q?Am=C3=A9lioration=20de=20l'erreur=20de=20Crash.?= =?utf8?q?=20(=C3=87a=20fait=20quand=20m=C3=AAme=20pas=20ce=20que=20je=20v?= =?utf8?q?eux)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- basile.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/basile.py b/basile.py index 610a346..58d8250 100755 --- a/basile.py +++ b/basile.py @@ -169,7 +169,8 @@ class UnicodeBotError(Exception): class CrashError(Exception): """Pour pouvoir faire crasher Basile, parce que ça a l'air drôle""" - pass + def __init__(self, msg=u""): + Exception.__init__(self, msg) def bot_unicode(chain): try: @@ -447,7 +448,7 @@ class Basile(ircbot.SingleServerIRCBot): elif cmd=="crash": if auteur in self.overops: log(self.serveur,"priv",auteur," ".join(message)+"[successful]") - self.crash() + self.crash("priv", auteur) else: notunderstood=True elif cmd=="reload": @@ -605,7 +606,7 @@ class Basile(ircbot.SingleServerIRCBot): self.reload(canal) elif cmd == "crash": if auteur in self.overops: - self.crash() + self.crash(auteur, message) elif cmd in ["part","leave","dégage","va-t-en","tut'tiresailleurs,c'estmesgalets"]: if auteur in self.ops and (not (canal in self.stay_channels) or auteur in self.overops): @@ -862,8 +863,9 @@ class Basile(ircbot.SingleServerIRCBot): else: self.serv.privmsg(auteur,"Config reloaded") - def crash(self): - raise CrashError + def crash(self, chan="nowhere", who="nobody"): + where = u"en privé" if chan == "priv" else u"sur le chan %s" % chan + raise CrashError(u"Crash demandé par %s %s" % (who, where)) def start_as_daemon(self, outfile): sys.stderr = Logger(outfile) -- 2.39.2