diff --git a/astrbot/core/star/register/star_handler.py b/astrbot/core/star/register/star_handler.py index 49a65d891..4693a4e75 100644 --- a/astrbot/core/star/register/star_handler.py +++ b/astrbot/core/star/register/star_handler.py @@ -422,11 +422,11 @@ def register_on_llm_request(**kwargs): from astrbot.api.provider import ProviderRequest @on_llm_request() - async def test(self, event: AstrMessageEvent, request: ProviderRequest) -> None: - request.system_prompt += "你是一个猫娘..." + async def test(self, event: AstrMessageEvent, req: ProviderRequest) -> None: + req.system_prompt += "你是一个猫娘..." ``` - 请务必接收两个参数:event, request + 请务必接收两个参数:event, req """ diff --git a/docs/en/dev/star/guides/listen-message-event.md b/docs/en/dev/star/guides/listen-message-event.md index e798475ad..9e58326ca 100644 --- a/docs/en/dev/star/guides/listen-message-event.md +++ b/docs/en/dev/star/guides/listen-message-event.md @@ -1,4 +1,3 @@ - # Handling Message Events Event listeners can receive message content delivered by the platform and implement features such as commands, command groups, and event listening. @@ -97,7 +96,7 @@ AstrBot will automatically parse command parameters for you. ```python @filter.command("add") -def add(self, event: AstrMessageEvent, a: int, b: int): +async def add(self, event: AstrMessageEvent, a: int, b: int): # /add 1 2 -> Result is: 3 yield event.plain_result(f"Wow! The answer is {a + b}!") ``` @@ -108,7 +107,7 @@ Command groups help you organize commands. ```python @filter.command_group("math") -def math(self): +def math(): pass @math.command("add") @@ -160,7 +159,7 @@ async def sub(self, event: AstrMessageEvent, a: int, b: int): yield event.plain_result(f"Result is: {a - b}") @calc.command("help") -def calc_help(self, event: AstrMessageEvent): +async def calc_help(self, event: AstrMessageEvent): # /math calc help yield event.plain_result("This is a calculator plugin with add and sub commands.") ``` @@ -173,7 +172,7 @@ You can add different aliases for commands or command groups: ```python @filter.command("help", alias={'帮助', 'helpme'}) -def help(self, event: AstrMessageEvent): +async def help(self, event: AstrMessageEvent): yield event.plain_result("This is a calculator plugin with add and sub commands.") ``` @@ -209,7 +208,7 @@ async def on_aiocqhttp(self, event: AstrMessageEvent): yield event.plain_result("Received a message") ``` -In the current version, `PlatformAdapterType` includes `AIOCQHTTP`, `QQOFFICIAL`, `GEWECHAT`, and `ALL`. +In the current version, `PlatformAdapterType` supports the following values: `AIOCQHTTP`, `QQOFFICIAL`, `QQOFFICIAL_WEBHOOK`, `TELEGRAM`, `WECOM`, `WECOM_AI_BOT`, `LARK`, `DINGTALK`, `DISCORD`, `SLACK`, `KOOK`, `VOCECHAT`, `WEIXIN_OFFICIAL_ACCOUNT`, `SATORI`, `MISSKEY`, `LINE`, `MATRIX`, `WEIXIN_OC`, `MATTERMOST`, `WEBCHAT`, `ALL`. #### Admin Commands @@ -420,13 +419,14 @@ You can implement some message decoration here, such as converting to voice, con ```python from astrbot.api.event import filter, AstrMessageEvent +import astrbot.api.message_components as Comp @filter.on_decorating_result() async def on_decorating_result(self, event: AstrMessageEvent): result = event.get_result() chain = result.chain print(chain) # Print the message chain - chain.append(Plain("!")) # Add an exclamation mark at the end of the message chain + chain.append(Comp.Plain("!")) # Add an exclamation mark at the end of the message chain ``` > You cannot use yield to send messages here. This hook is only for decorating event.get_result().chain. If you need to send, please use the `event.send()` method directly. diff --git a/docs/en/dev/star/plugin-new.md b/docs/en/dev/star/plugin-new.md index b3e6845db..e50e96964 100644 --- a/docs/en/dev/star/plugin-new.md +++ b/docs/en/dev/star/plugin-new.md @@ -102,8 +102,10 @@ The values in `support_platforms` must be keys from `ADAPTER_NAME_2_TYPE`. Curre - `aiocqhttp` - `qq_official` +- `qq_official_webhook` - `telegram` - `wecom` +- `wecom_ai_bot` - `lark` - `dingtalk` - `discord` @@ -111,9 +113,12 @@ The values in `support_platforms` must be keys from `ADAPTER_NAME_2_TYPE`. Curre - `kook` - `vocechat` - `weixin_official_account` +- `weixin_oc` - `satori` - `misskey` - `line` +- `matrix` +- `mattermost` ### Declare AstrBot Version Range (Optional) diff --git a/docs/zh/dev/star/guides/ai.md b/docs/zh/dev/star/guides/ai.md index 549275ace..71b867efd 100644 --- a/docs/zh/dev/star/guides/ai.md +++ b/docs/zh/dev/star/guides/ai.md @@ -1,4 +1,3 @@ - # AI AstrBot 内置了对多种大语言模型(LLM)提供商的支持,并且提供了统一的接口,方便插件开发者调用各种 LLM 服务。 @@ -490,7 +489,7 @@ persona_mgr = self.context.persona_manager - __Arguments__ - `persona_id: str` – 待删除的人格 ID - __Raises__ - `Valueable` – 若 `persona_id` 不存在 + `ValueError` – 若 `persona_id` 不存在 #### `get_default_persona_v3` diff --git a/docs/zh/dev/star/guides/listen-message-event.md b/docs/zh/dev/star/guides/listen-message-event.md index b8187b00b..edb7c7e0a 100644 --- a/docs/zh/dev/star/guides/listen-message-event.md +++ b/docs/zh/dev/star/guides/listen-message-event.md @@ -1,4 +1,3 @@ - # 处理消息事件 事件监听器可以收到平台下发的消息内容,可以实现指令、指令组、事件监听等功能。 @@ -97,9 +96,9 @@ AstrBot 会自动帮你解析指令的参数。 ```python @filter.command("add") -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}!") + yield event.plain_result(f"Wow! The answer is {a + b}!") ``` ## 指令组 @@ -108,7 +107,7 @@ def add(self, event: AstrMessageEvent, a: int, b: int): ```python @filter.command_group("math") -def math(self): +def math(): pass @math.command("add") @@ -160,7 +159,7 @@ async def sub(self, event: AstrMessageEvent, a: int, b: int): yield event.plain_result(f"结果是: {a - b}") @calc.command("help") -def calc_help(self, event: AstrMessageEvent): +async def calc_help(self, event: AstrMessageEvent): # /math calc help yield event.plain_result("这是一个计算器插件,拥有 add, sub 指令。") ``` @@ -173,7 +172,7 @@ def calc_help(self, event: AstrMessageEvent): ```python @filter.command("help", alias={'帮助', 'helpme'}) -def help(self, event: AstrMessageEvent): +async def help(self, event: AstrMessageEvent): yield event.plain_result("这是一个计算器插件,拥有 add, sub 指令。") ``` @@ -209,7 +208,7 @@ async def on_aiocqhttp(self, event: AstrMessageEvent): yield event.plain_result("收到了一条信息") ``` -当前版本下,`PlatformAdapterType` 有 `AIOCQHTTP`, `QQOFFICIAL`, `GEWECHAT`, `ALL`。 +当前版本下,`PlatformAdapterType` 支持以下值:`AIOCQHTTP`、`QQOFFICIAL`、`QQOFFICIAL_WEBHOOK`、`TELEGRAM`、`WECOM`、`WECOM_AI_BOT`、`LARK`、`DINGTALK`、`DISCORD`、`SLACK`、`KOOK`、`VOCECHAT`、`WEIXIN_OFFICIAL_ACCOUNT`、`SATORI`、`MISSKEY`、`LINE`、`MATRIX`、`WEIXIN_OC`、`MATTERMOST`、`WEBCHAT`、`ALL`。 #### 管理员指令 @@ -437,13 +436,14 @@ async def on_agent_done(self, event: AstrMessageEvent, run_context: ContextWrapp ```python from astrbot.api.event import filter, AstrMessageEvent +import astrbot.api.message_components as Comp @filter.on_decorating_result() async def on_decorating_result(self, event: AstrMessageEvent): result = event.get_result() chain = result.chain print(chain) # 打印消息链 - chain.append(Plain("!")) # 在消息链的最后添加一个感叹号 + chain.append(Comp.Plain("!")) # 在消息链的最后添加一个感叹号 ``` > 这里不能使用 yield 来发送消息。这个钩子只是用来装饰 event.get_result().chain 的。如需发送,请直接使用 `event.send()` 方法。 diff --git a/docs/zh/dev/star/guides/simple.md b/docs/zh/dev/star/guides/simple.md index d3314133f..b700bef06 100644 --- a/docs/zh/dev/star/guides/simple.md +++ b/docs/zh/dev/star/guides/simple.md @@ -4,7 +4,7 @@ ```python from astrbot.api.event import filter, AstrMessageEvent, MessageEventResult -from astrbot.api.star import Context, Star, register +from astrbot.api.star import Context, Star from astrbot.api import logger # 使用 astrbot 提供的 logger 接口 class MyPlugin(Star): diff --git a/docs/zh/dev/star/plugin-new.md b/docs/zh/dev/star/plugin-new.md index 04d61deae..2ebf5f392 100644 --- a/docs/zh/dev/star/plugin-new.md +++ b/docs/zh/dev/star/plugin-new.md @@ -104,8 +104,10 @@ support_platforms: - `aiocqhttp` - `qq_official` +- `qq_official_webhook` - `telegram` - `wecom` +- `wecom_ai_bot` - `lark` - `dingtalk` - `discord` @@ -113,9 +115,12 @@ support_platforms: - `kook` - `vocechat` - `weixin_official_account` +- `weixin_oc` - `satori` - `misskey` - `line` +- `matrix` +- `mattermost` ### 声明 AstrBot 版本范围(Optional)