Files
zhenxun_bot/zhenxun/configs/config.py
Copaan 5596497947 bugfix:修复notice事件扩散问题 (#2132)
* bugfix:修复notice事件扩散问题

* 优化并发调度

* bugfix:修复签到样式

* bugfix:功能调用统计修复

* bugfix:修复私聊时功能调用统计显示已退群问题

* 提高插件适配兼容性

* 优化发送队列

* 修改权限检查设计

* 继续修改权限检查设计

* 完善权限检查设计

* 优化sqlite配置

* 优化数据库初始化

* 代码整理,无用代码清理

* bugfix:修复启动时数据库校验问题

* bugfix:修复预算裁剪过于激进问题
2026-05-28 22:57:28 +08:00

63 lines
1.6 KiB
Python

from pathlib import Path
import nonebot
from pydantic import BaseModel, Field
from .utils import ConfigsManager
__all__ = ["BotConfig", "Config"]
class BotSetting(BaseModel):
self_nickname: str = ""
"""回复时NICKNAME"""
system_proxy: str | None = None
"""系统代理"""
db_url: str = ""
"""数据库链接, 默认值为sqlite:data/zhenxun.db"""
platform_superusers: dict[str, list[str]] = Field(default_factory=dict)
"""平台超级用户"""
qbot_id_data: dict[str, str] = Field(default_factory=dict)
"""官bot id:账号id"""
ext_path: list[str] = Field(default_factory=list)
"""第三方插件路径"""
qq_adapter_load: bool = False
"""是否加载 QQ 官方适配器"""
def get_qbot_uid(self, qbot_id: str) -> str | None:
"""获取官bot账号id
参数:
qbot_id: 官bot id
返回:
str: 账号id
"""
return self.qbot_id_data.get(qbot_id)
def get_superuser(self, platform: str) -> list[str]:
"""获取超级用户
参数:
platform: 对应平台
返回:
list[str]: 超级用户id
"""
if self.platform_superusers:
return self.platform_superusers.get(platform, [])
return []
def get_sql_type(self) -> str:
"""获取数据库类型
返回:
str: 数据库类型, postgres, mysql, sqlite
"""
return self.db_url.split(":", 1)[0] if self.db_url else ""
Config = ConfigsManager(Path() / "data" / "configs" / "plugins2config.yaml")
BotConfig = nonebot.get_plugin_config(BotSetting)