如何使用 telegraf
菜单按钮 在电报机器人中添加菜单按钮
how can I add Menu button in telegram bot using telegraf
menu button like this
您可以通过两种方式实现这一目标。通过
setMyCommands
/setCommands
You can achieve this in two ways. Either by
/setcommands
我通过添加一个新框架创建菜单按钮“ grammy ”
首先安装grammy: npm npm install grammy
npm npm install grammy
次
const { Bot } = require("grammy"); const bot = new Bot(BOT_TOKEN); // <-- place your bot token in this string
:
bot.api.setMyCommands([ { command: "start", description: "إبدأ من جديد" }, { command: "help", description: "طلب مساعدة " }, { command: "list", description: "القائمة " }, ]);
I create a menu button by add a new framework " Grammy "
first install grammy : npm install grammy
npm install grammy
seconde add this code :
create list of commands :
如果您在这里打开该按钮的Mini-App, /setCommands是错误的方法。
这是您可以从电报启动应用程序的方式
/mybots select your bot Bot Settings Menu Button
,然后添加您的URL和按钮的titter
If you're here to open your mini-app from that button, /setcommands is the wrong way to achieve that.
Here is how you can launch apps from telegram both
Then add your url and tittle of your button
为简单起见,您可以使用Botfather并将其直接从那里设置。
For simplicity, you can use BotFather and set it directly from there.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(4)
您可以通过两种方式实现这一目标。通过
setMyCommands
方法,或/setCommands
命令。You can achieve this in two ways. Either by
setMyCommands
method, or/setcommands
command.我通过添加一个新框架创建菜单按钮“ grammy ”
首先安装grammy:
npm npm install grammy
次
:
I create a menu button by add a new framework " Grammy "
first install grammy :
npm install grammy
seconde add this code :
create list of commands :
如果您在这里打开该按钮的Mini-App, /setCommands是错误的方法。
这是您可以从电报启动应用程序的方式
,然后添加您的URL和按钮的titter
If you're here to open your mini-app from that button, /setcommands is the wrong way to achieve that.
Here is how you can launch apps from telegram both
Then add your url and tittle of your button
为简单起见,您可以使用Botfather并将其直接从那里设置。
/setCommands
For simplicity, you can use BotFather and set it directly from there.
/setcommands