X-Git-Url: http://gitweb.pimeys.fr/?p=bots%2Fbasile.git;a=blobdiff_plain;f=nk.py;h=0cbaed023bd3149f95cb1330126db4e48f2e8f01;hp=f7f4bb30d378766aa541bef42ceee82e5f286ab3;hb=667757031c816e434da2065b2d129402a7a72f5f;hpb=5076791b641fced9605fb52fd5ce56aacda40f89 diff --git a/nk.py b/nk.py index f7f4bb3..0cbaed0 100644 --- 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: