Repository navigation
Fix: DM flow swallowing /status (and other commands) - #47
Merged
Merged
Conversation
/status (DM-only admin): render the operational summary as a native rich message — per-group <table bordered striped> (Grup | Penegakan | Captcha | Probation | Pending | Nonaktif, scoped to the caller's admin groups) plus a key-value section (Uptime, Database, Refresh admin, Auto-restrict). Any send_rich_message failure falls back to the byte-identical Markdown message (verified empirically against the pre-change output). /trusted: drop the standalone User ID column — four columns forced horizontal scrolling. The numeric ID is folded into the User cell as name (@username)<br><code>id</code>, keeping it visible and copyable. Markdown fallback untouched. Dates: the /trusted Date column and the /status job timestamps now render in WIB (Asia/Jakarta) instead of UTC, in both the rich output and the Markdown fallback (shared display strings; new constants.WIB single source of truth). /check deliberately stays on Markdown: aiogram 3.31 has no edit-to-rich equivalent, so its callback-query edit path could never go rich and a rich-then-Markdown flip mid-flow would be worse than consistent Markdown.
…operty
test_with_username_format asserts '(@' appears only via the username
suffix, but the name strategy allows punctuation, so Hypothesis can
generate name='(@' and fail the property through no fault of the code.
assume('(@' not in name) keeps the property's intent (username suffix
logic) while excluding the degenerate input. Pre-existing flake,
unrelated to the rich-text work.
The dm plugin registers before status in group 0, and its check (private + text) matched /status DMs first, so handle_dm answered with the unrestriction message and handle_status never ran (first-match-wins). The DM flow now owns free-text DMs and /start deep links only: its check excludes any bot_command that isn't /start. /status (and any future command registered after dm) falls through to its handler.
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.
Problem
Sending
/statusin DM answered with the unrestriction-flow message ("Kamu tidak memiliki pembatasan dari bot ini…") instead of the status report.Root cause
Both
dmandstatuslive in dispatch group 0, anddmregisters first inMANIFEST_ORDER. Its check (is_private_chat and has_text) matched the/statusDM before the status spec was ever evaluated — first-match-wins meanthandle_dmran andhandle_statusnever did./statuswas the only command affected (every other command plugin registers beforedm).Fix
The DM flow's check now excludes bot commands other than
/start:/startand/start <deep-link payload>→ DM flow (unchanged; deep-link recovery depends on it)/status,/trusted, and any other command → falls through to its own handlerThis is order-independent, so future command plugins registered after
dmwon't hit the same trap.Verification
TestDmCommandCarveOut(5 tests) intests/test_dispatch.py:/statusand/trustedDMs reach their handlers,/start(plain + deep-link) and free text still reach the DM flow.uv run pytest: 1284 passed;ruff check .clean;mypy src/bot/ tests/clean.