S
S
Spoon in the brain2019-05-29 16:30:23
Python
Spoon in the brain, 2019-05-29 16:30:23

Sending messages on button click (telebot)?

Hello, I have a bot. I need it to send a specific message when the cellback button is clicked. Will there be examples?

@bot.message_handler(commands=['start'])
def any_msg(message):
    keyboard = types.InlineKeyboardMarkup()
    next = types.InlineKeyboardButton(text="Пройти регистрацию", callback_data="next")
    keyboard.add(next)
    bot.send_message(message.chat.id, "Ляляляляля...", reply_markup=keyboard)

@bot.callback_query_handler(func=lambda call: True)
def callback_inline(call):
  if call.data == "next":
    #?????????????????????

I note that the message argument cannot be passed to callback_inline, which is why it puzzled me (forgive the newbie for stupid questions).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sound901, 2019-05-29
@vessels

@bot.callback_query_handler(func=lambda call: True)
def ans(call):
    kb = types.InlineKeyboardMarkup()
    cid = call.message.chat.id
    mid = call.message.message_id
    if call.data == "next":
        bot.edit_message_text('answer', cid, mid, reply_markup=kb, parse_mode='Markdown')

D
Danil K., 2019-06-06
@Danya_Violet

if call.data == 'next':
        bot.send_message(call.message.chat.id, 'И что дальше?')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question