简体   繁体   English

Telegram Bot 无法接收 preCheckoutQuery 更新

[英]Telegram Bot can`t receive preCheckoutQuery update

After sending sendInvoice to user(user get this pay form correctly) my bot is not receive preCheckoutQuery for payment confirmation.将 sendInvoice 发送给用户(用户正确获取此付款表格)后,我的机器人未收到 preCheckoutQuery 以确认付款。 Im trying to receiving Updates (specifically preCheckoutQuery) from Telegram Bot via webhook, but here:我试图通过 webhook 从 Telegram Bot 接收更新(特别是 preCheckoutQuery),但在这里:

dev.botframework.com -> My bots -> Telegram -> Health column -> Issue -> "There was an error sending this message to your bot: HTTP status code BadRequest" . dev.botframework.com -> 我的机器人 -> 电报 -> 健康栏 -> 问题 -> “向您的机器人发送此消息时出错:Z293C9EA246FF9985DC6F62A650F7898Z 代码状态错误”

Also, when i trying to set webhook on dev.botframework.com for my own bot and checking getWebhookInfo i get specific url like this:此外,当我尝试在 dev.botframework.com 上为我自己的机器人设置 webhook 并检查 getWebhookInfo 时,我得到了特定的 url,如下所示:

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

With this webhook my bot messaging with user correctly使用这个 webhook,我的机器人可以正确地与用户进行消息传递

Some info how to receive correctly preCheckoutQuery?一些信息如何正确接收 preCheckoutQuery?

Additional info:附加信息:

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

Library: Telegram.Bot ( https://github.com/TelegramBots/telegram.bot )图书馆:Telegram.Bot( https://github.com/TelegramBots/telegram.bot

My bot support TLS 1.2:我的机器人支持 TLS 1.2:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

My controller receving nothing我的 controller 什么也没收到

[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));
        ...
    }
}

From the linked GitHub issue:从链接的 GitHub 问题:

I've just received confirmation that the Azure Bot Service does not support the Telegram payment system.我刚刚收到确认 Azure 机器人服务不支持电报支付系统。 If you want access to all Telegram events, you'll have to connect your bot to Telegram on your own.如果您想访问所有 Telegram 事件,您必须自己将您的机器人连接到 Telegram。

This means your bot cannot use ABS endpoints if you want preCheckoutQuery to work.这意味着如果您希望preCheckoutQuery工作,您的机器人不能使用 ABS 端点。

To get "preCheckoutQuery" I did the following:为了获得“preCheckoutQuery”,我做了以下事情:

  • added api controller "telegramwebhook" to the bot将 api controller "telegramwebhook" 添加到机器人
  • changed the webhook of the bot to the previously created api controller将机器人的 webhook 更改为之前创建的 api controller
  • after processing the "preCheckoutQuery" message, redirected the received request to the Azure web hook "https://telegram.botframework.com/api/telegram/XXX/XXX"处理完“preCheckoutQuery”消息后,将收到的请求重定向到Azure web hook“https://telegram.botframework.com/api/”

It turns out something like "web hook proxy"原来是“网络钩子代理”之类的东西

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM