Telegraf.js的Telegram Bot-如何始终如一地收集数据



我的向导场景只有在我对bot.on('text'(处理程序发表评论后才能工作

bot.on('text', async (ctx) => {
try {
switch (ctx.message.text) {//my code}
} catch (e) {
console.error(e)
}
})

我的向导场景处理程序

stepHandler.on('text', async (ctx) => {
await ctx.reply('Step 2. Via command')
return ctx.wizard.next()
})

请建议如何解决此问题

我认为您需要从用户那里收集数据,您只需在然后你的代码简单地将数据分解为你想要的

例如:

bot.start(async (ctx) => {
console.log(ctx.message.chat);
ctx.telegram.sendMessage(ctx.chat.id, `hello ${ctx.chat.username} `);
})

最新更新