refactor: 将项目名称从 MaiBot 重命名为 MoFox-Bot

本次更新在整个代码库范围内将项目名称 "MaiBot" 及其相关变体(如 "maibot")统一重命名为 "MoFox-Bot"。

主要变更包括:
- 修改配置文件、模板和日志输出中的项目名称。
- 更新文档、注释和用户可见的字符串,以反映新的品牌名称。
- 调整插件元数据和描述。
This commit is contained in:
minecraft1024a
2025-10-11 20:46:00 +08:00
parent 6774d2a6c2
commit 3040000531
18 changed files with 43 additions and 43 deletions

View File

@@ -2,7 +2,7 @@
## 概述 ## 概述
增强命令系统是MaiBot插件系统的一个扩展让命令的定义和使用变得更加简单直观。你不再需要编写复杂的正则表达式只需要定义命令名、别名和参数处理逻辑即可。 增强命令系统是MoFox-Bot插件系统的一个扩展让命令的定义和使用变得更加简单直观。你不再需要编写复杂的正则表达式只需要定义命令名、别名和参数处理逻辑即可。
## 核心特性 ## 核心特性

View File

@@ -43,7 +43,7 @@ class ExampleAction(BaseAction):
这部分由Adapter传递给处理器。 这部分由Adapter传递给处理器。
以 MaiBot-Napcat-Adapter 为例,可选项目如下: 以 MoFox-Bot-Napcat-Adapter 为例,可选项目如下:
| 类型 | 说明 | 格式 | | 类型 | 说明 | 格式 |
| --- | --- | --- | | --- | --- | --- |
| text | 文本消息 | str | | text | 文本消息 | str |

View File

@@ -28,7 +28,7 @@ def get_global_config(key: str, default: Any = None) -> Any:
#### 示例: #### 示例:
获取机器人昵称 获取机器人昵称
```python ```python
bot_name = config_api.get_global_config("bot.nickname", "MaiBot") bot_name = config_api.get_global_config("bot.nickname", "MoFox-Bot")
``` ```
### 2. 获取插件配置 ### 2. 获取插件配置

View File

@@ -1,5 +1,5 @@
""" """
MaiBot模块系统 MoFox-Bot模块系统
包含聊天、情绪、记忆、日程等功能模块 包含聊天、情绪、记忆、日程等功能模块
""" """

View File

@@ -1,5 +1,5 @@
""" """
MaiBot 反注入系统模块 MoFox-Bot 反注入系统模块
本模块提供了一个完整的LLM反注入检测和防护系统用于防止恶意的提示词注入攻击。 本模块提供了一个完整的LLM反注入检测和防护系统用于防止恶意的提示词注入攻击。

View File

@@ -868,7 +868,7 @@ class StatisticOutputTask(AsyncTask):
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MaiBot运行统计报告</title> <title>MoFox-Bot运行统计报告</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style> <style>
body { body {
@@ -970,7 +970,7 @@ class StatisticOutputTask(AsyncTask):
""" """
+ f""" + f"""
<div class="container"> <div class="container">
<h1>MaiBot运行统计报告</h1> <h1>MoFox-Bot运行统计报告</h1>
<p class="info-item"><strong>统计截止时间:</strong> {now.strftime("%Y-%m-%d %H:%M:%S")}</p> <p class="info-item"><strong>统计截止时间:</strong> {now.strftime("%Y-%m-%d %H:%M:%S")}</p>
<div class="tabs"> <div class="tabs">

View File

@@ -58,7 +58,7 @@ install(extra_lines=3)
# 配置主程序日志格式 # 配置主程序日志格式
logger = get_logger("config") logger = get_logger("config")
# 获取当前文件所在目录的父目录的父目录即MaiBot项目根目录 # 获取当前文件所在目录的父目录的父目录即MoFox-Bot项目根目录
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
CONFIG_DIR = os.path.join(PROJECT_ROOT, "config") CONFIG_DIR = os.path.join(PROJECT_ROOT, "config")
TEMPLATE_DIR = os.path.join(PROJECT_ROOT, "template") TEMPLATE_DIR = os.path.join(PROJECT_ROOT, "template")

View File

@@ -1,5 +1,5 @@
""" """
MaiBot 插件系统 MoFox-Bot 插件系统
提供统一的插件开发和管理框架 提供统一的插件开发和管理框架
""" """

View File

@@ -172,11 +172,11 @@ async def graceful_shutdown():
except Exception as e: except Exception as e:
logger.warning(f"关闭WebSocket连接时出错: {e}") logger.warning(f"关闭WebSocket连接时出错: {e}")
# 关闭 MaiBot 连接 # 关闭 MoFox-Bot 连接
try: try:
await mmc_stop_com() await mmc_stop_com()
except Exception as e: except Exception as e:
logger.warning(f"关闭MaiBot连接时出错: {e}") logger.warning(f"关闭MoFox-Bot连接时出错: {e}")
# 取消所有剩余任务 # 取消所有剩余任务
current_task = asyncio.current_task() current_task = asyncio.current_task()
@@ -234,9 +234,9 @@ class LauchNapcatAdapterHandler(BaseEventHandler):
asyncio.create_task(message_process()) asyncio.create_task(message_process())
asyncio.create_task(check_timeout_response()) asyncio.create_task(check_timeout_response())
async def _start_maibot_connection(self): async def _start_mofox_bot_connection(self):
"""非阻塞方式启动MaiBot连接等待主服务启动后再连接""" """非阻塞方式启动MoFox-Bot连接等待主服务启动后再连接"""
# 等待一段时间让MaiBot主服务完全启动 # 等待一段时间让MoFox-Bot主服务完全启动
await asyncio.sleep(5) await asyncio.sleep(5)
max_attempts = 10 max_attempts = 10
@@ -244,19 +244,19 @@ class LauchNapcatAdapterHandler(BaseEventHandler):
while attempt < max_attempts: while attempt < max_attempts:
try: try:
logger.info(f"尝试连接MaiBot (第{attempt + 1}次)") logger.info(f"尝试连接MoFox-Bot (第{attempt + 1}次)")
await mmc_start_com(self.plugin_config) await mmc_start_com(self.plugin_config)
message_send_instance.maibot_router = router message_send_instance.mofox_bot_router = router
logger.info("MaiBot router连接已建立") logger.info("MoFox-Bot router连接已建立")
return return
except Exception as e: except Exception as e:
attempt += 1 attempt += 1
if attempt >= max_attempts: if attempt >= max_attempts:
logger.error(f"MaiBot连接失败已达到最大重试次数: {e}") logger.error(f"MoFox-Bot连接失败已达到最大重试次数: {e}")
return return
else: else:
delay = min(2 + attempt, 10) # 逐渐增加延迟最大10秒 delay = min(2 + attempt, 10) # 逐渐增加延迟最大10秒
logger.warning(f"MaiBot连接失败: {e}{delay}秒后重试") logger.warning(f"MoFox-Bot连接失败: {e}{delay}秒后重试")
await asyncio.sleep(delay) await asyncio.sleep(delay)

View File

@@ -1,7 +1,7 @@
[project] [project]
name = "MaiBotNapcatAdapter" name = "MoFoxBotNapcatAdapter"
version = "0.4.8" version = "0.4.8"
description = "A MaiBot adapter for Napcat" description = "A MoFox-Bot adapter for Napcat"
dependencies = [ dependencies = [
"ruff>=0.12.9", "ruff>=0.12.9",
] ]

View File

@@ -27,4 +27,4 @@ pyproject_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "pypro
toml_data = tomlkit.parse(open(pyproject_path, "r", encoding="utf-8").read()) toml_data = tomlkit.parse(open(pyproject_path, "r", encoding="utf-8").read())
project_data = toml_data.get("project", {}) project_data = toml_data.get("project", {})
version = project_data.get("version", "unknown") version = project_data.get("version", "unknown")
logger.info(f"版本\n\nMaiBot-Napcat-Adapter 版本: {version}\n喜欢的话点个star喵~\n") logger.info(f"版本\n\nMoFox-Bot-Napcat-Adapter 版本: {version}\n喜欢的话点个star喵~\n")

View File

@@ -32,7 +32,7 @@ def create_router(plugin_config: dict):
async def mmc_start_com(plugin_config: dict | None = None): async def mmc_start_com(plugin_config: dict | None = None):
"""启动MaiBot连接""" """启动MoFox-Bot连接"""
logger.debug("正在连接MoFox-Bot") logger.debug("正在连接MoFox-Bot")
if plugin_config: if plugin_config:
create_router(plugin_config) create_router(plugin_config)
@@ -43,6 +43,6 @@ async def mmc_start_com(plugin_config: dict | None = None):
async def mmc_stop_com(): async def mmc_stop_com():
"""停止MaiBot连接""" """停止MoFox-Bot连接"""
if router: if router:
await router.stop() await router.stop()

View File

@@ -304,7 +304,7 @@ class MessageHandler:
# 消息缓冲功能已移除,直接处理消息 # 消息缓冲功能已移除,直接处理消息
logger.debug(f"准备发送消息到MaiBot消息段数量: {len(seg_message)}") logger.debug(f"准备发送消息到MoFox-Bot消息段数量: {len(seg_message)}")
for i, seg in enumerate(seg_message): for i, seg in enumerate(seg_message):
logger.debug(f"消息段 {i}: type={seg.type}, data={str(seg.data)[:100]}...") logger.debug(f"消息段 {i}: type={seg.type}, data={str(seg.data)[:100]}...")

View File

@@ -26,17 +26,17 @@ class MessageSending:
self.plugin_config = plugin_config self.plugin_config = plugin_config
async def _attempt_reconnect(self): async def _attempt_reconnect(self):
"""尝试重新连接MaiBot router""" """尝试重新连接MoFox-Bot router"""
if self._connection_retries < self._max_retries: if self._connection_retries < self._max_retries:
self._connection_retries += 1 self._connection_retries += 1
logger.warning(f"尝试重新连接MaiBot router (第{self._connection_retries}次)") logger.warning(f"尝试重新连接MoFox-Bot router (第{self._connection_retries}次)")
try: try:
# 重新导入router # 重新导入router
from ..mmc_com_layer import router from ..mmc_com_layer import router
self.maibot_router = router self.maibot_router = router
if self.maibot_router is not None: if self.maibot_router is not None:
logger.info("MaiBot router重连成功") logger.info("MoFox-Bot router重连成功")
self._connection_retries = 0 # 重置重试计数 self._connection_retries = 0 # 重置重试计数
return True return True
except Exception as e: except Exception as e:
@@ -54,32 +54,32 @@ class MessageSending:
try: try:
# 检查maibot_router是否已初始化 # 检查maibot_router是否已初始化
if self.maibot_router is None: if self.maibot_router is None:
logger.warning("MaiBot router未初始化尝试重新连接") logger.warning("MoFox-Bot router未初始化尝试重新连接")
if not await self._attempt_reconnect(): if not await self._attempt_reconnect():
logger.error("MaiBot router重连失败无法发送消息") logger.error("MoFox-Bot router重连失败无法发送消息")
logger.error("请检查与MaiBot之间的连接") logger.error("请检查与MoFox-Bot之间的连接")
return False return False
# 检查是否需要切片发送 # 检查是否需要切片发送
message_dict = message_base.to_dict() message_dict = message_base.to_dict()
if chunker.should_chunk_message(message_dict): if chunker.should_chunk_message(message_dict):
logger.info("消息过大,进行切片发送到 MaiBot") logger.info("消息过大,进行切片发送到 MoFox-Bot")
# 切片消息 # 切片消息
chunks = chunker.chunk_message(message_dict) chunks = chunker.chunk_message(message_dict)
# 逐个发送切片 # 逐个发送切片
for i, chunk in enumerate(chunks): for i, chunk in enumerate(chunks):
logger.debug(f"发送切片 {i + 1}/{len(chunks)} 到 MaiBot") logger.debug(f"发送切片 {i + 1}/{len(chunks)} 到 MoFox-Bot")
# 获取对应的客户端并发送切片 # 获取对应的客户端并发送切片
platform = message_base.message_info.platform platform = message_base.message_info.platform
# 再次检查router状态防止运行时被重置 # 再次检查router状态防止运行时被重置
if self.maibot_router is None or not hasattr(self.maibot_router, "clients"): if self.maibot_router is None or not hasattr(self.maibot_router, "clients"):
logger.warning("MaiBot router连接已断开尝试重新连接") logger.warning("MoFox-Bot router连接已断开尝试重新连接")
if not await self._attempt_reconnect(): if not await self._attempt_reconnect():
logger.error("MaiBot router重连失败切片发送中止") logger.error("MoFox-Bot router重连失败切片发送中止")
return False return False
if platform not in self.maibot_router.clients: if platform not in self.maibot_router.clients:
@@ -111,7 +111,7 @@ class MessageSending:
except Exception as e: except Exception as e:
logger.error(f"发送消息失败: {str(e)}") logger.error(f"发送消息失败: {str(e)}")
logger.error("请检查与MaiBot之间的连接") logger.error("请检查与MoFox-Bot之间的连接")
return False return False

View File

@@ -46,7 +46,7 @@ class SendHandler:
async def handle_message(self, raw_message_base_dict: dict) -> None: async def handle_message(self, raw_message_base_dict: dict) -> None:
raw_message_base: MessageBase = MessageBase.from_dict(raw_message_base_dict) raw_message_base: MessageBase = MessageBase.from_dict(raw_message_base_dict)
message_segment: Seg = raw_message_base.message_segment message_segment: Seg = raw_message_base.message_segment
logger.info("接收到来自MaiBot的消息处理中") logger.info("接收到来自MoFox-Bot的消息处理中")
if message_segment.type == "command": if message_segment.type == "command":
logger.info("处理命令") logger.info("处理命令")
return await self.send_command(raw_message_base) return await self.send_command(raw_message_base)
@@ -196,7 +196,7 @@ class SendHandler:
# 对于其他命令,使用默认超时 # 对于其他命令,使用默认超时
response = await self.send_message_to_napcat(action, params) response = await self.send_message_to_napcat(action, params)
# 发送响应回MaiBot # 发送响应回MoFox-Bot
await self.send_adapter_command_response(raw_message_base, response, request_id) await self.send_adapter_command_response(raw_message_base, response, request_id)
if response.get("status") == "ok": if response.get("status") == "ok":
@@ -253,7 +253,7 @@ class SendHandler:
False, False,
) )
elif seg.type == "face": elif seg.type == "face":
logger.warning("MaiBot 发送了qq原生表情暂时不支持") logger.warning("MoFox-Bot 发送了qq原生表情暂时不支持")
elif seg.type == "image": elif seg.type == "image":
image = seg.data image = seg.data
new_payload = self.build_payload(payload, self.handle_image_message(image), False) new_payload = self.build_payload(payload, self.handle_image_message(image), False)
@@ -637,7 +637,7 @@ class SendHandler:
self, original_message: MessageBase, response_data: dict, request_id: str self, original_message: MessageBase, response_data: dict, request_id: str
) -> None: ) -> None:
""" """
发送适配器命令响应回MaiBot 发送适配器命令响应回MoFox-Bot
Args: Args:
original_message: 原始消息 original_message: 原始消息

View File

@@ -5,7 +5,7 @@ __plugin_meta__ = PluginMetadata(
description="通过系统API管理插件和组件的生命周期包括加载、卸载、启用和禁用等操作。", description="通过系统API管理插件和组件的生命周期包括加载、卸载、启用和禁用等操作。",
usage="该插件提供 `plugin_management` command。", usage="该插件提供 `plugin_management` command。",
version="1.0.0", version="1.0.0",
author="MaiBot团队", author="MoFox-Bot团队",
license="GPL-v3.0-or-later", license="GPL-v3.0-or-later",
repository_url="https://github.com/MaiM-with-u/maibot", repository_url="https://github.com/MaiM-with-u/maibot",
keywords=["plugins", "components", "management", "built-in"], keywords=["plugins", "components", "management", "built-in"],

View File

@@ -5,7 +5,7 @@ __plugin_meta__ = PluginMetadata(
description="将文本转换为语音进行播放的插件,支持多种语音模式和智能语音输出场景判断。", description="将文本转换为语音进行播放的插件,支持多种语音模式和智能语音输出场景判断。",
usage="该插件提供 `tts_action` action。", usage="该插件提供 `tts_action` action。",
version="0.1.0", version="0.1.0",
author="MaiBot团队", author="MoFox-Bot团队",
license="GPL-v3.0-or-later", license="GPL-v3.0-or-later",
repository_url="https://github.com/MaiM-with-u/maibot", repository_url="https://github.com/MaiM-with-u/maibot",
keywords=["tts", "voice", "audio", "speech", "accessibility"], keywords=["tts", "voice", "audio", "speech", "accessibility"],

View File

@@ -1,5 +1,5 @@
""" """
MaiBot 端的消息切片处理模块 MoFox-Bot 端的消息切片处理模块
用于接收和重组来自 Napcat-Adapter 的切片消息 用于接收和重组来自 Napcat-Adapter 的切片消息
""" """