Answer the question
In order to leave comments, you need to log in
How to call a function and pass chat id to it after clicking on InlineKeyboardButton?
There is a code:
def listener(messages):
for message in messages:
if message.content_type == 'text':
print(str(message.chat.first_name) +
" [" + str(message.chat.id) + "]: " + message.text)
bot = TeleBot(TOKEN)
bot.set_update_listener(listener)
@bot.message_handler(commands=['hot_news'])
def send_hot_news(message):
chat_id = message.chat.id
for i in range(1):
keyboard = types.InlineKeyboardMarkup()
button = types.InlineKeyboardButton(
'Получить полный текст статьи', callback_data='get_full_text')
keyboard.add(button)
txt = open('text.txt', 'rb').read()
bot.send_message(
chat_id, txt, parse_mode='HTML', reply_markup=keyboard)
@bot.callback_query_handler(func=lambda call: True)
def callbacks(call):
if call.data == "get_full_text":
# тут мне хотелось бы вызвать функцию отправик полного текста статьи
# отдельным сообщением
bot.send_message(
chat_id, 'это не работает потому что функция не принимает chat id')
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