@bot.message_handler(commands=['start'])
def get_filial(message: types.Message):
markup_inline_filial=types.InlineKeyboardMarkup()
item_shop1=types.InlineKeyboardButton(text='Shop1', callback_data='shop1')
item_shop2=types.InlineKeyboardButton(text='Shop2', callback_data='shop2')
markup_inline_filial.add(item_shop1,item_shop2)
@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="Choose one:",reply_markup=markup_inline_item)
@bot.message_handler()
def message_handler_shop1(message):
if message.text in ['1','2','3','4']:
send_docs_shop1(message)
else:
send_query_shop1(message)
def send_docs_shop1(message):
file_source=open(f"E:\shop1_{message.text}.csv")
bot.send_document(message.chat.id, file_source)
def send_query_shop1(message):
bot.send_document(message.chat.id, "Hello from shop1")
@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="Choose one:",reply_markup=markup_inline_item)
@bot.message_handler()
def message_handler_shop2(message):
if message.text =='d':
send_docs_shop2(message)
else:
send_query_shop2(message)
def send_docs_shop2(message):
file_source=open(f"E:\shop2_{message.text}.csv")
bot.send_document(message.chat.id, file_source)
def send_query_shop2(message):
bot.send_document(message.chat.id, "Hello from shop2")
Есть такой код, мне нужно, что бы когда выбираю "Shop1", выполнялась код для "shop1", когда выбираю "Shop2", выполнялась код для "shop2". Но сейчас независимо от выбора выполняется код "Shop1" и для "Shop1" и для "Shop2".