+ match = self.quote_pattern.match(message)
+ if match:
+ d = match.groupdict()
+ if self.quotedb.store(d["author"], d["content"]):
+ serv.privmsg(canal, (u"%s: Ce sera retenu, répété, amplifié" % (auteur,)).encode("utf-8"))
+ self.quotedb.save()
+ else:
+ serv.privmsg(canal, (u"%s: Je le savais déjà." % (auteur,)).encode("utf-8"))
+ if message.startswith(u"!quote"):
+ if message.strip() == u"!quote":
+ q = self.quotedb.random()
+ serv.privmsg(canal, str(q))
+ elif message.startswith("!quote "):
+ author = message[7:].strip()
+ try:
+ q = self.quotedb.randomfrom(author)
+ except IndexError:
+ serv.privmsg(canal, (u"Pas de quote de %s en mémoire." % author).encode("utf-8"))
+ return
+ serv.privmsg(canal, str(q))
+ elif message.startswith(u"!author"):
+ words = message.split()
+ cmd = words[0].lstrip("!")
+ regexp = cmd in ["author" + suffix for suffix in config.regex_suffixes]
+ search = u" ".join(words[1:])
+ authors = self.quotedb.search_authors(search, regexp)
+ if len(authors) > config.search_max_authors:
+ authors = authors[:config.search_max_authors+1] + ["+%s" % (len(authors) - config.search_max_authors)]
+ if authors:
+ serv.privmsg(canal, "%s: %s" % (auteur, (u", ".join(authors)).encode("utf-8")))
+ else:
+ serv.privmsg(canal, "%s: Pas d'auteur correspondant à la recherche." % (auteur,))