PDA

Просмотр полной версии : отправка сообщений по нажатию кнопки | TeleBot


akitanoname
01.10.2023, 12:55
РЕЧЬ ИДЕТ ПРО TeleBot

как мне сделать так, что бы по нажатию кнопки которая создается







python:






types
.
KeyboardButton
(
)




, отправлялось сообщение не 1 раз, а постоянно при каждом нажатии​

Python_newbie
01.10.2023, 13:46
Python:






import
telebot
from
telebot
import
types

token
=
"token"
bot
=
telebot
.
TeleBot
(
token
)
@bot.message_handler
(
commands
=
[
'start'
]
)
def
start_message
(
message
)
:
markup
=
types
.
ReplyKeyboardMarkup
(
resize_keyboard
=
True
)
item1
=
types
.
KeyboardButton
(
"Кнопка"
)
markup
.
add
(
item1
)
bot
.
send_message
(
message
.
chat
.
id
,
"Старт"
,
reply_markup
=
markup
)
bot
.
infinity_polling
(
)