]> gitweb.pimeys.fr Git - bots/parrot.git/blobdiff - parrot.py
!author : on affiche un message si pas de résultat
[bots/parrot.git] / parrot.py
index d3039a4a432711ec2c4a79683e03a184a84d1df2..6229e8d4a5c4189d82a0a6945fe5d8c3a52e4e50 100755 (executable)
--- a/parrot.py
+++ b/parrot.py
@@ -449,12 +449,15 @@ 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-r", "authorreg", "author-reg", "author-regex"]
                 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] + [unicode(len(authors) - config.search_max_authors)]
-                serv.privmsg(canal, "%s: %s" % (auteur, (u" ".join(authors)).encode("utf-8")))
+                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.")
 
     def on_action(self, serv, ev):
         """À la réception d'une action."""