X-Git-Url: http://gitweb.pimeys.fr/?p=bots%2Fparrot.git;a=blobdiff_plain;f=parrot.py;fp=parrot.py;h=8ce0673d5d315ae5a62b476be3b6b7cd714346e1;hp=ae7adb91b6ac2a1051d477e32c5478715d787cbe;hb=96f8fe13b9dbcab83f3123b37bc620c562a1e214;hpb=b393b2849cc38986109ceabe2501919c12487859 diff --git a/parrot.py b/parrot.py index ae7adb9..8ce0673 100755 --- a/parrot.py +++ b/parrot.py @@ -439,10 +439,17 @@ class Parrot(ircbot.SingleServerIRCBot): self.quotedb.save() else: serv.privmsg(canal, (u"%s: Je le savais déjà." % (auteur,)).encode("utf-8")) + # Whou, attention, hack dégueu + # on enlève context- au début des !commands si il y est, + # et on passe à True le paramètre show_context pour s'en souvenir + show_context = False + if message.startswith(u"!context-"): + show_context = True + message = u"!" + message[9:] if message.startswith(u"!quote"): if message.strip() == u"!quote": q = self.quotedb.random() - serv.privmsg(canal, str(q)) + serv.privmsg(canal, q.display(show_context)) elif message.startswith("!quote "): author = message[7:].strip() try: @@ -450,7 +457,7 @@ class Parrot(ircbot.SingleServerIRCBot): except IndexError: serv.privmsg(canal, (u"Pas de quote de %s en mémoire." % author).encode("utf-8")) return - serv.privmsg(canal, str(q)) + serv.privmsg(canal, q.display(show_context)) elif message.startswith(u"!author") or message.startswith(u"!from"): words = message.split() cmd = words[0].lstrip("!") @@ -467,7 +474,7 @@ class Parrot(ircbot.SingleServerIRCBot): elif cmd.startswith("from"): quotes = sum([self.quotedb.quotesfrom(a) for a in authors], []) q = random.choice(quotes) - serv.privmsg(canal, str(q)) + serv.privmsg(canal, q.display(show_context)) elif message.startswith(u"!search"): words = message.split() cmd = words[0].lstrip("!") @@ -476,7 +483,7 @@ class Parrot(ircbot.SingleServerIRCBot): quotes = self.quotedb.search(inquote=search, regexp=regexp) if quotes: q = random.choice(quotes) - serv.privmsg(canal, str(q)) + serv.privmsg(canal, q.display(show_context)) else: serv.privmsg(canal, "%s: Pas de quotes correspondant à la recherche." % (auteur,))