Feature: 支持自定义快捷指令#13
Conversation
Original review guide in EnglishReviewer's GuideThis pull request introduces support for user-defined command shortcuts by leveraging Alconna's namespace and command manager features. Shortcuts are now persisted to a cache file on shutdown and loaded on startup. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @FrostN0v0 - 我已经查看了你的更改 - 这里有一些反馈:
- 考虑运行代码格式化程序以确保一致的样式,尤其是在函数调用和定义中的换行符方面。
以下是我在审查期间查看的内容
- 🟡 General issues: 发现 2 个问题
- 🟢 Security: 一切看起来都很好
- 🟢 Testing: 一切看起来都很好
- 🟢 Complexity: 一切看起来都很好
- 🟢 Documentation: 一切看起来都很好
帮助我更有用!请点击每个评论上的 👍 或 👎,我将使用反馈来改进你的评论。
Original comment in English
Hey @FrostN0v0 - I've reviewed your changes - here's some feedback:
- Consider running a code formatter to ensure consistent styling, particularly regarding line breaks in function calls and definitions.
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| command_manager.load_cache(shortcut_cache) | ||
| logger.debug("Skland shortcuts cache loaded") |
There was a problem hiding this comment.
suggestion (bug_risk): Cache operations on startup are clear.
将启动时的缓存加载和转储操作包装在 try/except 块中,以捕获启动或关闭期间的 IO 错误。
Suggested implementation:
@driver.on_startup
async def startup():
try:
command_manager.load_cache(shortcut_cache)
logger.debug("Skland shortcuts cache loaded")
except Exception as e:
logger.error("Failed to load shortcut cache on startup", exc_info=e)
if config.check_res_update:
try:
if version := await GameResourceDownloader.check_update():
for route in RESOURCE_ROUTES:
logger.info(f"正在下载: {route}")
await GameResourceDownloader.download_all(
owner="yuanyan3060",
repo="ArknightsGameResource",
route=route,
branch="main",
)
except Exception as e:
logger.error("Error during resource update", exc_info=e)If there is a cache dump operation in your shutdown function (for example, within a @driver.on_shutdown decorated function), Wrap that operation in a similar try/except block to catch and log any IO errors during shutdown.
Original comment in English
suggestion (bug_risk): Cache operations on startup are clear.
Wrap cache load and dump in a try/except to catch IO errors during startup or shutdown.
Suggested implementation:
@driver.on_startup
async def startup():
try:
command_manager.load_cache(shortcut_cache)
logger.debug("Skland shortcuts cache loaded")
except Exception as e:
logger.error("Failed to load shortcut cache on startup", exc_info=e)
if config.check_res_update:
try:
if version := await GameResourceDownloader.check_update():
for route in RESOURCE_ROUTES:
logger.info(f"正在下载: {route}")
await GameResourceDownloader.download_all(
owner="yuanyan3060",
repo="ArknightsGameResource",
route=route,
branch="main",
)
except Exception as e:
logger.error("Error during resource update", exc_info=e)If there is a cache dump operation in your shutdown function (for example, within a @driver.on_shutdown decorated function), Wrap that operation in a similar try/except block to catch and log any IO errors during shutdown.
|
|
||
| #### 🪄 自定义快捷指令 | ||
|
|
||
| > 该特性依赖于 [Alconna 快捷指令](https://nonebot.dev/docs/best-practice/alconna/command#command%E7%9A%84%E4%BD%BF%E7%94%A8)。自定义指令不带 `COMMAND_START`,若有必要需手动填写 |
There was a problem hiding this comment.
suggestion: 澄清关于自定义命令的 COMMAND_START 的说明。
“自定义指令不带 COMMAND_START” 一句不太清晰,因为示例别名 /兔兔签到 已包含 /。请说明“自定义指令”指的是快捷别名还是目标命令字符串,并举例说明何时需手动添加 COMMAND_START。
Original comment in English
suggestion: Clarify the note about COMMAND_START for custom commands.
“自定义指令不带 COMMAND_START” 一句不太清晰,因为示例别名 /兔兔签到 已包含 /。请说明“自定义指令”指的是快捷别名还是目标命令字符串,并举例说明何时需手动添加 COMMAND_START。
|
需 ArcletProject/Alconna#97 发版才支持指令缓存。 |
好的,这是翻译成中文的 pull request 总结:
Sourcery 总结
为 NoneBot 的 Skland 插件添加自定义快捷方式支持
新特性:
增强功能:
文档:
Original summary in English
Summary by Sourcery
Add support for custom shortcuts in the Skland plugin for NoneBot
New Features:
Enhancements:
Documentation: