【问题标题】:Telegraf and ngrokTelegraf 和 ngrok
【发布时间】: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
          }
        })

我有一个像这样的网址:http://6f2b-88-149-195-143.ngrok.io/api/v1/telegram-callback/d8472bbde1d80d53614d6473524320e98f8c19a73facbcf709193bb8049df84e

在我的控制器中,我可以检索此 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


    【解决方案1】:

    有同样的问题。你解决了吗?

    【讨论】:

      猜你喜欢
      • 2021-08-20
      • 2017-09-15
      • 2019-01-30
      • 2021-12-07
      • 1970-01-01
      • 2018-11-02
      • 2014-07-02
      • 2017-01-10
      • 1970-01-01
      相关资源
      最近更新 更多