Skip to content

Comments

Feat/telegram command alias register #5233#5234

Open
evpeople wants to merge 2 commits intoAstrBotDevs:masterfrom
evpeople:feat/telegram-command-alias-register
Open

Feat/telegram command alias register #5233#5234
evpeople wants to merge 2 commits intoAstrBotDevs:masterfrom
evpeople:feat/telegram-command-alias-register

Conversation

@evpeople
Copy link
Contributor

@evpeople evpeople commented Feb 19, 2026

fixes: #5233

添加了 #5233 对应的功能,注册 alias 到telegram

Modifications / 改动点

仅修改 tg_adapter.py
实现对alias的注册和重复检测

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

image

IMG_5001

image

Checklist / 检查清单

  • 😊 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。/ If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
  • 👀 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。/ My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
  • 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到了 requirements.txtpyproject.toml 文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
  • 😮 我的更改没有引入恶意代码。/ My changes do not introduce malicious code.

Summary by Sourcery

在注册 Telegram 命令别名为机器人命令时,并在命令收集过程中处理重复的命令名称。

新特性:

  • 在注册 Telegram 机器人命令时,将命令别名与主命令一起包含进去。

增强内容:

  • 在收集 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:

  • Include command aliases alongside primary commands when registering Telegram bot commands.

Enhancements:

  • Add duplicate command name detection and logging when collecting Telegram bot commands.

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.
@auto-assign auto-assign bot requested review from Fridemn and Soulter February 19, 2026 15:06
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Feb 19, 2026
@dosubot
Copy link

dosubot bot commented Feb 19, 2026

Related Documentation

Checked 1 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sourcery 对开源项目是免费的——如果你觉得我们的代码审查有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进代码审查。
Original comment in English

Hey - I've left some high level feedback:

  • 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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@dosubot dosubot bot added the area:platform The bug / feature is about IM platform adapter, such as QQ, Lark, Telegram, WebChat and so on. label Feb 19, 2026
@evpeople
Copy link
Contributor Author

这个日志的修改我想在整体的i18n完成后再做?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:platform The bug / feature is about IM platform adapter, such as QQ, Lark, Telegram, WebChat and so on. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] telegram 支持将命令的 alias 注册到命令中

1 participant