Skip to content

Fix: Respect sleep_threshold=0 in invoke() to prevent unwanted Flood…#146

Open
b1rdfr0st wants to merge 1 commit intoMayuri-Chan:mainfrom
b1rdfr0st:main
Open

Fix: Respect sleep_threshold=0 in invoke() to prevent unwanted Flood…#146
b1rdfr0st wants to merge 1 commit intoMayuri-Chan:mainfrom
b1rdfr0st:main

Conversation

@b1rdfr0st
Copy link

…Wait sleep

This PR updates the invoke() method to correctly handle sleep_threshold=0.

Before:

Even when sleep_threshold=0, the client still waits for the full FloodWait duration.

After:

With this change:

  • If sleep_threshold == 0, it raises the FloodWait immediately (no sleep).
  • If sleep_threshold < 0, it always raises (never sleeps).
  • If sleep_threshold > 0, it only sleeps if amount <= sleep_threshold.

This makes sleep_threshold behave more as expected and allows advanced bot handling logic outside of Pyrogram.

Thanks!

…Wait sleep

This PR updates the `invoke()` method to correctly handle `sleep_threshold=0`.

### Before:
Even when `sleep_threshold=0`, the client still waits for the full FloodWait duration.

### After:
With this change:
- If `sleep_threshold == 0`, it raises the FloodWait immediately (no sleep).
- If `sleep_threshold < 0`, it always raises (never sleeps).
- If `sleep_threshold > 0`, it only sleeps if `amount <= sleep_threshold`.

This makes `sleep_threshold` behave more as expected and allows advanced bot handling logic outside of Pyrogram.

Thanks!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant