【问题标题】:Get Telegram Bot to Reply to Specific Message让 Telegram Bot 回复特定消息
【发布时间】:2020-10-04 04:25:47
【问题描述】:

我可以使用chat_id 向群组发送消息,并且效果很好,但不是我想要的。

我正在尝试让我的 TG 机器人回复群组中的特定消息。用户可以通过右键单击消息,单击回复和回复等方式对其他用户进行正常操作。发送此回复后,它会突出显示原始消息并显示对它的回复,如图所示。

我希望我的机器人在回复用户时执行此操作,但不知道如何或是否可能。我也没有使用python-telegram-bot。我正在执行自定义 JSON POST 请求。

【问题讨论】:

    标签: python-3.x telegram-bot


    【解决方案1】:

    使用sendMessage方法发送消息后,返回如下数据:

    https://api.telegram.org/bot<TOKEN>/sendMessage?chat_id=123456&text=SO Example
    
    {
        "ok": true,
        "result": {
            "message_id": 80,
            "from": {
                ...  
    

    您需要在某处保存message_id

    然后,使用sendMessage 中的reply_to_message_id 参数,您可以像这样回复该消息:

    https://api.telegram.org/bot<TOKEN>/sendMessage?chat_id=123456&text=Reply&reply_to_message_id=80
    

    【讨论】:

      猜你喜欢
      • 2017-08-07
      • 2017-11-28
      • 2017-07-04
      • 2021-12-18
      • 1970-01-01
      • 1970-01-01
      • 2018-06-01
      • 2018-10-05
      • 2018-12-28
      相关资源
      最近更新 更多