创建一个命令处理程序,它从有效负载中获取 chat_id,并将其作为响应发送回。
dp.add_handler(CommandHandler("myid", myid_command_handler))
def myid_command_handler(update, context):
"""Send back the chat_id"""
chat_id = update.message.chat.id
update.message.reply_text('Here it is: ' + str(chat_id))