X-Git-Url: http://gitweb.pimeys.fr/?a=blobdiff_plain;f=parrot.py;h=1f5b70def7f3b3aa91f987595253692ce024fdd7;hb=ceb91bbbe344c41702edb1707a7d4b05ecca2e39;hp=0c4006fc0e1ad6c0e6a14c2780d20b5bd4581e41;hpb=429401c797769a35ad0c6310e81f03f161e198ff;p=bots%2Fparrot.git diff --git a/parrot.py b/parrot.py index 0c4006f..1f5b70d 100755 --- a/parrot.py +++ b/parrot.py @@ -449,7 +449,7 @@ class Parrot(ircbot.SingleServerIRCBot): elif message.startswith(u"!author"): words = message.split() cmd = words[0].lstrip("!") - regexp = cmd in ["author-r", "authorreg", "author-reg", "author-regex"] + 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: @@ -458,6 +458,17 @@ class Parrot(ircbot.SingleServerIRCBot): serv.privmsg(canal, "%s: %s" % (auteur, (u", ".join(authors)).encode("utf-8"))) else: serv.privmsg(canal, "%s: Pas d'auteur correspondant à la recherche." % (auteur,)) + elif message.startswith(u"!search"): + words = message.split() + cmd = words[0].lstrip("!") + regexp = cmd in ["search" + suffix for suffix in config.regex_suffixes] + search = u" ".join(words[1:]) + quotes = self.quotedb.search(inquote=search, regexp=regexp) + if quotes: + q = random.choice(quotes) + serv.privmsg(canal, str(q)) + else: + serv.privmsg(canal, "%s: Pas de quotes correspondant à la recherche." % (auteur,)) def on_action(self, serv, ev): """À la réception d'une action."""