自动注册Telegram机器人指令 / Automatically register Telegram bot commands #14
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.
概述 / Overview
实现了Telegram适配器自动注册机器人指令的功能。当插件加载完成后,适配器会自动收集所有插件的命令并通过Telegram Bot API注册,使命令在Telegram客户端的命令菜单中可见。
This PR implements automatic registration of bot commands in the Telegram adapter. After plugins are loaded, the adapter automatically collects all commands from plugins and registers them with the Telegram Bot API, making commands visible in Telegram's command menu.
实现细节 / Implementation Details
核心变更 / Core Changes
在
TelegramAdapter.cs中添加了RegisterBotCommandsAsync方法,该方法:Events.OnInitialized事件在所有插件加载完成后触发Internal.Plugins获取所有已启用插件的命令_botClient.SetMyCommands()将命令注册到TelegramAdded
RegisterBotCommandsAsyncmethod toTelegramAdapter.csthat:Events.OnInitializedafter all plugins are loadedInternal.Pluginsto get commands from all enabled plugins_botClient.SetMyCommands()to register commands with Telegram命令验证规则 / Command Validation Rules
示例 / Example
这些命令会自动注册到Telegram,用户可以在聊天输入框中看到命令提示。
These commands will be automatically registered with Telegram, and users will see command suggestions in the chat input field.
影响范围 / Impact
测试 / Testing
由于需要真实的Telegram Bot Token,自动化测试受限。建议手动测试:
/查看命令列表Automated testing is limited due to the need for a real Telegram Bot Token. Manual testing recommended:
/in Telegram client to view command list文档更新 / Documentation
更新了
README.md文档,说明了自动命令注册功能和相关限制。Updated
README.mdwith details about automatic command registration feature and limitations.Fixes #[issue_number]
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.