Files
zhenxun_bot/zhenxun/configs/config.py
T

39 lines
916 B
Python
Raw Normal View History

2024-08-24 19:32:52 +08:00
import random
2021-11-04 16:11:50 +08:00
from pathlib import Path
2024-08-24 19:32:52 +08:00
import nonebot
from pydantic import BaseModel
2021-08-06 19:42:02 +08:00
2024-08-24 19:32:52 +08:00
from .utils import ConfigsManager
2024-08-24 17:06:23 +08:00
2024-08-24 19:32:52 +08:00
class BotSetting(BaseModel):
2024-08-24 17:06:23 +08:00
2024-08-24 19:32:52 +08:00
self_nickname: str = ""
"""回复时NICKNAME"""
system_proxy: str | None = None
"""系统代理"""
db_url: str = ""
"""数据库链接"""
platform_superusers: dict[str, list[str]] = {}
"""平台超级用户"""
2024-08-24 17:06:23 +08:00
2024-08-24 19:32:52 +08:00
def get_superuser(self, platform: str) -> str:
"""获取超级用户
2024-08-24 17:06:23 +08:00
2024-08-24 19:32:52 +08:00
参数:
platform: 对应平台
2024-08-24 17:06:23 +08:00
2024-08-24 19:32:52 +08:00
返回:
str | None: 超级用户id
"""
if self.platform_superusers:
if platform_superuser := self.platform_superusers.get(platform):
return random.choice(platform_superuser)
return ""
2021-05-20 18:37:51 +08:00
2021-11-04 16:11:50 +08:00
Config = ConfigsManager(Path() / "data" / "configs" / "plugins2config.yaml")
2024-08-24 17:06:23 +08:00
2024-08-24 19:32:52 +08:00
BotConfig = nonebot.get_plugin_config(BotSetting)