Skip to content

fix(docs): fix multiple errors in plugin development guides#8166

Merged
Soulter merged 9 commits into
AstrBotDevs:masterfrom
lingyun14beta:docs
May 12, 2026
Merged

fix(docs): fix multiple errors in plugin development guides#8166
Soulter merged 9 commits into
AstrBotDevs:masterfrom
lingyun14beta:docs

Conversation

@lingyun14beta
Copy link
Copy Markdown
Contributor

@lingyun14beta lingyun14beta commented May 12, 2026

通过惊人的注意力发现了文档的一些错误

Modifications / 改动点

  1. def add / def calc_help 应为 async def
    (docs/zh|en/dev/star/guides/listen-message-event.md)
  2. on_decorating_result 示例缺少 Plain 导入
    (docs/zh|en/dev/star/guides/listen-message-event.md)
  3. PlatformAdapterType不完整
    (docs/zh|en/dev/star/guides/listen-message-event.md)
  4. delete_persona Raises 字段拼写错误
    (docs/zh/dev/star/guides/ai.md)
    ValueableValueError,与 persona_mgr.py 实际 raise 类型一致。
  5. support_platforms 列表不完整
    (docs/zh|en/dev/star/plugin-new.md)
    缺少 qq_official_webhookwecom_ai_botweixin_ocmatrixmattermost 5 个平台。(还是要声明一下好?)
  6. simple.md 导入了已废弃的 register
    (docs/zh/dev/star/guides/simple.md)
    register_star 装饰器自 v3.5.20 起标注 DeprecationWarning
  7. star_handler.py docstring 参数命名不一致
    (astrbot/core/star/register/star_handler.py)
    register_on_llm_request 的 docstring 示例使用 request,而调用处internal.py 变量名为 req,用户文档两处示例也均为 req。将 docstring 统一改为 req,消除歧义。
  8. 指令组占位函数 self 参数前后不一致
    (docs/zh|en/dev/star/guides/listen-message-event.md)
    同文件两处示例,一处写 def math(self):,另一处写 def math():。统一改为无 self
  • This is NOT a breaking change. / 这不是一个破坏性变更。

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

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

Summary by Sourcery

Update plugin development documentation and examples to reflect current async APIs, supported platforms, and consistent naming.

Enhancements:

  • Align register_on_llm_request docstring example parameter naming with existing usage to avoid ambiguity.

Documentation:

  • Correct command and helper function examples to use async definitions and consistent command group signatures in message event guides (EN/ZN).
  • Expand documented PlatformAdapterType and support_platforms lists to include all currently supported adapters in both English and Chinese docs.
  • Fix missing message component import and usage in on_decorating_result examples in message event guides (EN/ZH).
  • Correct the documented exception type for delete_persona and remove deprecated register import from simple plugin guide (ZH).

@auto-assign auto-assign Bot requested review from Fridemn and Soulter May 12, 2026 15:12
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label May 12, 2026
Copy link
Copy Markdown
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 - I've found 1 issue, and left some high level feedback:

  • In the command examples, you’ve updated add and calc_help to be async, but other command handlers in the same docs (e.g. those under @math.command) are still sync; consider making all handler examples consistently async to avoid confusing plugin authors about the required function signature.
  • The hardcoded PlatformAdapterType lists in the docs are now much more complete; to reduce future drift, it might be worth adding a short note pointing readers to the canonical enum / mapping in the codebase so the docs don’t need manual updates every time a new adapter is added.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the command examples, you’ve updated `add` and `calc_help` to be `async`, but other command handlers in the same docs (e.g. those under `@math.command`) are still sync; consider making all handler examples consistently `async` to avoid confusing plugin authors about the required function signature.
- The hardcoded `PlatformAdapterType` lists in the docs are now much more complete; to reduce future drift, it might be worth adding a short note pointing readers to the canonical enum / mapping in the codebase so the docs don’t need manual updates every time a new adapter is added.

## Individual Comments

### Comment 1
<location path="docs/zh/dev/star/guides/listen-message-event.md" line_range="100-101" />
<code_context>
-def add(self, event: AstrMessageEvent, a: int, b: int):
+async def add(self, event: AstrMessageEvent, a: int, b: int):
     # /add 1 2 -> 结果是: 3
     yield event.plain_result(f"Wow! The anwser is {a + b}!")
 ```
</code_context>
<issue_to_address>
**issue (typo):** Fix the typo "anwser" in the example string.

```suggestion
    # /add 1 2 -> 结果是: 3
    yield event.plain_result(f"Wow! The answer is {a + b}!")
```
</issue_to_address>

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/zh/dev/star/guides/listen-message-event.md Outdated
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request primarily updates the documentation and docstring examples to align with current API standards, including the use of async def for command handlers and the expansion of the PlatformAdapterType list. It also refines message component usage and fixes several typos. Review feedback identifies an inconsistency in the documented parameter count for LLM requests, a spelling error in the Chinese guide, and missing platform entries in the plugin development documentation.

```

请务必接收两个参数:event, request
请务必接收两个参数:event, req
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.

medium

文档说明中提到的参数数量与示例代码不一致。示例代码中包含 selfeventreq 三个参数,而说明文字称“务必接收两个参数”。建议统一为三个参数以减少误导。

Suggested change
请务必接收两个参数event, req
请务必接收三个参数self, event, req

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

不需要吧我记得

Comment thread docs/zh/dev/star/guides/listen-message-event.md Outdated
- `misskey`
- `line`
- `matrix`
- `mattermost`
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.

medium

docs/en/dev/star/guides/listen-message-event.md 中,PlatformAdapterType 列表包含了 WEBCHAT,但在此处的 support_platforms 列表中缺失了 webchat。建议添加以保持文档一致性。

Suggested change
- `mattermost`
- mattermost
- webchat

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

webchat是内置功能,不需要列入support_platforms

- `misskey`
- `line`
- `matrix`
- `mattermost`
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.

medium

docs/zh/dev/star/guides/listen-message-event.md 中,PlatformAdapterType 列表包含了 WEBCHAT,但在此处的 support_platforms 列表中缺失了 webchat。建议添加以保持文档一致性。

Suggested change
- `mattermost`
- mattermost
- webchat

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

webchat是内置功能,不需要列入support_platforms

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 12, 2026
@Soulter Soulter merged commit cb90de7 into AstrBotDevs:master May 12, 2026
21 checks passed
@Soulter
Copy link
Copy Markdown
Member

Soulter commented May 12, 2026

thanks!

@lingyun14beta lingyun14beta deleted the docs branch May 12, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants