优化项目结构,格式化代码
This commit is contained in:
@@ -5,7 +5,6 @@ MaiZone插件独立配置文件加载系统
|
||||
它支持TOML格式的配置文件,具有配置验证、默认值处理、类型转换等功能。
|
||||
"""
|
||||
|
||||
import os
|
||||
import toml
|
||||
import shutil
|
||||
import datetime
|
||||
@@ -165,8 +164,8 @@ class MaiZoneConfigLoader:
|
||||
|
||||
def _save_config_to_file(self, config_data: Dict[str, Any]):
|
||||
"""保存配置到文件(带注释)"""
|
||||
toml_content = f"# MaiZone插件配置文件\n"
|
||||
toml_content += f"# 让你的麦麦发QQ空间说说、评论、点赞,支持AI配图、定时发送和自动监控功能\n"
|
||||
toml_content = "# MaiZone插件配置文件\n"
|
||||
toml_content += "# 让你的麦麦发QQ空间说说、评论、点赞,支持AI配图、定时发送和自动监控功能\n"
|
||||
toml_content += f"# 配置版本: {self.config_version}\n\n"
|
||||
|
||||
for section_name, section_spec in self.config_specs.items():
|
||||
@@ -187,7 +186,7 @@ class MaiZoneConfigLoader:
|
||||
if field_spec.choices:
|
||||
toml_content += f"# 可选值: {', '.join(map(str, field_spec.choices))}\n"
|
||||
if field_spec.min_value is not None or field_spec.max_value is not None:
|
||||
range_str = f"# 范围: "
|
||||
range_str = "# 范围: "
|
||||
if field_spec.min_value is not None:
|
||||
range_str += f"最小值 {field_spec.min_value}"
|
||||
if field_spec.max_value is not None:
|
||||
|
||||
@@ -2,7 +2,7 @@ import asyncio
|
||||
import random
|
||||
import time
|
||||
import traceback
|
||||
from typing import List, Dict, Any
|
||||
from typing import Dict, Any
|
||||
|
||||
from src.common.logger import get_logger
|
||||
from src.plugin_system.apis import llm_api, config_api
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import asyncio
|
||||
import random
|
||||
import time
|
||||
import traceback
|
||||
from typing import List, Tuple, Type, Union, Any, Optional
|
||||
from typing import List, Tuple, Type
|
||||
|
||||
from src.common.logger import get_logger
|
||||
from src.plugin_system import (
|
||||
@@ -88,7 +87,7 @@ class SendFeedCommand(BaseCommand):
|
||||
# 权限检查
|
||||
if not user_id or not self.check_permission(user_id):
|
||||
logger.info(f"用户 {user_id} 权限不足")
|
||||
await self.send_text(f"权限不足,无法使用此命令")
|
||||
await self.send_text("权限不足,无法使用此命令")
|
||||
return False, "权限不足", True
|
||||
|
||||
# 获取主题
|
||||
@@ -791,7 +790,7 @@ class MaiZonePlugin(BasePlugin):
|
||||
|
||||
# 初始化定时管理器
|
||||
if self.config_loader.get_config("schedule.enable_schedule", False):
|
||||
logger.info(f"定时任务启用状态: true")
|
||||
logger.info("定时任务启用状态: true")
|
||||
self.schedule_manager = ScheduleManager(self)
|
||||
asyncio.create_task(self._start_scheduler_delayed())
|
||||
|
||||
|
||||
@@ -4,13 +4,10 @@ import os
|
||||
import random
|
||||
import time
|
||||
import datetime
|
||||
import traceback
|
||||
from typing import List, Dict, Any, Optional
|
||||
from pathlib import Path
|
||||
|
||||
import httpx
|
||||
import requests
|
||||
import asyncio
|
||||
import bs4
|
||||
import json5
|
||||
|
||||
|
||||
@@ -3,15 +3,13 @@ import datetime
|
||||
import time
|
||||
import traceback
|
||||
import os
|
||||
import json
|
||||
from typing import Dict, List, Any
|
||||
from typing import Dict, Any
|
||||
|
||||
from src.common.logger import get_logger
|
||||
from src.plugin_system.apis import llm_api, config_api
|
||||
|
||||
# 导入工具模块
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.dirname(__file__))
|
||||
|
||||
from qzone_utils import QZoneManager, get_send_history
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import os
|
||||
import asyncio
|
||||
import functools
|
||||
from typing import Any, Dict, List
|
||||
from datetime import datetime, timedelta
|
||||
from exa_py import Exa
|
||||
import asyncio
|
||||
from asyncddgs import aDDGS
|
||||
|
||||
from src.common.logger import get_logger
|
||||
@@ -12,19 +10,12 @@ from typing import Tuple,Type
|
||||
from src.plugin_system import (
|
||||
BasePlugin,
|
||||
register_plugin,
|
||||
BaseAction,
|
||||
BaseCommand,
|
||||
BaseTool,
|
||||
ComponentInfo,
|
||||
ActionActivationType,
|
||||
ConfigField,
|
||||
BaseEventHandler,
|
||||
llm_api,
|
||||
EventType,
|
||||
MaiMessages,
|
||||
ToolParamType
|
||||
)
|
||||
from src.config.config import global_config
|
||||
import httpx
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
|
||||
Reference in New Issue
Block a user