Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
call query telebot
#1
There are 3 functions:

send_docs_shop1()
send_docs_shop2()
send_docs_shop3()

How to call them depending on callback_query. For example if callback_query=='shop1, call send_docs_shop1() or callback_query=='shop2 call send_docs_shop2() and so on.

Now I do this:
@bot.callback_query_handler(func=lambda call:call.data=='shop1')
def get_select_button_shop1(call: types.CallbackQuery):
markup_inline_item=types.InlineKeyboardMarkup()
markup_inline_item.add()
bot.edit_message_text(chat_id=call.message.chat.id,message_id=call.message.id,text='welcome to shop1:',reply_markup=markup_inline_item)
 
@bot.message_handler()
def message_handler(message: types.Message):
if message.text in shop1:
    shop1.send_docs_shop1(message)
else:
    shop1.send_query_shop1(message)
 
@bot.callback_query_handler(func=lambda call:call.data=='shop2')
def get_select_button_shop2(call: types.CallbackQuery):
markup_inline_item=types.InlineKeyboardMarkup()
markup_inline_item.add()
bot.edit_message_text(chat_id=call.message.chat.id,message_id=call.message.id,text='welcome to shop2:',reply_markup=markup_inline_item)
 
@bot.message_handler()
def message_handler(message: types.Message):
if message.text in shop2:
    shop2.send_docs_shop2(message)
else:
    shop2.send_query_shop2(message)
 
 @bot.callback_query_handler(func=lambda call:call.data=='shop3')
def get_select_button_shop3(call: types.CallbackQuery):
markup_inline_item=types.InlineKeyboardMarkup()
markup_inline_item.add()
bot.edit_message_text(chat_id=call.message.chat.id,message_id=call.message.id,text='welcome to shop3:',reply_markup=markup_inline_item)
 
@bot.message_handler()
def message_handler(message: types.Message):
if message.text in shop3:
    shop3.send_docs_shop3(message)
else:
    shop3.send_query_shop3(message)
But now, regardless of the callback, only shop1 is called. Please help with the question, I have been suffering for 3 days already, I tried different options, but the result is 0.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020