79247422

Date: 2024-12-03 11:43:17
Score: 1
Natty:
Report link

They say, func parameter for bot.callback_query_handler is a filter. So you can check, if your query fits this handler or should go to another. maybe, this will work:

def get_announcement(message): markup = types.InlineKeyboardMarkup(row_width=2) item1 = types.InlineKeyboardButton("📎 Attach photo", callback_data='announce_attach_photo') item2 = types.InlineKeyboardButton("➡️ Skip", callback_data='announce_skip') markup.add(item1, item2) bot.send_message(chat_id=message.chat.id, text="Do you want to attach a photo?", reply_markup=markup)

@bot.callback_query_handler(func=lambda call: call.data.startswith("announcement_")) def handle_announcement_callback(call): if call.data == "announce_attach_photo": ... elif data == "announce_skip": ...

def get_notification_preference(message, announcement, photo): markup = types.InlineKeyboardMarkup(row_width=2) item1 = types.InlineKeyboardButton("🔈 Sand with notification", callback_data="notification_on") item2 = types.InlineKeyboardButton("🔇 Send silently", callback_data="notification_off") markup.add(item1, item2) bot.send_message(chat_id=message.chat.id, text="How to send an announcement?", reply_markup=markup)

@bot.callback_query_handler(func=lambda call: call.data.startswith("notification_")) def handle_notification_callback(call): if call.data == "notification_on": ... elif call.data == "notification_off": ...

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Малика Бахтиарова