抽象send方法,添加注释
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
"""
|
||||
配置加载模块
|
||||
|
||||
负责读取和解析 config.toml 配置文件,提供全局配置对象。
|
||||
"""
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict
|
||||
|
||||
@@ -5,12 +10,26 @@ import tomllib
|
||||
|
||||
|
||||
class Config:
|
||||
"""
|
||||
配置加载类,负责读取和解析 config.toml 文件
|
||||
"""
|
||||
|
||||
def __init__(self, file_path: str = "config.toml"):
|
||||
"""
|
||||
初始化配置加载器
|
||||
|
||||
:param file_path: 配置文件路径,默认为 "config.toml"
|
||||
"""
|
||||
self.path = Path(file_path)
|
||||
self._data: Dict[str, Any] = {}
|
||||
self.load()
|
||||
|
||||
def load(self):
|
||||
"""
|
||||
加载配置文件
|
||||
|
||||
:raises FileNotFoundError: 如果配置文件不存在
|
||||
"""
|
||||
if not self.path.exists():
|
||||
raise FileNotFoundError(f"配置文件 {self.path} 未找到!")
|
||||
|
||||
@@ -20,14 +39,29 @@ class Config:
|
||||
# 通过属性访问配置
|
||||
@property
|
||||
def napcat_ws(self) -> dict:
|
||||
"""
|
||||
获取 NapCat WebSocket 配置
|
||||
|
||||
:return: 配置字典
|
||||
"""
|
||||
return self._data.get("napcat_ws", {})
|
||||
|
||||
@property
|
||||
def bot(self) -> dict:
|
||||
"""
|
||||
获取 Bot 基础配置
|
||||
|
||||
:return: 配置字典
|
||||
"""
|
||||
return self._data.get("bot", {})
|
||||
|
||||
@property
|
||||
def features(self) -> dict:
|
||||
"""
|
||||
获取功能特性配置
|
||||
|
||||
:return: 配置字典
|
||||
"""
|
||||
return self._data.get("features", {})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user