2026-10-21 18:35:16 +08:00
|
|
|
"""普通 NoneBot 配置;不依赖真寻配置系统。"""
|
|
|
|
|
|
2026-10-26 11:34:00 +08:00
|
|
|
from typing import Literal
|
2026-10-21 18:35:16 +08:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
2026-10-26 11:34:00 +08:00
|
|
|
from pydantic import BaseModel, Field, conint, validator
|
2026-10-21 18:35:16 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class Config(BaseModel):
|
|
|
|
|
"""农场启动配置。"""
|
|
|
|
|
|
|
|
|
|
farm_deployment: str = Field(
|
|
|
|
|
"nonebot", min_length=1, description="农场存档部署标识",
|
|
|
|
|
)
|
2026-10-26 11:34:00 +08:00
|
|
|
farm_data_dir: Path | None = Field(
|
|
|
|
|
None, description='兼容旧部署的数据目录;未设置时使用平台默认目录',
|
|
|
|
|
)
|
2026-10-21 18:35:16 +08:00
|
|
|
farm_image_format: Literal["AUTO", "JPEG", "PNG"] = Field(
|
|
|
|
|
"AUTO", description="图片格式,AUTO 优先使用压缩 JPEG",
|
|
|
|
|
)
|
2026-10-22 18:33:42 +08:00
|
|
|
farm_image_quality: conint(strict=True, ge=1, le=95) = Field(
|
|
|
|
|
75,
|
|
|
|
|
description="全部农场图片编码质量;仅我的农场高清时至少85",
|
|
|
|
|
)
|
2026-10-23 19:12:16 +08:00
|
|
|
farm_resource_source: Literal['Github', 'Gitea', 'farm_service'] = Field(
|
|
|
|
|
'Github', description='资源获取地址,修改后重载插件',
|
|
|
|
|
)
|
|
|
|
|
farm_service_url: str = Field(
|
|
|
|
|
'', description='farm_service 地址,独立供资源及活动服务使用',
|
|
|
|
|
)
|
2026-10-26 11:34:00 +08:00
|
|
|
|
|
|
|
|
@validator('farm_data_dir', pre=True)
|
|
|
|
|
def empty_data_directory(cls, value):
|
|
|
|
|
return None if value == '' else value
|