From 2c5dd9bba046999af1f39b1042a992654326714d Mon Sep 17 00:00:00 2001 From: minecraft1024a Date: Sat, 30 Aug 2025 14:41:33 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E7=AE=80=E5=8C=96=20README=20=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E5=AE=89=E8=A3=85=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将详细的安装和配置步骤移至官方文档,并在 README 中提供直接链接。这使得 README 更加简洁,并引导用户访问最新的、更全面的部署指南。 --- README.md | 20 ++---- .../built_in/set_typing_status/_manifest.json | 16 +++++ .../built_in/set_typing_status/plugin.py | 64 +++++++++++++++++++ 3 files changed, 84 insertions(+), 16 deletions(-) create mode 100644 src/plugins/built_in/set_typing_status/_manifest.json create mode 100644 src/plugins/built_in/set_typing_status/plugin.py diff --git a/README.md b/README.md index d45e86c43..9ae8ca7e6 100644 --- a/README.md +++ b/README.md @@ -124,22 +124,10 @@ -```bash -# 1. 克隆项目到本地 -git clone https://github.com/MoFox-Studio/MoFox_Bot.git -cd MoFox_Bot - -# 2. 安装依赖 -pip install -r requirements.txt - -# 3. 配置机器人 -# 首先,复制配置文件模板 -cp config/bot_config.toml.example config/bot_config.toml -# 然后,根据你的需求编辑 config/bot_config.toml 文件 - -# 4. 启动机器人 -python bot.py -``` +> [!NOTE] +> 详细的安装和配置步骤,请务必参考我们的官方文档: +> * **Windows 用户部署指南**: [https://mofox-studio.github.io/MoFox-Bot-Docs/docs/deployment_guide.html](https://mofox-studio.github.io/MoFox-Bot-Docs/docs/deployment_guide.html) +> * **`bot_config.toml` 究极详细教程**: [https://mofox-studio.github.io/MoFox-Bot-Docs/docs/guides/bot_config_guide.html](https://mofox-studio.github.io/MoFox-Bot-Docs/docs/guides/bot_config_guide.html)
diff --git a/src/plugins/built_in/set_typing_status/_manifest.json b/src/plugins/built_in/set_typing_status/_manifest.json new file mode 100644 index 000000000..d3914ea48 --- /dev/null +++ b/src/plugins/built_in/set_typing_status/_manifest.json @@ -0,0 +1,16 @@ +{ + "name": "Set Typing Status", + "description": "一个在LLM生成回复时设置私聊输入状态的插件。", + "version": "1.0.0", + "author": { + "name": "Kilo Code" + }, + "license": "MIT", + "homepage_url": "", + "repository_url": "", + "keywords": ["typing", "status", "private chat"], + "categories": ["utility"], + "host_application": { + "min_version": "1.0.0" + } +} \ No newline at end of file diff --git a/src/plugins/built_in/set_typing_status/plugin.py b/src/plugins/built_in/set_typing_status/plugin.py new file mode 100644 index 000000000..a88fe1390 --- /dev/null +++ b/src/plugins/built_in/set_typing_status/plugin.py @@ -0,0 +1,64 @@ +from typing import List, Tuple, Type +import logging + +from src.plugin_system import ( + BasePlugin, + register_plugin, + ComponentInfo, + BaseEventHandler, + EventType, +) +from src.plugin_system.base.base_event import HandlerResult +from src.plugin_system.apis import send_api + +logger = logging.getLogger(__name__) + + +class SetTypingStatusHandler(BaseEventHandler): + """在LLM处理私聊消息后设置“正在输入”状态的事件处理器。""" + + handler_name = "set_typing_status_handler" + handler_description = "在LLM生成回复后,将用户的聊天状态设置为“正在输入”。" + init_subscribe = [EventType.POST_LLM] + + async def execute(self, params: dict) -> HandlerResult: + message = params.get("message") + if not message or not message.is_private_message: + return HandlerResult(success=True, continue_process=True) + + user_id = message.message_info.user_info.user_id + if not user_id: + return HandlerResult(success=False, continue_process=True, message="无法获取用户ID") + + try: + params = {"user_id": user_id,"event_type": 1} + await send_api.adapter_command_to_stream( + action="set_input_status", + params=params, + stream_id=message.stream_id, + ) + logger.debug(f"成功为用户 {user_id} 设置“正在输入”状态。") + return HandlerResult(success=True, continue_process=True) + except Exception as e: + logger.error(f"为用户 {user_id} 设置“正在输入”状态时出错: {e}") + return HandlerResult(success=False, continue_process=True, message=str(e)) + + +@register_plugin +class SetTypingStatusPlugin(BasePlugin): + """一个在LLM生成回复时设置私聊输入状态的插件。""" + + plugin_name = "set_typing_status" + enable_plugin = True + dependencies = [] + python_dependencies = [] + config_file_name = "" + + config_schema = {} + + def get_plugin_components(self) -> List[Tuple[ComponentInfo, Type]]: + """注册插件的功能组件。""" + return [(SetTypingStatusHandler.get_handler_info(), SetTypingStatusHandler)] + + def register_plugin(self) -> bool: + return True