mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
* 🐛 修复添加插件依赖更新 * 🔧 修改插件依赖安装命令为使用poetry运行pip * 🐛 修复群组入群与退群提示 * 🐛 修复群组踢出用户提醒 * 🎨 代码优化 * 🎨 群欢迎迁移优化 * 🩹 精确webui调用统计 * 🚨 auto fix by pre-commit hooks * 🐛 修复测试 * 🎨 fix pre-commit.ci * 🎨 fix pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
60 lines
1.4 KiB
Python
60 lines
1.4 KiB
Python
from dataclasses import field
|
|
from pathlib import Path
|
|
|
|
import nonebot
|
|
from pydantic import BaseModel
|
|
|
|
from .utils import ConfigsManager
|
|
|
|
__all__ = ["BotConfig", "Config"]
|
|
|
|
|
|
class BotSetting(BaseModel):
|
|
self_nickname: str = ""
|
|
"""回复时NICKNAME"""
|
|
system_proxy: str | None = None
|
|
"""系统代理"""
|
|
db_url: str = ""
|
|
"""数据库链接"""
|
|
platform_superusers: dict[str, list[str]] = field(default_factory=dict)
|
|
"""平台超级用户"""
|
|
qbot_id_data: dict[str, str] = field(default_factory=dict)
|
|
"""官bot id:账号id"""
|
|
|
|
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)
|