From 2bc0451f6286b139ac5e4b99a819ae4b7f19de27 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 19 Jun 2025 15:24:29 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20=E8=87=AA=E5=8A=A8=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96=E4=BB=A3=E7=A0=81=20[skip=20ci]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/hello_world_plugin/plugin.py | 9 +++++++-- src/plugin_system/apis/send_api.py | 6 +++--- src/plugin_system/base/base_action.py | 6 +----- src/plugin_system/base/base_command.py | 20 +++++++++----------- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/plugins/hello_world_plugin/plugin.py b/plugins/hello_world_plugin/plugin.py index 19dae84f0..60723e227 100644 --- a/plugins/hello_world_plugin/plugin.py +++ b/plugins/hello_world_plugin/plugin.py @@ -1,7 +1,12 @@ from typing import List, Tuple, Type from src.plugin_system import ( - BasePlugin, register_plugin, BaseAction, BaseCommand, - ComponentInfo, ActionActivationType, ConfigField + BasePlugin, + register_plugin, + BaseAction, + BaseCommand, + ComponentInfo, + ActionActivationType, + ConfigField, ) # ===== Action组件 ===== diff --git a/src/plugin_system/apis/send_api.py b/src/plugin_system/apis/send_api.py index c64736a0a..18069bbb6 100644 --- a/src/plugin_system/apis/send_api.py +++ b/src/plugin_system/apis/send_api.py @@ -5,16 +5,16 @@ 使用方式: from src.plugin_system.apis import send_api - + # 方式1:直接使用stream_id(推荐) await send_api.text_to_stream("hello", stream_id) await send_api.emoji_to_stream(emoji_base64, stream_id) await send_api.custom_to_stream("video", video_data, stream_id) - + # 方式2:使用群聊/私聊指定函数 await send_api.text_to_group("hello", "123456") await send_api.text_to_user("hello", "987654") - + # 方式3:使用通用custom_message函数 await send_api.custom_message("video", video_data, "123456", True) """ diff --git a/src/plugin_system/base/base_action.py b/src/plugin_system/base/base_action.py index 6432f5645..3758c7f14 100644 --- a/src/plugin_system/base/base_action.py +++ b/src/plugin_system/base/base_action.py @@ -213,11 +213,7 @@ class BaseAction(ABC): logger.error(f"{self.log_prefix} 缺少聊天ID") return False - return await send_api.text_to_stream( - text=content, - stream_id=self.chat_id, - reply_to=reply_to - ) + return await send_api.text_to_stream(text=content, stream_id=self.chat_id, reply_to=reply_to) async def send_emoji(self, emoji_base64: str) -> bool: """发送表情包 diff --git a/src/plugin_system/base/base_command.py b/src/plugin_system/base/base_command.py index 50b345fc5..0a94fe1d1 100644 --- a/src/plugin_system/base/base_command.py +++ b/src/plugin_system/base/base_command.py @@ -98,15 +98,11 @@ class BaseCommand(ABC): """ # 获取聊天流信息 chat_stream = self.message.chat_stream - if not chat_stream or not hasattr(chat_stream, 'stream_id'): + if not chat_stream or not hasattr(chat_stream, "stream_id"): logger.error(f"{self.log_prefix} 缺少聊天流或stream_id") return False - return await send_api.text_to_stream( - text=content, - stream_id=chat_stream.stream_id, - reply_to=reply_to - ) + return await send_api.text_to_stream(text=content, stream_id=chat_stream.stream_id, reply_to=reply_to) async def send_type( self, message_type: str, content: str, display_message: str = "", typing: bool = False, reply_to: str = "" @@ -125,7 +121,7 @@ class BaseCommand(ABC): """ # 获取聊天流信息 chat_stream = self.message.chat_stream - if not chat_stream or not hasattr(chat_stream, 'stream_id'): + if not chat_stream or not hasattr(chat_stream, "stream_id"): logger.error(f"{self.log_prefix} 缺少聊天流或stream_id") return False @@ -138,7 +134,9 @@ class BaseCommand(ABC): reply_to=reply_to, ) - async def send_command(self, command_name: str, args: dict = None, display_message: str = "", storage_message: bool = True) -> bool: + async def send_command( + self, command_name: str, args: dict = None, display_message: str = "", storage_message: bool = True + ) -> bool: """发送命令消息 Args: @@ -153,7 +151,7 @@ class BaseCommand(ABC): try: # 获取聊天流信息 chat_stream = self.message.chat_stream - if not chat_stream or not hasattr(chat_stream, 'stream_id'): + if not chat_stream or not hasattr(chat_stream, "stream_id"): logger.error(f"{self.log_prefix} 缺少聊天流或stream_id") return False @@ -187,7 +185,7 @@ class BaseCommand(ABC): bool: 是否发送成功 """ chat_stream = self.message.chat_stream - if not chat_stream or not hasattr(chat_stream, 'stream_id'): + if not chat_stream or not hasattr(chat_stream, "stream_id"): logger.error(f"{self.log_prefix} 缺少聊天流或stream_id") return False @@ -203,7 +201,7 @@ class BaseCommand(ABC): bool: 是否发送成功 """ chat_stream = self.message.chat_stream - if not chat_stream or not hasattr(chat_stream, 'stream_id'): + if not chat_stream or not hasattr(chat_stream, "stream_id"): logger.error(f"{self.log_prefix} 缺少聊天流或stream_id") return False