Skip to content

[fix] 修复了使用最小pages示例时插件无法注册的bug - #9858

Open
xiewoc wants to merge 4 commits into
AstrBotDevs:masterfrom
xiewoc:master
Open

[fix] 修复了使用最小pages示例时插件无法注册的bug#9858
xiewoc wants to merge 4 commits into
AstrBotDevs:masterfrom
xiewoc:master

Conversation

@xiewoc

@xiewoc xiewoc commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

在使用最小pages实例时发现无对应插件页面,遂发

Modifications / 改动点

仅修改docs/zh&en/dev/star/guides/plugin-pages.md,添加了

@register(f"{PLUGIN_NAME}", "Soulter", "一个简单的 Pages 示例插件", "1.0.0", "repo url")

修改了

from astrbot.api.star import Context, Star

-->

from astrbot.api.star import Context, Star, register
  • This is NOT a breaking change. / 这不是一个破坏性变更。

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

image

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.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

Summary by Sourcery

修正文档中的最小 Pages 插件示例,使其能够正确注册并展示完整的插件定义。

Bug Fixes:

  • 修复英文和中文插件 Pages 文档最小示例缺少插件注册信息,导致示例插件无法正常注册的问题。

Documentation:

  • 更新中英文插件 Pages 最小完整示例,补充插件注册装饰器及相关导入。

@dosubot dosubot Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Aug 28, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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


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.

Comment thread docs/en/dev/star/guides/plugin-pages.md
Comment thread docs/en/dev/star/guides/plugin-pages.md
@xiewoc

xiewoc commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

静待review

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

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant