【问题标题】:How to handle new_chat_members when a user joined to telegram group with telegram bot?当用户使用电报机器人加入电报组时如何处理 new_chat_members?
【发布时间】:2019-09-12 11:05:09
【问题描述】:

我正在尝试使用我的电报机器人向加入群组的用户发送消息。我将机器人添加到组中,机器人是组中的管理员。我关闭了群组隐私。当用户加入群组时,我得到new_chat_member 的用户,但消息无限发送给用户。并且当成员加入组时的更新待定。

 if(isset($arrayMessage['message'])) {
    if (isset($arrayMessage['message']['new_chat_member'])) {
        $text= "hello!";
        $url= "https://api.telegram.org/bot".$token."/sendMessage?chat_id=".$chat_id."&text=".$text;
        file_get_contents($url);
    }

}

【问题讨论】:

    标签: laravel telegram-bot


    【解决方案1】:

    我假设您正在使用长轮询来回答这个问题。使用getUpdates 方法时,它会不断检索现有的未确认更新,直到您使用偏移参数确认它们为止。

    enter link description here

    如果您不确认更新,您将继续收到相同的更新,因此会收到无限消息。

    【讨论】:

      猜你喜欢
      • 2020-09-24
      • 1970-01-01
      • 2017-08-18
      • 2023-01-20
      • 2021-10-22
      • 2017-07-10
      • 1970-01-01
      • 1970-01-01
      • 2021-03-24
      相关资源
      最近更新 更多