【问题标题】:Forbidden: Bot was blocked by the user - laravel irazasyed/telegram-bot-sdk禁止:机器人被用户阻止 - laravel irazasyed/telegram-bot-sdk
【发布时间】:2020-11-11 13:11:27
【问题描述】:

最近我收到很多这样的异常:

[2020-07-21 00:00:51] local.ERROR: Forbidden: bot was blocked by the user {"exception":"[object] (Telegram\\Bot\\Exceptions\\TelegramResponseException(code: 403): Forbidden: bot was blocked by the user at /home/birjande/public_html/tel.birjandelectronic.shop/packages/irazasyed/telegram-bot-sdk/src/Exceptions/TelegramResponseException.php:58)

在我的情况下,当用户阻止机器人时,我的机器人在无限循环中失败并一次又一次地发送消息!

我得到的是这种或错误,Just times 10000!

事实上,如果我遇到错误,它会重复超过 1000 次!

我使用 laravel 6irazasyed/telegram-bot-sdk

【问题讨论】:

  • 您应该捕获所有可能的异常,以避免响应 Telegram 时出现不正常 (200) 的 http 状态代码。
  • 其实在找到你的问题的答案之前,你应该马上解决你网站的漏洞问题http://birjandelectronic.shop/。您的网络服务器配置不正确,目录列表未禁用,甚至您的机器人令牌也暴露了!

标签: laravel telegram telegram-bot laravel-6 telegram-api


【解决方案1】:

我像这样创建自己的 sendMessage

public function sendMessage($arr) {
     try {
         Telegram::sendMessage($arr);
     } catch (TelegramResponseException $e) {
         return "user has been blocked!";
     }
 }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-06
    • 1970-01-01
    • 2022-06-23
    • 1970-01-01
    • 2021-07-27
    • 1970-01-01
    • 2020-02-09
    • 2018-08-11
    相关资源
    最近更新 更多