fix(qqpush): 修复token配置读取导致的404
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
"""Danding_QqPush 插件配置模块"""
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class Config(BaseModel):
|
||||
"""插件配置"""
|
||||
|
||||
Token: str = ""
|
||||
"""API 访问 Token,用于鉴权(必须在 .env 中配置 DANDING_QQPUSH_TOKEN)"""
|
||||
"""Danding_QqPush 插件配置模块"""
|
||||
import os
|
||||
|
||||
from pydantic import BaseModel, model_validator
|
||||
|
||||
|
||||
class Config(BaseModel):
|
||||
"""插件配置"""
|
||||
|
||||
Token: str = "danding-8HkL9xQ2"
|
||||
"""API 访问 Token,用于鉴权(必须在 .env 中配置 DANDING_QQPUSH_TOKEN)"""
|
||||
|
||||
# 图片生成配置
|
||||
ImageWidth: int = 800
|
||||
@@ -32,9 +34,27 @@ class Config(BaseModel):
|
||||
"""最大文本长度(字符数),超过将截断"""
|
||||
|
||||
# 字体路径配置
|
||||
FontPaths: list = ("/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc",
|
||||
"/usr/share/fonts/wqy-microhei/wqy-microhei.ttc",
|
||||
"/usr/share/fonts/wqy-zenhei/wqy-zenhei.ttc",
|
||||
"C:/Windows/Fonts/msyh.ttc",
|
||||
"C:/Windows/Fonts/simhei.ttf",)
|
||||
"""字体文件路径列表"""
|
||||
FontPaths: list = ("/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc",
|
||||
"/usr/share/fonts/wqy-microhei/wqy-microhei.ttc",
|
||||
"/usr/share/fonts/wqy-zenhei/wqy-zenhei.ttc",
|
||||
"C:/Windows/Fonts/msyh.ttc",
|
||||
"C:/Windows/Fonts/simhei.ttf",)
|
||||
"""字体文件路径列表"""
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def load_token_aliases(cls, values):
|
||||
"""兼容 NoneBot 配置和环境变量中的 QQPush Token 命名。"""
|
||||
if not isinstance(values, dict):
|
||||
return values
|
||||
|
||||
token = (
|
||||
values.get("Token")
|
||||
or values.get("token")
|
||||
or values.get("DANDING_QQPUSH_TOKEN")
|
||||
or values.get("danding_qqpush_token")
|
||||
or os.getenv("DANDING_QQPUSH_TOKEN")
|
||||
)
|
||||
if token:
|
||||
values["Token"] = token
|
||||
return values
|
||||
|
||||
Reference in New Issue
Block a user