elif cmd in [u"ping"] and not canal in self.quiet_channels:
serv.privmsg(canal, "%s: pong" % (auteur))
- elif cmd in [u"solde", u"!solde", u"!coca"]:
+ elif cmd in [u"solde", u"!solde", u"!coca"] or cmd.startswith("!"):
if self.identities.has_key(auteur):
idbde = self.identities[auteur]["idbde"]
if cmd in [u"solde", u"!solde"]:
success, solde, pseudo = nk.get_solde(self.nk, self.identities[auteur]["idbde"], serv, canal)
if success:
serv.privmsg(canal, "%s: %s (%s)" % (auteur, float(solde)/100, pseudo.encode("utf8")))
- elif cmd in [u"!coca"]:
- success = nk.consomme(self.nk, self.identities[auteur]["idbde"], u"Coca", serv, canal)
+ elif cmd in [u"!coca"] or cmd.startswith("!"):
+ success = nk.consomme(self.nk, self.identities[auteur]["idbde"], message[1:], serv, canal)
log(self.serveur, canal, auteur, message + ("[successful]" if success else "[failed]"))
else:
serv.privmsg(canal, "%s: Je ne connais pas votre pseudo note." % (auteur))
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: