Показать сообщение отдельно

  #2  
Старый 09.01.2024, 08:02
Dickson
Участник форума
Регистрация: 31.12.2022
Сообщений: 201
С нами: 1774087

Репутация: 33
По умолчанию

удали свой код

Цитата:
Сообщение от Спойлер  


test.py:





Код:
import
telebot
from
telebot
import
types
import
random

bot_token
=
'token'
bot
=
telebot
.
TeleBot
(
bot_token
)
@bot.message_handler
(
commands
=
[
'start'
]
)
def
start
(
message
)
:
markup
=
types
.
InlineKeyboardMarkup
(
)
rock_button
=
types
.
InlineKeyboardButton
(
"🪨"
,
callback_data
=
'rock'
)
scissors_button
=
types
.
InlineKeyboardButton
(
"✂️"
,
callback_data
=
'scissors'
)
paper_button
=
types
.
InlineKeyboardButton
(
"📄"
,
callback_data
=
'paper'
)
markup
.
add
(
rock_button
,
scissors_button
,
paper_button
)
bot
.
send_message
(
message
.
chat
.
id
,
"Выберите свой вариант:"
,
reply_markup
=
markup
)
@bot.callback_query_handler
(
func
=
lambda
call
:
True
)
def
handle_callback
(
call
)
:
user_choice
=
call
.
data
    bot_choice
=
random
.
choice
(
[
'rock'
,
'scissors'
,
'paper'
]
)
result
=
determine_winner
(
user_choice
,
bot_choice
)
bot
.
send_message
(
call
.
message
.
chat
.
id
,
f"Вы выбрали:{get_emoji(user_choice)}\nБот выбрал:{get_emoji(bot_choice)}\n\n{result}\n\nПопробуйте снова!"
)
markup
=
types
.
InlineKeyboardMarkup
(
)
rock_button
=
types
.
InlineKeyboardButton
(
"🪨"
,
callback_data
=
'rock'
)
scissors_button
=
types
.
InlineKeyboardButton
(
"✂️"
,
callback_data
=
'scissors'
)
paper_button
=
types
.
InlineKeyboardButton
(
"📄"
,
callback_data
=
'paper'
)
markup
.
add
(
rock_button
,
scissors_button
,
paper_button
)
bot
.
send_message
(
call
.
message
.
chat
.
id
,
"Выберите свой вариант:"
,
reply_markup
=
markup
)
def
determine_winner
(
user_choice
,
bot_choice
)
:
if
user_choice
==
bot_choice
:
return
"Ничья!"
elif
(
user_choice
==
'rock'
and
bot_choice
==
'scissors'
)
or
(
user_choice
==
'scissors'
and
bot_choice
==
'paper'
)
or
(
user_choice
==
'paper'
and
bot_choice
==
'rock'
)
:
return
"Вы победили!"
else
:
return
"Вы проиграли!"
def
get_emoji
(
choice
)
:
if
choice
==
'rock'
:
return
"🪨"
elif
choice
==
'scissors'
:
return
"✂️"
elif
choice
==
'paper'
:
return
"📄"
bot
.
polling
(
)


 
Ответить с цитированием