diff --git a/nardco.py b/nardco.py index 0e7195b50a0bf0a45e07f8213875c9a3f057dcb9..eed08f3590bada214c39c7f5dd169319e68d0d97 100755 --- a/nardco.py +++ b/nardco.py @@ -60,9 +60,14 @@ global cmdCarac cmdCarac = "$" personnalizedCmd = {} + + reponse = None pas_reponse = [] a_repondu = [] +scores = {} +tour = 0 +total = 0 def isCommande(string): global cmdCarac @@ -140,6 +145,9 @@ class Boooob(ircbot.SingleServerIRCBot): global reponse global a_repondu global pas_reponse + global tour + global scores + global total canal = ev.target() @@ -209,15 +217,43 @@ class Boooob(ircbot.SingleServerIRCBot): if "Titch" in personne and "leave" in message and "nardco" in message: serv.part(canal) - if reponse is not None and fuzz.ratio(message, reponse) > 60 and personne not in a_repondu: - serv.privmsg(canal, personne + " a trouvé la reponse : {0} ! Bien joué !".format(reponse)) - reponse = None - a_repondu = [] - pas_reponse = [] - - if reponse is not None and message in pas_reponse and personne not in a_repondu : - serv.privmsg(canal, "WRONG, {0}".format(personne)) - a_repondu.append(personne) + if reponse is not None : + if fuzz.ratio(message, reponse) > 60 and personne not in a_repondu: + serv.privmsg(canal, personne + " a trouvé la reponse : {0} ! Bien joué !".format(reponse)) + reponse = None + a_repondu = [] + pas_reponse = [] + tour+=1 + if personne in scores.keys() : + scores[personne]+=1 + else : + scores[personne] = 1 + + if tour == total + 1 : + maxScore = 0 + gagnant = '' + + for pseudo in scores.keys() : + if scores[pseudo] > maxScore : + maxScore = scores[pseudo] + gagnant = pseudo + serv.privmsg(canal, "${0} a gagné avec un score de ${1}".format(gagnant, maxScore)) + scores = {} + tour = 0 + total = 0 + else : + datas = quizz() + reponse = datas['reponse'].lower() + choix = datas['choix'] + question= datas['question'] + serv.privmsg(canal, "Question : {0}".format(question.format('utf8'))) + serv.privmsg(canal, "Choix: {0}".format(', '.join(choix).format('utf8'))) + else : + for mot in pas_reponse : + if mot.lower() in message and personne not in a_repondu : + serv.privmsg(canal, "WRONG, {0}".format(personne)) + a_repondu.append(personne) + if not is_l_heure_de_manger() and should_ban(message) : serv.privmsg(canal, "PUTAIN ON A DIT NON")