【发布时间】:2020-09-10 17:08:14
【问题描述】:
我会使用 telegraf 在电报频道上发送消息。我已邀请该机器人并让他成为管理员。
我已经用这段代码测试过:
bot.on('text', (ctx) => {
// Explicit usage
ctx.telegram.sendMessage(ctx.message.chat.id, `Hello ${ctx.state.role}`)
// Using context shortcut
// ctx.reply(`Hello ${ctx.state.role}`)
})
bot.launch();
但它只有在我私信时才会回复。 那么为什么它在频道上不起作用呢? 比我如何在没有命令的情况下在该频道中发送消息? (例如 with and 间隔?
我试试这个:
bot.use((ctx) => {
console.log(ctx.message)
})
当我在私人聊天中(与他)使用机器人时,它会返回所有消息数据。在我收到未定义的频道上
【问题讨论】:
标签: node.js telegram telegraf telegram-api