X-Git-Url: http://gitweb.pimeys.fr/?a=blobdiff_plain;f=parrot.py;h=8ce0673d5d315ae5a62b476be3b6b7cd714346e1;hb=96f8fe13b9dbcab83f3123b37bc620c562a1e214;hp=c948dfe0e4367b1340f0c1bb8376239d2f9c8bda;hpb=a34f731c8204d8a204ff85c0665a5b46e779d63b;p=bots%2Fparrot.git diff --git a/parrot.py b/parrot.py index c948dfe..8ce0673 100755 --- a/parrot.py +++ b/parrot.py @@ -425,7 +425,7 @@ class Parrot(ircbot.SingleServerIRCBot): self.dump(asked_by=auteur, asked_where=canal) elif cmd in [u"restore"] and auteur in self.overops: self.restore(asked_by=auteur, asked_where=canal) - elif cmd in [u"display"]: + elif cmd in [u"display", u"link", u"url"]: 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 @@ -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,))