Reputation: 1559
Telegram bot performs some tasks with messages in channels. It should skip messages with inline buttons (for example, with voting buttons).
Is there a way to identify if the posted message contains the inline keyboard or not?
Message object seems not to contain anything like that. editReplyMarkup can only replace the keyboard...
To make it more clear.
Upvotes: 2
Views: 2146
Reputation: 960
How does bot handle a messages?
You must check type in Update
object.
upd:
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
from telegram.ext import Updater, CommandHandler, CallbackQueryHandler
def start(bot, update):
print(update)
keyboard = [[InlineKeyboardButton("one", callback_data='1'),
InlineKeyboardButton("two", callback_data='2')],
[InlineKeyboardButton("tree", callback_data='3')]]
reply_markup = InlineKeyboardMarkup(keyboard)
update.message.reply_text('Please choose:', reply_markup=reply_markup)
def button(bot, update):
print(update)
query = update.callback_query
bot.edit_message_text(text="Your choose: %s" % query.data,
chat_id=query.message.chat_id,
message_id=query.message.message_id)
up = Updater('***TOKEN***')
up.dispatcher.add_handler(CommandHandler('start', start))
up.dispatcher.add_handler(CallbackQueryHandler(button))
up.start_polling()
return diffrent
message:
{message: {message_id: 20, new_chat_members: [], new_chat_member: None, date: 0000000001, delete_chat_photo: False, from: {id: 000000005, username: username, first_name: name, language_code: en-US}, entities: [{offset: 0, length: 6, type: bot_command}], chat: {id: 000000005, username: username, first_name: name, type: private}, new_chat_photo: [], group_chat_created: False, photo: [], supergroup_chat_created: False, text: /start, channel_chat_created: False}, update_id: 000000051}
inline:
{callback_query: {chat_instance: -0000000000000000060, message: {message_id: 21, new_chat_members: [], new_chat_member: None, date: 1505211901, delete_chat_photo: False, from: {id: 000000005, username: botname, first_name: test}, entities: [], chat: {id: 000000005, username: username, first_name: name, type: private}, new_chat_photo: [], group_chat_created: False, photo: [], supergroup_chat_created: False, text: Please choose:, channel_chat_created: False}, data: 2, id: 0000000000000000094, from: {id: 000000005, username: username, first_name: name, language_code: en-US}}, update_id: 000000005}
Upvotes: 1