【问题标题】:Telegram Bot can`t receive preCheckoutQuery updateTelegram Bot 无法接收 preCheckoutQuery 更新
【发布时间】:2020-07-16 11:20:00
【问题描述】:

将 sendInvoice 发送给用户(用户正确获取此付款表格)后,我的机器人没有收到 preCheckoutQuery 以确认付款。 我试图通过 webhook 从 Telegram Bot 接收更新(特别是 preCheckoutQuery),但在这里:

dev.botframework.com -> 我的机器人 -> 电报 -> 健康专栏 -> 问题 -> “向您的机器人发送此消息时出错:HTTP 状态代码 BadRequest”

另外,当我尝试在 dev.botframework.com 上为我自己的机器人设置 webhook 并检查 getWebhookInfo 时,我会得到这样的特定网址:

{"ok":true,"result":{"url":"https://telegram.botframework.com/api/telegram/XXX/XXX","has_custom_certificate":false,"pending_update_count":0,"max_connections":40}}

使用这个 webhook,我的机器人可以正确地与用户进行消息传递

一些信息如何正确接收 preCheckoutQuery?

附加信息:

/getWebhookInfo 有时会返回我 pending_update_count":1

库:Telegram.Bot (https://github.com/TelegramBots/telegram.bot)

我的机器人支持 TLS 1.2:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

我的控制器什么也没收到

[Route("api/[controller]")]
public class UpdateController : Controller
{
    private readonly IBotFrameworkHttpAdapter Adapter;
    private readonly IBot Bot;

    public UpdateController(IBotFrameworkHttpAdapter adapter, IBot bot)
    {
        Adapter = adapter;
        Bot = bot;
    }
    [HttpPost]
    public async Task<IActionResult> Post([FromBody]Update _update)
    { 
        ...
        await Consts.BotClient.SendTextMessageAsync(chatId, string.Format("Update received\nP: {0} M: {1} H: {2}", a.Path, a.Method, a.Host.Value));
        ...
    }
}

【问题讨论】:

标签: c# asp.net-core botframework payment telegram-webhook


【解决方案1】:

来自链接的 GitHub 问题:

我刚刚收到 Azure 机器人服务不支持 Telegram 支付系统的确认。如果您想访问所有 Telegram 事件,您必须自行将您的机器人连接到 Telegram。

这意味着如果你想让preCheckoutQuery 工作,你的机器人不能使用 ABS 端点。

【讨论】:

    猜你喜欢
    • 2017-06-03
    • 1970-01-01
    • 2020-05-22
    • 1970-01-01
    • 2020-08-11
    • 1970-01-01
    • 2016-11-02
    • 1970-01-01
    • 2020-12-08
    相关资源
    最近更新 更多