这是我的代码
bot.edit_message_text(chat_id = CHAT_ID, message_id = MESSAGE_ID, text = "message has been updated", reply_markup=inline_keyboard)
I think you can get it with:
lastMessageId = message[-1].message_id
lastChatId = message[-1].chat.id
I don´t know why you need it, but I send example for you to understand how use message id and user id.
You should create a keyboard:
keyboard = types.InlineKeyboardMarkup()
keyboard.add(types.InlineKeyboardButton('Yes', callback_data='yes'),
types.InlineKeyboardButton('No', callback_data='no'))
Create a command:
@bot.message_handler(commands=['like'])
def like(message):
cid = message.chat.id
bot.send_message(cid, "Do you like it?", reply_markup=keyboard)
Create Callback:
@bot.callback_query_handler(func=lambda call: call.data in ['yes', 'no'])
def callback_handler(call):
cid = call.message.chat.id
mid = call.message.message_id
answer = call.data
update_lang(cid, answer)
try:
bot.edit_message_text("You voted: " + answer, cid, mid, reply_markup=keyboard)
except:
pass
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.