Repository navigation
fix(role): answer when the customize command has no description - #3296
Merged
zhayujie merged 1 commit intoSep 29, 2026
Merged
Conversation
`$设定扮演` on its own reads the missing description straight from `clist[1]`, so the IndexError leaves `on_handle_context` untouched by `PluginManager.emit_event` and only reaches the worker's exception callback, which logs it. The user gets no reply, while the sibling commands answer the same mistake with their help text. The two `f` prefixes removed on the role-type branch are pre-existing F541 violations: the CI lint job runs ruff's F class over every Python file a PR changes, so they have to go for this file to pass the gate.
Owner
|
Merged, thanks! An empty description now gets the help text, not a silent IndexError. |
4 of 8 tasks
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 does this PR do?
$设定扮演sent without a role description reads that missing description straightfrom
clist[1](plugins/role/role.py:207). Nothing on the way out handles theIndexError:PluginManager.emit_eventcalls the handler directly(
plugins/plugin_manager.py:293),_generate_replydoesn't wrap it(
channel/chat_channel.py:223-229), and the callback for a failed worker only logs it(
channel/chat_channel.py:452-453). So the user's command gets no reply at all, whilethe two sibling commands answer this same mistake right away —
$角色with no namereturns the help text (
plugins/role/role.py:185-189) and$角色类型with no tag asksfor one (
plugins/role/role.py:156, answered at:173-174).The guard copies that existing behaviour instead of inventing new output: an empty
description is answered with the plugin's own help text before
clist[1]is touched.Two pre-existing F541 violations in the same file (
f"未知角色类型。\n",f"请输入角色类型。\n") lose theirfprefix here as well. The CI lint job runs ruff'sF class over every Python file a PR changes, so without that the run would fail on
lines this change has nothing to do with.
Fixes #3294
How was this tested?
tests/test_role_empty_customize_argument.py, 3 cases: the bare command nowreplies with the help text,
$设定扮演 一位海盗船长still sets the role, and the$角色guard being copied keeps its own reply so the two cannot drift apart.
ebf206bfworktree withIndexError: list index out of rangeatplugins/role/role.py:207(1 failed,2 passed); with the guard all 3 pass.
pytest tests/ -qgives 36 failed / 2231 passed / 37 skipped on thisbranch against 36 failed / 2228 passed / 37 skipped on plain
ebf206bf, and the twofailing sets are byte-for-byte identical (
diffof the sortedFAILEDlines isempty) — no new failure, the three extra passes are the new tests.
ruff check plugins/role/role.py tests/test_role_empty_customize_argument.py --select F --ignore F403,F405, passes.