【发布时间】:2022-10-21 05:26:55
【问题描述】:
我正在使用 ngrok 和 telegraf 和 nestjs
我正在运行一个 ngrok 以将其与 webwook 一起使用。 我的配置是:
this.telegramService.getBot().launch({
webhook: {
domain: this.configService.get('app.nodeEnv') !== 'production' ? this.configService.get('telegramConfig.webwookUrl') : request.checkChannel.webwook,
port: 8443,
hookPath: '/api/v1/telegram-callback/'+ secretPathComponent
}
})
在我的控制器中,我可以检索此 POST 调用
@Post('/:gatewayId')
@HttpCode(HttpStatus.OK)
async createButton(
@Param('gatewayId') gatewayId: string,
@Request() req
){
await this.telegramService.activateCallback(req.body.callback_query);
return "ok"
}
在我的服务中,我有这样的东西
async activateCallback(callbackObj: any) {
console.log(await this.bot.telegram.getWebhookInfo())
console.log("---")
console.log(callbackObj)
console.log("---")
//const channel = await this.gatewayModel.findOne({ channelId: callbackObj.message.sender_chat.id, 'kind': 'Telegram' }) as Telegram
try {
await this.bot.action('foo', (ctx) => {
// reply in chat
return ctx.reply('foo')
//post on top
return ctx.answerCbQuery('Lorem', { show_alert: true });
});
}catch(e){
console.log(e)
}
}
我发送带有按钮和回调的消息,其中 callback_data 是 foo,但是当我单击它时,我没有收到任何反馈
我可以在调试期间阅读它:
last_error_message: 'Wrong response from the webhook: 503 Service Unavailable',
max_connections: 40,
我的 ngrok 工作,我可以用 cUrl 到达它。
使用轮询,我的 callback_data 有效
【问题讨论】:
标签: node.js typescript telegram telegraf