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:
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("!")
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("!")
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,))