Merge branch 'dev' of https://github.com/MoFox-Studio/MoFox-Core into dev
This commit is contained in:
8
bot.py
8
bot.py
@@ -296,8 +296,10 @@ class DatabaseManager:
|
|||||||
# 使用线程执行器运行潜在的阻塞操作
|
# 使用线程执行器运行潜在的阻塞操作
|
||||||
await initialize_sql_database()
|
await initialize_sql_database()
|
||||||
elapsed_time = time.time() - start_time
|
elapsed_time = time.time() - start_time
|
||||||
|
|
||||||
|
db_type = global_config.database.database_type if global_config else "unknown"
|
||||||
logger.info(
|
logger.info(
|
||||||
f"数据库连接初始化成功,使用 {global_config.database.database_type} 数据库,耗时: {elapsed_time:.2f}秒"
|
f"数据库连接初始化成功,使用 {db_type} 数据库,耗时: {elapsed_time:.2f}秒"
|
||||||
)
|
)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@@ -321,6 +323,10 @@ class ConfigurationValidator:
|
|||||||
try:
|
try:
|
||||||
from src.config.config import global_config
|
from src.config.config import global_config
|
||||||
|
|
||||||
|
if global_config is None:
|
||||||
|
logger.error("全局配置未初始化")
|
||||||
|
return False
|
||||||
|
|
||||||
# 检查必要的配置节
|
# 检查必要的配置节
|
||||||
required_sections = ["database", "bot"]
|
required_sections = ["database", "bot"]
|
||||||
for section in required_sections:
|
for section in required_sections:
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from src.common.logger import get_logger
|
|||||||
egg = get_logger("小彩蛋")
|
egg = get_logger("小彩蛋")
|
||||||
|
|
||||||
|
|
||||||
def weighted_choice(data: Sequence[str], weights: list[float] | None = None) -> str:
|
def weighted_choice(data: Sequence[str], weights: Sequence[float] | None = None) -> str:
|
||||||
"""
|
"""
|
||||||
从 data 中按权重随机返回一条。
|
从 data 中按权重随机返回一条。
|
||||||
若 weights 为 None,则所有元素权重默认为 1。
|
若 weights 为 None,则所有元素权重默认为 1。
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import time
|
|||||||
import traceback
|
import traceback
|
||||||
from collections.abc import Callable, Coroutine
|
from collections.abc import Callable, Coroutine
|
||||||
from random import choices
|
from random import choices
|
||||||
from typing import Any
|
from typing import Any, cast
|
||||||
|
|
||||||
from rich.traceback import install
|
from rich.traceback import install
|
||||||
|
|
||||||
@@ -172,6 +172,9 @@ class MainSystem:
|
|||||||
logger.warning(f"{calc_name} 不是 BaseInterestCalculator 的有效子类")
|
logger.warning(f"{calc_name} 不是 BaseInterestCalculator 的有效子类")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# 显式转换类型以修复 Pyright 错误
|
||||||
|
component_class = cast(type[BaseInterestCalculator], component_class)
|
||||||
|
|
||||||
# 创建组件实例
|
# 创建组件实例
|
||||||
calculator_instance = component_class()
|
calculator_instance = component_class()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user