blacklisted_masks = [("Flo!*@*", [])]
#: Regexp utilisée pour parser des quotes
-quote_regexp = ur"""\s*(?:"|«|')\s*(?P<content>.+?)\s*(?:"|»|') ?~ ?(?P<author>.+?)\s*(?:$|\n)"""
+quote_regexp = ur"""\s*(?:"|«|')\s*(?P<content>.+?)\s*(?:"|»|')\s*~\s*(?P<author>.+?)\s*(?:$|\n)"""
#: Regexp utlisée pour parser une quote avec timestamp
quote_regexp_with_timestamp = ur"(?P<timestamp>.{19}) " + quote_regexp
self.serv.privmsg(canal, "%s: %s" % (auteur, config.quote_display_url.encode("utf-8")))
else:
# Vu que ce bot est prévu pour parser des quotes il va falloir bosser ici
- match = quote_pattern.match(message)
+ match = self.quote_pattern.match(message)
if match:
d = match.groupdict()
if self.quotedb.store(d["author"], d["content"]):
import config
+quote_matcher = re.compile(config.quote_regexp, flags=re.UNICODE)
+quote_matcher_with_timestamp = re.compile(config.quote_regexp_with_timestamp, flags=re.UNICODE)
+
def get_now():
""" Renvoie la date actuelle """
return datetime.datetime(*time.localtime()[:6])
Indépendamment de la date. """
return [self.author, self.content] == [otherquote.author, otherquote.content]
-quote_matcher = re.compile(config.quote_regexp)
def parse(text, date=None):
""" Parse le ``text`` et renvoie une quote ou None. """
with open(dump_file) as f:
t = f.read()
t = t.decode("utf-8") # Oui, ça peut fail, mais on ne doit alors pas continuer
- regex = re.compile(config.quote_regexp_with_timestamp)
- l = [m.groupdict() for m in regex.finditer(t)]
+ l = [m.groupdict() for m in quote_matcher_with_timestamp.finditer(t)]
# On instancie les quotes grâce aux dicos qui ont déjà la bonne tronche
l = [Quote(**q) for q in l]
newquotedb = QuoteDB()