From: Vincent Le Gallic Date: Wed, 12 Feb 2014 13:23:04 +0000 (+0100) Subject: On ne retient pas les trailing spaces d'un author X-Git-Url: http://gitweb.pimeys.fr/?a=commitdiff_plain;h=f86d3f62f5e99220deeba536d62eb710df78f333;p=bots%2Fparrot.git On ne retient pas les trailing spaces d'un author --- diff --git a/config.py b/config.py index c42357e..ae88a91 100644 --- a/config.py +++ b/config.py @@ -110,7 +110,7 @@ helpmsg_overops = u" SAY DO STAY NOSTAY OPS OVEROPS KICK DIE CRASH" blacklisted_masks = [("Flo!*@*", [])] #: Regexp utilisée pour parser des quotes -quote_regexp = ur"""\s*("|«|')\s*(?P.*?)\s*("|»|') ?~ ?(?P.*)""" +quote_regexp = ur"""\s*("|«|')\s*(?P.*?)\s*("|»|') ?~ ?(?P.*?)\s*$""" #: Template pour afficher une quote quote_template = u"« %(content)s » ~ %(author)s" diff --git a/parrot.py b/parrot.py index cf033b7..01ed82a 100755 --- a/parrot.py +++ b/parrot.py @@ -85,7 +85,8 @@ class Parrot(ircbot.SingleServerIRCBot): self.last_perdu = 0 self.quotedb = quotes.QuoteDB() - self.quotedb.load() + self.reload_quotes() + ### Utilitaires def _getnick(self): @@ -122,10 +123,15 @@ class Parrot(ircbot.SingleServerIRCBot): quit_message = random.choice(config.quit_messages) self.die(msg=quit_message.encode("utf8")) + def reload_quotes(self): + """ Recharge la base de données des quotes et recompile la regexp de quote """ + self.quotedb.load() + self.quote_pattern = re.compile(config.quote_regexp, flags=re.UNICODE) + def execute_reload(self, auteur=None): """Recharge la config.""" reload(config) - self.quotedb.load() + self.reload_quotes() if auteur in [None, "SIGHUP"]: towrite = "Config reloaded" + " (SIGHUP received)" * (auteur == "SIGHUP") for to in config.report_bugs_to: