Answer the question
In order to leave comments, you need to log in
How to make a win counter in db.bd in a rock paper scissors game and a certain user could press a button?
reviewed everything, found little useful ... It is necessary for the user to write
A gameand the bot started the game, it's already there
@dp.message_handler(lambda message: message.text.lower() == 'игра')
async def process_command_1(message: types.Message):
button1 = InlineKeyboardButton('Камень', callback_data = '1')
button2 = InlineKeyboardButton('✂️Ножницы', callback_data = '2')
button3 = InlineKeyboardButton('Бумага', callback_data = '3')
buttons = InlineKeyboardMarkup().add(button1, button2, button3)
await bot.send_message(message.chat.id, "Я готов!\nВыбери предмет, чтобы победить меня УАХАХА\n*зловещий смех*", reply_markup= buttons)
@dp.callback_query_handler(lambda c: c.data == '1')
async def process_callback_yes(callback: types.CallbackQuery):
rand = random.choice(["Камень", "✂️Ножницы", "Бумага"])
await bot.delete_message(callback.message.chat.id, callback.message.message_id)
await callback.message.answer("Я выбрал " + rand + "\nА ты выбрал Камень")
if rand == 'Камень':
await callback.message.answer("⚔️НИЧЬЯ⚔️")
elif rand == '✂️Ножницы':
await callback.message.answer("ПОБЕДА ЗА ТОБОЙ✅")
else:
await callback.message.answer("☠️Я ПОБЕДИЛ☠️")
@dp.callback_query_handler(lambda c: c.data == '2')
async def process_callback_yes(callback: types.CallbackQuery):
rand = random.choice(["Камень", "✂️Ножницы", "Бумага"])
await bot.delete_message(callback.message.chat.id, callback.message.message_id)
await callback.message.answer("Я выбрал " + rand + "\nА ты выбрал ✂️Ножницы")
if rand == 'Камень':
await callback.message.answer("☠️Я ПОБЕДИЛ☠️")
elif rand == '✂️Ножницы':
await callback.message.answer("⚔️НИЧЬЯ⚔️")
else:
await callback.message.answer("ПОБЕДА ЗА ТОБОЙ✅")
@dp.callback_query_handler(lambda c: c.data == '2')
async def process_callback_yes(callback: types.CallbackQuery):
rand = random.choice(["Камень", "✂️Ножницы", "Бумага"])
await bot.delete_message(callback.message.chat.id, callback.message.message_id)
await callback.message.answer("Я выбрал " + rand + "\nА ты выбрал ✂️Ножницы")
if rand == 'Камень':
await callback.message.answer("☠️Я ПОБЕДИЛ☠️")
elif rand == '✂️Ножницы':
await callback.message.answer("⚔️НИЧЬЯ⚔️")
else:
await callback.message.answer("ПОБЕДА ЗА ТОБОЙ✅")
@dp.callback_query_handler(lambda c: c.data == '2')
async def process_callback_yes(callback: types.CallbackQuery):
rand = random.choice(["Камень", "✂️Ножницы", "Бумага"])
await bot.delete_message(callback.message.chat.id, callback.message.message_id)
await callback.message.answer("Я выбрал " + rand + "\nА ты выбрал ✂️Ножницы")
if rand == 'Камень':
await callback.message.answer("☠️Я ПОБЕДИЛ☠️")
elif rand == '✂️Ножницы':
await callback.message.answer("⚔️НИЧЬЯ⚔️")
else:
await callback.message.answer("ПОБЕДА ЗА ТОБОЙ✅")
@dp.callback_query_handler(lambda c: c.data == '3')
async def process_callback_yes(callback: types.CallbackQuery):
rand = random.choice(["Камень", "✂️Ножницы", "Бумага"])
await bot.delete_message(callback.message.chat.id, callback.message.message_id)
await callback.message.answer("Я выбрал " + rand + "\nА ты выбрал Бумага")
if rand == 'Камень':
await callback.message.answer("ПОБЕДА ЗА ТОБОЙ✅")
elif rand == '✂️Ножницы':
await callback.message.answer("☠️Я ПОБЕДИЛ☠️")
else:
await callback.message.answer("⚔️НИЧЬЯ⚔️")
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question