]> gitweb.pimeys.fr Git - bots/basile.git/blobdiff - nk.py
Maintenant on peut consommer n'importe quoi
[bots/basile.git] / nk.py
diff --git a/nk.py b/nk.py
index f7f4bb30d378766aa541bef42ceee82e5f286ab3..0cbaed023bd3149f95cb1330126db4e48f2e8f01 100644 (file)
--- a/nk.py
+++ b/nk.py
@@ -115,8 +115,11 @@ def consomme(sock, idbde, conso, serv, canal):
         retcode = ret["retcode"]
         if retcode == 0:
             boutons = ret["msg"]
-            ibouton = [b["label"].lower() for b in boutons].index(conso.lower())
-            bouton = boutons[ibouton]
+            boutons = [b for b in boutons if b["label"].lower() == conso.lower()]
+            if len(boutons) == 0:
+                serv.privmsg(canal, (u"Impossible de trouver la conso %s" % (conso)).encode("utf-8"))
+                return False
+            bouton = boutons[0]
             sock.write(json.dumps(["consos", [[bouton["id"], idbde, 1]]]))
             ret = full_read(sock)
             if ret["retcode"] == 0: