X-Git-Url: http://gitweb.pimeys.fr/?a=blobdiff_plain;f=basile.py;h=bad7c8fe38230159137adf6d56e0802b1b20a144;hb=0cf07b92e97aaefaaf8c5d0a5506a13bd75819b5;hp=e4426ae1d7ac095cf8873ea6259e6207d18c2984;hpb=f0cc860eaf72baa51e3838738cb4b1fa44f610c5;p=bots%2Fbasile.git diff --git a/basile.py b/basile.py index e4426ae..bad7c8f 100755 --- a/basile.py +++ b/basile.py @@ -178,9 +178,13 @@ def connect_NK(): def login_NK(username,password,typ="bdd"): sock=connect_NK() + if typ=="special": # ça c'est pour Basile lui-même + masque='["note"]' + elif typ=="bdd": + masque='[["all"],["all"],false]' try: # Basile a un compte special user - commande='login [%s,%s,"%s",[["note"],[],false]]'%(json.dumps(username),json.dumps(password),typ) + commande='login [%s,%s,"%s",%s]'%(json.dumps(username),json.dumps(password),typ,masque) sock.write(commande) out=sock.read() except Exception as exc: @@ -428,13 +432,15 @@ class Basile(ircbot.SingleServerIRCBot): HELP Affiche de l'aide sur une commande. CONNECT Ouvre une connection au serveur Note Kfet. IDENTIFY Me permet de savoir qui tu es sur la note kfet. - DROP Me fait oublier ton identité.""" + DROP Me fait oublier ton identité. + SOLDE Obtenir ton solde""" helpmsg_ops=""" JOIN Faire rejoindre un chan LEAVE Faire quitter un chan QUIET Se taire sur un chan NOQUIET Opposé de QUIET - LOST Perdre sur un chan""" + LOST Perdre sur un chan + SOLDE Donner le solde de quelqu'un""" helpmsg_overops=""" SAY Fais envoyer un message sur un chan ou à une personne STAY Ignorera les prochains LEAVE pour un chan @@ -590,6 +596,32 @@ class Basile(ircbot.SingleServerIRCBot): serv.privmsg(auteur,"Syntaxe : LOST ") else: notunderstood=True + elif cmd=="solde": + if len(message)==1: + if self.identities.has_key(auteur): + try: + self.nk.write('search ["x",["pseudo"],%s]'%(json.dumps(auteur))) + ret=json.loads(self.nk.read()) + solde=ret["msg"][0]["solde"] + pseudo=ret["msg"][0]["pseudo"] + except Exception as exc: + serv.privmsg(auteur,"failed") + log(self.serveur,"priv",auteur," ".join(message)+"[failed]") + return + serv.privmsg(auteur,"%s (%s)"%(float(solde)/100,pseudo.encode("utf8"))) + else: + serv.privmsg(canal,"Je ne connais pas ton pseudo note.") + elif auteur in self.ops: + try: + self.nk.write('search ["x",["pseudo"],%s]'%(json.dumps(message[1]))) + ret=json.loads(self.nk.read()) + solde=ret["msg"][0]["solde"] + pseudo=ret["msg"][0]["pseudo"] + except Exception as exc: + serv.privmsg(auteur,"failed") + log(self.serveur,"priv",auteur," ".join(message)+"[failed]") + return + serv.privmsg(auteur,"%s (%s)"%(float(solde)/100,pseudo.encode("utf8"))) else: notunderstood=True if notunderstood: @@ -602,9 +634,10 @@ class Basile(ircbot.SingleServerIRCBot): try: test=bot_unicode(message) except UnicodeBotError: - serv.privmsg(canal, - "%s: Euh, tu fais de la merde avec ton encodage là, j'ai failli crasher…"%(auteur)) - return + if not canal in self.quiet_channels: + serv.privmsg(canal, + "%s: Euh, tu fais de la merde avec ton encodage là, j'ai failli crasher…"%(auteur)) + return pour_moi,message=self.pourmoi(serv,message) if pour_moi and message.split()!=[]: cmd=message.split()[0].lower()