diff --git a/machineACafe.py b/machineACafe.py index a3533f7..6dccb04 100644 --- a/machineACafe.py +++ b/machineACafe.py @@ -32,7 +32,7 @@ async def on_ready(): @client.event async def on_message(message): - + ########################## PARTIE CAFE ################################### if (re.match("(.)*(cafe|café|kfé|kfe|kaf|caf|kawa)(.)*", message.content) and not message.author.bot): @@ -60,7 +60,7 @@ async def on_message(message): ########################## PARTIE COURSES ################################### global state, messages, courreurs, parieurs - + if (message.content == "$course" and not message.author.bot and state == 0): state+= 1 messages["concurrents"] = await message.channel.send("Choisissez les émojis qui vont faire la course, ensuite envoyez $ready") @@ -70,12 +70,12 @@ async def on_message(message): if (messages["concurrents"].reactions): state += 1 messages["paris"] = await message.channel.send("Faites vos paris ! ensuite envoyez $start") - + for reaction in messages["concurrents"].reactions: - + #montre les possibilités de vote await messages["paris"].add_reaction(reaction) - + # création de la course courreurs.append({ 'reaction': reaction, 'avance': 1, 'votes': [], 'course': None}) @@ -91,13 +91,13 @@ async def on_message(message): if not courreur["votes"]: usersList = "Personne n'" for user in courreur["votes"]: - usersList += user.name + ", " + usersList += message.guild.get_member(user.id).nick + ", " await message.channel.send("{} a.ont parié.e.s pour {}".format(usersList, courreur["reaction"].emoji)) # affichage de la course await message.channel.send("---------------------- Debut de la course ----------------------") - for courreur in courreurs: + for courreur in courreurs: courreur["course"] = await message.channel.send(':triangular_flag_on_post:' + courreur["avance"] * " " + courreur["reaction"].emoji + (RACE_LENGTH - courreur["avance"]) * " " + ":checkered_flag:") - + # on fait la course !!! while True: # on avance un courreur random @@ -121,20 +121,19 @@ async def on_message(message): for parieur in podium[0]["votes"]: c.execute(f'INSERT OR IGNORE INTO users VALUES ({parieur.id}, "{parieur.name}", 0, 0, 0);') c.execute(f'UPDATE users SET balance = balance + 50, nbBets = nbBets + 1 WHERE id LIKE {parieur.id};') - await message.channel.send(f'{parieur.name} a gagné 50 tc-dollars') + await message.channel.send(f'{message.guild.get_member(parieur.id).nick} a gagné 50 tc-dollars') await message.channel.send(":second_place: " + podium[1]["reaction"].emoji) for parieur in podium[1]["votes"]: c.execute(f'INSERT OR IGNORE INTO users VALUES ({parieur.id}, "{parieur.name}", 0, 0, 0);') c.execute(f'UPDATE users SET balance = balance + 40, nbBets = nbBets + 1 WHERE id LIKE {parieur.id};') - await message.channel.send(f'{parieur.name} a gagné 40 tc-dollars') + await message.channel.send(f'{message.guild.get_member(parieur.id).nick} a gagné 40 tc-dollars') await message.channel.send(":third_place: " + podium[2]["reaction"].emoji) for parieur in podium[2]["votes"]: c.execute(f'INSERT OR IGNORE INTO users VALUES ({parieur.id}, "{parieur.name}", 0, 0, 0);') c.execute(f'UPDATE users SET balance = balance + 30, nbBets = nbBets + 1 WHERE id LIKE {parieur.id};') - await message.channel.send(f'{parieur.name} a gagné 30 tc-dollar') - + await message.channel.send(f'{message.guild.get_member(parieur.id).nick} a gagné 30 tc-dollar') finally: conn.commit() # udpate the changes in db state = 0 # back to normal state @@ -147,7 +146,8 @@ async def on_message(message): elif(message.content == "$richiestboard" and state == 0 and not message.author.bot): await message.channel.send(":first_place: ---- Richiestboard ---- :first_place:") for index, row in enumerate(c.execute('SELECT * FROM users ORDER BY balance DESC LIMIT 10')): - await message.channel.send(f'{index + 1} --- {row[1]} avec {row[2]} tc-dollars') + await message.channel.send( + f'{index + 1} --- {message.guild.get_member(row[0]).nick} avec {row[2]} tc-dollars') elif(message.content == "$myscore" and state == 0 and not message.author.bot): c.execute(f'SELECT * FROM users WHERE id={message.author.id}') @@ -159,12 +159,12 @@ async def on_message(message): @client.event async def on_reaction_add(reaction, user): - + # * Working # stockage des reactions aux messages du bot if (reaction.message.id == messages["concurrents"].id and reaction not in messages["concurrents"].reactions): messages["concurrents"].reactions.append(reaction) - + # stockage des paris if (state == 2 and reaction.message.id == messages["paris"].id and not user == client.user and user not in parieurs): for courreur in courreurs: # on evite les emojis qui ne sont pas en compet diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..18df8e5 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,17 @@ +aiohttp==3.6.2 +async-timeout==3.0.1 +attrs==20.2.0 +chardet==3.0.4 +discord==1.0.1 +discord.py==1.4.1 +discord.py-stubs==1.4.0.2 +idna==2.10 +idna-ssl==1.1.0 +install==1.3.3 +multidict==4.7.6 +mypy==0.782 +mypy-extensions==0.4.3 +python-dotenv==0.14.0 +typed-ast==1.4.1 +typing-extensions==3.7.4.3 +yarl==1.5.1