2

如果我的用户发送命令 /myid,我想制作一个可以回复/返回聊天 ID 的电报机器人。我应该怎么办?

提前致谢!

4

1 回答 1

1

创建一个命令处理程序,它从有效负载中获取 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))
于 2020-08-06T06:47:22.610 回答