Skip to content

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