调整日志级别
This commit is contained in:
1
main.py
1
main.py
@@ -85,6 +85,7 @@ def main():
|
||||
except Exception as e:
|
||||
robot.LOG.error(f"GlancesMonitor服务器启动失败: {e}")
|
||||
|
||||
robot.LOG.info(f"=" * 30)
|
||||
asyncio.run(async_job.run_all())
|
||||
# 让机器人一直跑
|
||||
robot.keep_running_and_block_process()
|
||||
|
||||
@@ -85,7 +85,7 @@ class AIAutoResponsePlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ class AIGenImagePlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ class BeautyLegPlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ class DifyPlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ class DouyinParserPlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ class DuanjuSearchPlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class FanhaoSearchPlugin(MessagePluginInterface):
|
||||
return True
|
||||
|
||||
def start(self) -> bool:
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ class GameTaskPlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ class GlobalNewsPlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ class GroupAutoInvitePlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class GroupMemberChangePlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
@@ -56,7 +56,7 @@ class GroupMemberChangePlugin(MessagePluginInterface):
|
||||
"""初始化插件"""
|
||||
self.LOG.debug(f"正在初始化 {self.name} 插件...")
|
||||
|
||||
self.LOG.info(f"{self.name} 插件初始化完成")
|
||||
self.LOG.debug(f"{self.name} 插件初始化完成")
|
||||
return True
|
||||
|
||||
def can_process(self, message: Dict[str, Any]) -> bool:
|
||||
|
||||
@@ -74,12 +74,12 @@ class GroupVirtualPlugin(MessagePluginInterface):
|
||||
# 从Redis加载数据
|
||||
self.data = self.group_virtual_redis.load_chat_groups()
|
||||
|
||||
self.LOG.info(f"[{self.name}] 插件初始化完成")
|
||||
self.LOG.debug(f"[{self.name}] 插件初始化完成")
|
||||
return True
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ class GuessSongPlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ class JDTokenPlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ class LuckyPotPlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ class MessagePushTask(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ class MessageSignPlugin(MessagePluginInterface):
|
||||
with open(self.vocab_file_path, 'r', encoding='utf-8') as f:
|
||||
lines = f.readlines()
|
||||
self.vocab_list = [line.strip() for line in lines if line.strip()]
|
||||
self.LOG.info(f"成功加载词汇表,共 {len(self.vocab_list)} 个单词")
|
||||
self.LOG.debug(f"成功加载词汇表,共 {len(self.vocab_list)} 个单词")
|
||||
else:
|
||||
self.LOG.error(f"词汇表文件不存在: {self.vocab_file_path}")
|
||||
except Exception as e:
|
||||
@@ -137,7 +137,7 @@ class MessageSignPlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ class MessageSummaryPlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ class MusicPlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class PluginManagerPlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ class PointTradePlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ class RobotMenuPlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ class StatsCollectorPlugin(PluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ class VideoPlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ class VideoManPlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ class WeatherPlugin(MessagePluginInterface):
|
||||
return True
|
||||
|
||||
def start(self) -> bool:
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ class XiurenImagePlugin(MessagePluginInterface):
|
||||
|
||||
def start(self) -> bool:
|
||||
"""启动插件"""
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
@@ -375,7 +375,7 @@ class XiuxianPlugin(MessagePluginInterface):
|
||||
# 境界顺序(用于计算下一个境界)
|
||||
realm_order = ["炼气", "筑基", "金丹", "元婴", "化神", "合体", "大乘", "渡劫", "真仙"]
|
||||
|
||||
self.LOG.info(f"开始解析境界配置,共{len(realms_cfg)}个境界")
|
||||
self.LOG.debug(f"开始解析境界配置,共{len(realms_cfg)}个境界")
|
||||
for realm_name, config_str in realms_cfg.items():
|
||||
try:
|
||||
# 解析配置:每层阈值,境界分值,突破丹药,丹药成功率,强行成功率,强行倍率
|
||||
@@ -434,12 +434,12 @@ class XiuxianPlugin(MessagePluginInterface):
|
||||
except Exception as e:
|
||||
self.LOG.warning(f"解析境界配置失败: {realm_name}={config_str}, 错误: {e}")
|
||||
|
||||
self.LOG.info(f"境界配置解析完成:层级阈值{len(self.layer_threshold_map)}个,突破配置{len(self.break_config)}个")
|
||||
self.LOG.debug(f"境界配置解析完成:层级阈值{len(self.layer_threshold_map)}个,突破配置{len(self.break_config)}个")
|
||||
self.LOG.debug(f"[{self.name}] 插件初始化完成,指令:{self._commands}")
|
||||
return True
|
||||
|
||||
def start(self) -> bool:
|
||||
self.LOG.info(f"[{self.name}] 插件已启动")
|
||||
self.LOG.debug(f"[{self.name}] 插件已启动")
|
||||
self.status = PluginStatus.RUNNING
|
||||
return True
|
||||
|
||||
|
||||
15
robot.py
15
robot.py
@@ -47,6 +47,7 @@ class Robot:
|
||||
self.config = config
|
||||
self.LOG = logger
|
||||
|
||||
self.LOG.info(f"="*30)
|
||||
# wechat_ipad 相关属性
|
||||
self.ipad_bot: WechatAPIClient
|
||||
self.ipad_config = None
|
||||
@@ -58,13 +59,13 @@ class Robot:
|
||||
self.alias = None
|
||||
self.phone = None
|
||||
self.message_auto_revoke: MessageAutoRevoke = None
|
||||
self.LOG.info(f"DB+REDIS 连接池开始初始化")
|
||||
self.LOG.debug(f"DB+REDIS 连接池开始初始化")
|
||||
# 使用单例模式获取实例
|
||||
self.db_manager = DBConnectionManager.get_instance(
|
||||
mysql_config=self.config.mariadb,
|
||||
redis_config=self.config.redis
|
||||
)
|
||||
self.LOG.info(f"数据库连接管理器初始化完成")
|
||||
self.LOG.debug(f"数据库连接管理器初始化完成")
|
||||
|
||||
# 为了兼容现有代码,保留原有的连接池
|
||||
self.db_pool = self.db_manager.mysql_pool
|
||||
@@ -78,7 +79,7 @@ class Robot:
|
||||
self.groups = {} # 存储按group_id分组的消息列表,每个group_id最多保留10条消息
|
||||
|
||||
# 初始化插件系统
|
||||
self.LOG.info("开始初始化插件系统...")
|
||||
self.LOG.debug("开始初始化插件系统...")
|
||||
self.plugin_registry = PluginRegistry()
|
||||
self.event_system = EventSystem()
|
||||
self.plugin_modules = {} # 存储已加载的插件模块
|
||||
@@ -97,7 +98,7 @@ class Robot:
|
||||
self.plugins = self.plugin_manager.load_all_plugins()
|
||||
|
||||
# 加载插件
|
||||
self.LOG.info("插件系统初始化完成")
|
||||
self.LOG.debug("插件系统初始化完成")
|
||||
|
||||
GroupBotManager.load_local_cache()
|
||||
# 权限模块加载
|
||||
@@ -117,7 +118,7 @@ class Robot:
|
||||
with open("wechat_ipad/config.toml", "rb") as f:
|
||||
self.ipad_config = tomllib.load(f)
|
||||
|
||||
self.LOG.info("正在初始化wechat_ipad客户端...")
|
||||
self.LOG.debug("正在初始化wechat_ipad客户端...")
|
||||
|
||||
# 检查必要的配置
|
||||
server_url = self.ipad_config.get("server_url", "")
|
||||
@@ -139,7 +140,7 @@ class Robot:
|
||||
)
|
||||
self.ipad_thread.start()
|
||||
|
||||
self.LOG.info("wechat_ipad客户端初始化完成")
|
||||
self.LOG.debug("wechat_ipad客户端初始化完成")
|
||||
return True
|
||||
except Exception as e:
|
||||
self.LOG.error(f"初始化wechat_ipad客户端失败: {e}")
|
||||
@@ -153,7 +154,7 @@ class Robot:
|
||||
async def _wechat_ipad_core(self, server_ip, server_port):
|
||||
"""wechat_ipad核心逻辑,基于bot-core.py"""
|
||||
try:
|
||||
self.LOG.info("启动wechat_ipad bot")
|
||||
self.LOG.debug("启动wechat_ipad bot")
|
||||
# 调用登录接口
|
||||
self.ipad_bot = wechat_ipad.WechatAPIClient(server_ip, server_port)
|
||||
self.message_auto_revoke = MessageAutoRevoke(self.ipad_bot)
|
||||
|
||||
Reference in New Issue
Block a user