Skip to content
Extraits de code Groupes Projets
Valider d6304873 rédigé par Loris TICHADOU's avatar Loris TICHADOU
Parcourir les fichiers

add quizz

parent a01e9653
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -60,9 +60,14 @@ global cmdCarac ...@@ -60,9 +60,14 @@ global cmdCarac
cmdCarac = "$" cmdCarac = "$"
personnalizedCmd = {} personnalizedCmd = {}
reponse = None reponse = None
pas_reponse = [] pas_reponse = []
a_repondu = [] a_repondu = []
scores = {}
tour = 0
total = 0
def isCommande(string): def isCommande(string):
global cmdCarac global cmdCarac
...@@ -140,6 +145,9 @@ class Boooob(ircbot.SingleServerIRCBot): ...@@ -140,6 +145,9 @@ class Boooob(ircbot.SingleServerIRCBot):
global reponse global reponse
global a_repondu global a_repondu
global pas_reponse global pas_reponse
global tour
global scores
global total
canal = ev.target() canal = ev.target()
...@@ -209,16 +217,44 @@ class Boooob(ircbot.SingleServerIRCBot): ...@@ -209,16 +217,44 @@ class Boooob(ircbot.SingleServerIRCBot):
if "Titch" in personne and "leave" in message and "nardco" in message: if "Titch" in personne and "leave" in message and "nardco" in message:
serv.part(canal) serv.part(canal)
if reponse is not None and fuzz.ratio(message, reponse) > 60 and personne not in a_repondu: 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)) serv.privmsg(canal, personne + " a trouvé la reponse : {0} ! Bien joué !".format(reponse))
reponse = None reponse = None
a_repondu = [] a_repondu = []
pas_reponse = [] pas_reponse = []
tour+=1
if reponse is not None and message in pas_reponse and personne not in a_repondu : 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)) serv.privmsg(canal, "WRONG, {0}".format(personne))
a_repondu.append(personne) a_repondu.append(personne)
if not is_l_heure_de_manger() and should_ban(message) : if not is_l_heure_de_manger() and should_ban(message) :
serv.privmsg(canal, "PUTAIN ON A DIT NON") serv.privmsg(canal, "PUTAIN ON A DIT NON")
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter