优化自动化
This commit is contained in:
@@ -39,6 +39,7 @@ class ProxyConfig:
|
||||
api_url: str
|
||||
batch_size: int
|
||||
check_interval: int
|
||||
api_proxy: Optional[str] = None
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -52,6 +53,20 @@ class EmailConfig:
|
||||
file_path: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class ServerConfig:
|
||||
hostname: str
|
||||
description: Optional[str] = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class AutoServiceConfig:
|
||||
check_interval: int = 60
|
||||
upload_interval: int = 300
|
||||
email_check_threshold: int = 30
|
||||
email_fetch_count: int = 2
|
||||
|
||||
|
||||
@dataclass
|
||||
class CapsolverConfig:
|
||||
api_key: str
|
||||
@@ -83,6 +98,9 @@ class Config:
|
||||
register_config: RegisterConfig = None
|
||||
email_config: EmailConfig = None
|
||||
captcha_config: CaptchaConfig = None
|
||||
server_config: Optional[ServerConfig] = None
|
||||
auto_service_config: Optional[AutoServiceConfig] = None
|
||||
hostname: Optional[str] = None # 向后兼容
|
||||
|
||||
@classmethod
|
||||
def from_yaml(cls, path: str = "config.yaml"):
|
||||
@@ -112,7 +130,18 @@ class Config:
|
||||
proxy_config = ProxyConfig(**data.get('proxy', {})) if 'proxy' in data else None
|
||||
register_config = RegisterConfig(**data.get('register', {})) if 'register' in data else None
|
||||
email_config = EmailConfig(**data.get('email', {})) if 'email' in data else None
|
||||
|
||||
|
||||
# 创建服务器配置对象
|
||||
server_config = ServerConfig(**data.get('server_config', {})) if 'server_config' in data else None
|
||||
|
||||
# 创建自动服务配置对象
|
||||
auto_service_config = AutoServiceConfig(**data.get('auto_service', {})) if 'auto_service' in data else None
|
||||
|
||||
# 设置hostname (优先使用server_config中的hostname)
|
||||
hostname = None
|
||||
if server_config and hasattr(server_config, 'hostname'):
|
||||
hostname = server_config.hostname
|
||||
|
||||
return cls(
|
||||
global_config=global_config,
|
||||
database_config=db_config,
|
||||
@@ -120,5 +149,8 @@ class Config:
|
||||
proxy_config=proxy_config,
|
||||
register_config=register_config,
|
||||
email_config=email_config,
|
||||
captcha_config=captcha_config
|
||||
captcha_config=captcha_config,
|
||||
server_config=server_config,
|
||||
auto_service_config=auto_service_config,
|
||||
hostname=hostname
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user