【问题标题】:Telegram API throwing PeerFloodError: Too many requestsTelegram API 抛出 PeerFloodError:请求过多
【发布时间】:2019-03-12 11:57:08
【问题描述】:

我没有使用机器人 API。我正在使用 Telegram API 发送消息。消息很容易发送,但问题发生在 19 个用户之后。在第 20 个用户,我收到 PeerFloodError。即使经过大量搜索,我也没有找到任何具体的限制,并且使用 sleep 也不起作用。请提出解决此问题的方法。

代码

def send_message(root2, client):
    totalcount = 0
    for user in users:
        if totalcount >= len(users):
            root2.destroy()
            break

        if totalcount % 15 == 0 and totalcount != 0:
            print("Waiting for one minute...")
            time.sleep(60)

        if user not in users2 or user not in users3:
            totalcount += 1
            entity = client.get_entity(user)

            client.send_message(entity, message_str)
            time.sleep(8)

【问题讨论】:

    标签: python-3.x telegram telegram-bot python-telegram-bot telethon


    【解决方案1】:

    大多数 Telegram API 对 30 秒、30 分钟、24 小时的周期都有严格的限制。传播 19 次(或在 30 分钟内调用更少的 API 并捕获它是否抛出错误,如果 30 分钟后运行良好:太好了!否则,执行此过程 24 小时。)

    请注意,要大量使用 Telegram API,您可能需要在项目中使用多个帐户。

    【讨论】:

    • 非常感谢。它解决了我的问题。我只是将睡眠时间从 8 增加到 120(两分钟),以便在 38 分钟内分发 19 个请求,它就像一个魅力。
    猜你喜欢
    • 2021-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-28
    • 1970-01-01
    • 2015-09-20
    • 2017-02-10
    • 2023-03-10
    相关资源
    最近更新 更多