且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在电报机器人中显示选项?

更新时间:2023-11-19 12:34:34

为此,您必须与 BotFather 交谈.

For that, you have to talk to BotFather.

  1. 在 Telegram 应用中,打开与 BotFather 的聊天.

  1. In the Telegram App, open the chat with BotFather.

给他发送/setcommands.他会向您展示您的机器人列表.

Send him /setcommands. He will present you with a list of your bots.

选择要为其设置命令菜单的机器人.

Pick the bot for which you want to set the command menu.

编写并发送命令列表.以您的图片为例,这 4 行应该可以:

Compose and send the command list. Using your image as an example, these 4 lines should do:

开始 - 描述 1
菜单 - 说明 2
帮助 - 说明 3
停止 - 描述 4

start - Description 1
menu - Description 2
help - Description 3
stop - Description 4

注意每行的命令部分(- 符号的左侧)必须只有小写字符,并且没有斜线.- 符号周围也应该有空格.

Note that command part of each line(left side of - signs) must have just lowercase characters, and no slashes. There should also be spaces around the - sign.

完成此过程后,退出并终止 Telegram 应用程序.重新打开它,转到与目标机器人的聊天,输入 /(或文本字段旁边的 / 按钮上的选项卡),命令菜单应该出现

Once you complete this process, exit and kill the Telegram App. Re-open it, go to the chat with your target bot, type a / (or tab on the / button next to the text field), the command menu should come up.