Feat/telegram command alias register #5233#5234
Open
evpeople wants to merge 2 commits intoAstrBotDevs:masterfrom
Open
Feat/telegram command alias register #5233#5234evpeople wants to merge 2 commits intoAstrBotDevs:masterfrom
evpeople wants to merge 2 commits intoAstrBotDevs:masterfrom
Conversation
Now when registering commands with aliases, all aliases will be
registered as Telegram bot commands in addition to the main command.
Example:
@register_command(command_name="draw", alias={"画", "gen"})
Now /draw, /画, and /gen will all appear in the Telegram command menu.
…ommands Log a warning when duplicate command names are detected during Telegram command registration to help identify configuration conflicts.
Contributor
There was a problem hiding this comment.
Hey - 我在这里给出了一些总体反馈:
- 在
_extract_command_info中,建议在迭代之前对cmd_names去重(例如通过dict.fromkeys,或在保持顺序的前提下使用set),以避免在别名不小心与主命令或彼此重复时造成重复的校验和日志记录。 - 新增的关于重复注册的日志消息是中文,而更新后的描述是英文(
Command group:、Command:);为了与tg_adapter.py其余部分保持一致,可能值得在这里统一一下语言风格。
给 AI Agent 的提示
Please address the comments from this code review:
## Overall Comments
- In `_extract_command_info`, consider deduplicating `cmd_names` (e.g., via `dict.fromkeys` or a `set` while preserving order) before iterating to avoid redundant validation and log entries when aliases accidentally repeat the main command or each other.
- The new log message for duplicate registrations is in Chinese while the updated descriptions use English (`Command group:`, `Command:`); it may be worth aligning the language style here with the rest of `tg_adapter.py` for consistency.帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进代码审查。
Original comment in English
Hey - I've left some high level feedback:
- In
_extract_command_info, consider deduplicatingcmd_names(e.g., viadict.fromkeysor asetwhile preserving order) before iterating to avoid redundant validation and log entries when aliases accidentally repeat the main command or each other. - The new log message for duplicate registrations is in Chinese while the updated descriptions use English (
Command group:,Command:); it may be worth aligning the language style here with the rest oftg_adapter.pyfor consistency.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `_extract_command_info`, consider deduplicating `cmd_names` (e.g., via `dict.fromkeys` or a `set` while preserving order) before iterating to avoid redundant validation and log entries when aliases accidentally repeat the main command or each other.
- The new log message for duplicate registrations is in Chinese while the updated descriptions use English (`Command group:`, `Command:`); it may be worth aligning the language style here with the rest of `tg_adapter.py` for consistency.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
Author
|
这个日志的修改我想在整体的i18n完成后再做? |
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.
fixes: #5233
添加了 #5233 对应的功能,注册 alias 到telegram
Modifications / 改动点
仅修改 tg_adapter.py
实现对alias的注册和重复检测
Screenshots or Test Results / 运行截图或测试结果
Checklist / 检查清单
requirements.txt和pyproject.toml文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations inrequirements.txtandpyproject.toml.Summary by Sourcery
在注册 Telegram 命令别名为机器人命令时,并在命令收集过程中处理重复的命令名称。
新特性:
增强内容:
Original summary in English
Summary by Sourcery
Register Telegram command aliases as bot commands and handle duplicate command names during command collection.
New Features:
Enhancements: