Telegram API 抛出 PeerFloodError:请求过多

Jas*_*ngh 4 python-3.x telegram python-telegram-bot telegram-bot telethon

我没有使用机器人 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)
Run Code Online (Sandbox Code Playgroud)

tas*_*ori 5

most of the Telegram APIs have strict limits for each of 30-seconds, 30-minutes, 24-hours periods. spread 19(or less API calls in 30 minutes and catch whether it throws an error or not, if it's doing fine after 30minutes: Great! otherwise, do this process for 24 hours.)

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

  • 非常感谢。它解决了我的问题。我只是将睡眠时间从 8 增加到 120(两分钟),以在 38 分钟内传播 19 个请求,它的效果非常好。 (2认同)