From 6ac9765ce7280aa6b2e5cf1acd4f45a53593a910 Mon Sep 17 00:00:00 2001 From: Hung IRC Bot Date: Sat, 8 Jun 2013 18:50:47 +0200 Subject: [PATCH] =?utf8?q?Possibilit=C3=A9=20de=20fournir=20des=20mots=20c?= =?utf8?q?ustom=20sur=20la=20commande=20PLAY?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- config.py | 2 +- hung.py | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/config.py b/config.py index b02816f..58c4a92 100644 --- a/config.py +++ b/config.py @@ -49,4 +49,4 @@ leave_messages=["On finira la partie plus tard :p"] #: Nombre de chances avant d'être pendu lives = 7 #: Caractères qui sont déjà affichés au début si il sont dans le mot -non_guess_chars = "'-()." +non_guess_chars = "'-(). " diff --git a/hung.py b/hung.py index 7616802..0000a91 100755 --- a/hung.py +++ b/hung.py @@ -194,8 +194,11 @@ class Hung(ircbot.SingleServerIRCBot): if auteur in self.ops: if len(message)>1: if message[1] in self.play_channels: - serv.privmsg(auteur,"Je play déjà sur %s."%(message[1])) - log(self.serveur,"priv",auteur," ".join(message)+"[failed]") + if len(message) > 2: + self.start_partie(serv, message[1], " ".join(message[2:])) + else: + serv.privmsg(auteur,"Je play déjà sur %s."%(message[1])) + log(self.serveur,"priv",auteur," ".join(message)+"[failed]") else: self.play_channels.append(message[1]) self.play_status[message[1]]=[None,None,None] @@ -319,11 +322,14 @@ class Hung(ircbot.SingleServerIRCBot): obfuskated=" ".join([lettre[0] if lettre[1] else "_" for lettre in mot]) serv.privmsg(canal,"%s : %s"%(begin,obfuskated)) - def start_partie(self, serv, canal): - mots=[mot.strip() for mot in open(config.dico_mots).readlines()] - defs=[defi.strip() for defi in open(config.dico_defs).readlines()] - indice = random.randrange(0,len(mots)) - mot,definition=mots[indice],defs[indice] + def start_partie(self, serv, canal, mot=None): + if mot is None: + mots=[mot.strip() for mot in open(config.dico_mots).readlines()] + defs=[defi.strip() for defi in open(config.dico_defs).readlines()] + indice = random.randrange(0,len(mots)) + mot,definition=mots[indice],defs[indice] + else: + definition = "(custom word)" # ' et - sont considérés comme déjà devinés mot = [(lettre,lettre in config.non_guess_chars) for lettre in list(mot)] self.play_status[canal]=[mot,definition,{}] -- 2.39.2