云功能ID未响应Telegram webhook



我正在尝试编写我的第一个电报机器人。我决定使用谷歌云函数来执行机器人逻辑。我使用的代码是

const bot = new Telegraf(config().bot.token)
bot.start(ctx => ctx.reply('Welcome'))
bot.hears('hi', ctx => ctx.reply('Hey there'))
bot.telegram.setWebhook(
`https://us-central1-some-project.cloudfunctions.net/${process.env.FUNCTION_TARGET}`,
);
exports.bot = https.onRequest((req, res) => {
bot.handleUpdate(req.body, res);
})

问题是,在一段时间的不活动后,机器人停止响应消息。重新部署功能后,它又开始工作了。我甚至不知道如何调试这个问题。

GCF超时,因为需要为不支持的消息定义回退,像这个

bot.on('message', ctx => ctx.reply('Not supported command'));

最新更新