node.js - 如何使用 NodeJS 在 inlinekeyboard 中动态添加一行和两个按钮?
问题描述
我有一个名为“stateNames”的数组。我想在电报机器人的 inlineKeyboard 中显示数组中的元素。我想在一行中显示两个 stateNames 按钮。
但我不明白。我尝试了下面的代码,但它不起作用。
GitHub:https ://github.com/nilesh-kawar/Covid19-Stats-bot
请帮忙
bot.command('covid', (ctx) => {
getStates()
.then((stateNames) => {
ctx.telegram.sendMessage(ctx.chat.id,'Choose State',
{
reply_markup: {
inline_keyboard : stateNames.map((item, index) => ([
{
text: item,
callback_data: String(index),
},
{
text: item+1,
callback_data: String(index),
}
])),
}
})
})
})
解决方案
推荐阅读
- pattern-matching - 使用 python POO 进行图挖掘:创建图并测试匹配
- node.js - 在电子反应应用程序中导入 whatsapp-web.js nodejs 模块的问题
- windows - 我可以获得适用于 Windows 32 位的 MongoDB Shell 吗?
- linux - 未设置带有 PKG_CHECK_MODULES 的 Autoconf
_CFLAGS 和 _LIBS 变量 - regex - 正则表达式在 \n 和 \t 之间选择字符,中间有数字
- java - Android 导航组件 - 如果用户未登录,则导航到其他活动
- graphql - 在 Graphql (NestJs) 中扩展泛型类型
- javascript - 其他js文件上的异步函数总是返回未定义,但函数运行
- docker - 无法 cd 进入 Docker 卷中目录的软链接
- javascript - Heroku - 未找到