From f86d3f62f5e99220deeba536d62eb710df78f333 Mon Sep 17 00:00:00 2001 From: Vincent Le Gallic Date: Wed, 12 Feb 2014 14:23:04 +0100 Subject: [PATCH] On ne retient pas les trailing spaces d'un author --- config.py | 2 +- parrot.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) 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: -- 2.39.2