[fix] 修复了使用最小pages示例时插件无法注册的bug - #9858
Open
xiewoc wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="docs/en/dev/star/guides/plugin-pages.md" line_range="44-49" />
<code_context>
+Plugin backend code should use `astrbot.api.web`. Avoid exposing raw FastAPI, Starlette, or Quart request objects as the public API for your plugin business logic.
+
+```python
+from astrbot.api.star import Context, Star, register
+from astrbot.api.web import error_response, json_response, request
+
+PLUGIN_NAME = "astrbot_plugin_page_demo"
+
+@register(f"{PLUGIN_NAME}", "Soulter", "a simple example pages plugin", "1.0.0", "repo url")
+class MyPlugin(Star):
+ def __init__(self, context: Context):
</code_context>
<issue_to_address>
**nitpick:** The example explicitly uses the deprecated `register` decorator even though `Star` subclasses are auto-registered by the current framework; importing the example emits a deprecation warning, and the example will break when the decorator is removed.
**Triggers:** Whenever a user copies and imports the minimal example.
**Suggested fix:** Remove the `register` import and decorator, or clearly label the decorator as required only for older AstrBot versions.
</issue_to_address>
### Comment 2
<location path="docs/en/dev/star/guides/plugin-pages.md" line_range="49" />
<code_context>
+
+PLUGIN_NAME = "astrbot_plugin_page_demo"
+
+@register(f"{PLUGIN_NAME}", "Soulter", "a simple example pages plugin", "1.0.0", "repo url")
+class MyPlugin(Star):
+ def __init__(self, context: Context):
</code_context>
<issue_to_address>
**issue:** The copied example records the literal string `repo url` as the plugin repository; when the plugin updater uses this metadata, it has no valid repository source and update operations fail.
**Triggers:** When a user copies the example unchanged and later attempts to update the plugin.
**Suggested fix:** Use a clearly valid placeholder URL format, or omit the optional repository argument and explain that users should replace it with their actual repository URL.
```suggestion
@register(f"{PLUGIN_NAME}", "Soulter", "a simple example pages plugin", "1.0.0", "https://github.com/your-user/your-repo")
```
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: docs/en/dev/star/guides/plugin-pages.md:49
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
Author
|
静待review |
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.
在使用最小pages实例时发现无对应插件页面,遂发
Modifications / 改动点
仅修改docs/zh&en/dev/star/guides/plugin-pages.md,添加了
@register(f"{PLUGIN_NAME}", "Soulter", "一个简单的 Pages 示例插件", "1.0.0", "repo url")修改了
-->
Screenshots or Test Results / 运行截图或测试结果
Checklist / 检查清单
😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
/ 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
/ 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。
🤓 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.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.toml文件相应位置。😮 My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Summary by Sourcery
修正文档中的最小 Pages 插件示例,使其能够正确注册并展示完整的插件定义。
Bug Fixes:
Documentation: