Repository navigation
fix(moderation): retry muting a new member when Telegram can't be reached - #26
Merged
Merged
Conversation
…ched A single failed TLS handshake to the Bot API (httpx.ConnectError) made restrict_chat_member fail. The new member was never muted, got no welcome or verification, and could post freely. The group saw one notice asking admins to check both the bot's rights and the network, which could not tell the two causes apart. Muting now goes through retry_telegram_send: network errors, timeouts and flood waits are retried up to 3 times. BadRequest and Forbidden are not. When muting still fails, the group notice names the actual cause: - missing rights: asks admins to give the bot the 「封禁用户」 right - still unreachable: says the member got in without verification Both notices mention the member with the neutral link instead of the raw ID. Other failures, such as an admin joining, stay silent as before. If the notice itself cannot be sent, it is logged and the remaining new members in the same join message are still handled.
Member
Author
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What happened
On 2026-11-10 a new member joined a group with verification on. The bot's
restrict_chat_membercall failed on a single TLS handshake to the Bot API (NetworkError: httpx.ConnectError, log refERR-203F9EE0). The notice that followed went through fine, so the network was back within a second.Because muting failed, the handler skipped the member entirely: no welcome, no verification, no timeout. They could post freely. The group saw "无法限制成员 …,请检查机器人的管理员权限与网络", which made it look like a permission problem.
What changed
retry_telegram_send: network errors, timeouts and flood waits are retried up to 3 times (0.5s, then 1s; a flood wait sleeps as long as Telegram asks).BadRequestandForbiddenare not retried.For the reviewer
concurrent_updatesis on (bounded), so other updates keep flowing, but each waiting join occupies a slot.can_restrict_members.check_bot_permissionsin the same file calls it 「限制成员」.Testing
uv run pytest -q tests/ -k "verify or moderation or telegram_utils": 72 passed, including 4 new tests: a single network blip retried and verification proceeds; a lasting failure retried 3 times then announced; missing rights announced after one attempt; an admin joining not announced.ruff checkpasses on the changed files. The full suite and the MySQL integration suite were not run.