mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-Nonebot.git
synced 2026-04-01 22:04:51 +00:00
Merge remote-tracking branch 'SanYeCao-Nonebot/master'
This commit is contained in:
commit
8053ddd71c
3 changed files with 76 additions and 0 deletions
49
src/configs/config.py
Normal file
49
src/configs/config.py
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
from pathlib import Path
|
||||||
|
import nonebot
|
||||||
|
from collections import defaultdict
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
class BotSetting(BaseModel):
|
||||||
|
""""
|
||||||
|
Bot 配置
|
||||||
|
"""
|
||||||
|
#数据库链接
|
||||||
|
db_url: str = "sqlite://./chat_bot.db"
|
||||||
|
# 超级用户
|
||||||
|
platform_superusers = {"QQ": [""]}
|
||||||
|
#官bot id:账号id
|
||||||
|
bot_id_data = {"BOT_ACCOUNT":"bot1","BOT_APPID": "user1",}
|
||||||
|
|
||||||
|
def get_bot_uid(self, bot_id: str) -> str | None:
|
||||||
|
"""获取官bot账号id
|
||||||
|
|
||||||
|
参数:
|
||||||
|
bot_id: 官bot id
|
||||||
|
|
||||||
|
返回:
|
||||||
|
str: 账号id
|
||||||
|
"""
|
||||||
|
return self.bot_id_data.get(bot_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 ""
|
||||||
|
|
||||||
27
src/configs/path_config.py
Normal file
27
src/configs/path_config.py
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# 图片路径
|
||||||
|
IMAGE_PATH = Path() / "resources" / "image"
|
||||||
|
# 语音路径
|
||||||
|
RECORD_PATH = Path() / "resources" / "record"
|
||||||
|
# 文本路径
|
||||||
|
TEXT_PATH = Path() / "resources" / "text"
|
||||||
|
# 日志路径
|
||||||
|
LOG_PATH = Path() / "log"
|
||||||
|
# 字体路径
|
||||||
|
FONT_PATH = Path() / "resources" / "font"
|
||||||
|
# 数据路径
|
||||||
|
DATA_PATH = Path() / "data"
|
||||||
|
# 临时数据路径
|
||||||
|
TEMP_PATH = Path() / "resources" / "temp"
|
||||||
|
# 网页模板路径
|
||||||
|
TEMPLATE_PATH = Path() / "resources" / "template"
|
||||||
|
|
||||||
|
|
||||||
|
IMAGE_PATH.mkdir(parents=True, exist_ok=True)
|
||||||
|
RECORD_PATH.mkdir(parents=True, exist_ok=True)
|
||||||
|
TEXT_PATH.mkdir(parents=True, exist_ok=True)
|
||||||
|
LOG_PATH.mkdir(parents=True, exist_ok=True)
|
||||||
|
FONT_PATH.mkdir(parents=True, exist_ok=True)
|
||||||
|
DATA_PATH.mkdir(parents=True, exist_ok=True)
|
||||||
|
TEMP_PATH.mkdir(parents=True, exist_ok=True)
|
||||||
0
src/configs/utils/__init__.py
Normal file
0
src/configs/utils/__init__.py
Normal file
Loading…
Reference in a new issue