From ab8f5100a8e3bfd1085c8fb4b9311311499eb886 Mon Sep 17 00:00:00 2001 From: forchannot Date: Sun, 23 Apr 2023 00:20:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20pm=20set=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LittlePaimon/config/config/manage.py | 26 +++++++++++++++++--------- LittlePaimon/config/config/model.py | 2 +- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/LittlePaimon/config/config/manage.py b/LittlePaimon/config/config/manage.py index 4d581cd..69bc76f 100644 --- a/LittlePaimon/config/config/manage.py +++ b/LittlePaimon/config/config/manage.py @@ -18,16 +18,24 @@ class ConfigManager: :param value: 新配置值 """ if config_name not in cls.config.dict(by_alias=True).keys(): - return f'没有配置项为{config_name}' - if '启用' in config_name or '开关' in config_name or config_name in {'自动接受好友请求', '自动接受群邀请'}: - if value not in ['开', '关', 'true', 'false', 'on', 'off']: - return '参数错误' - value = value in ['开', 'true', 'on'] - elif config_name != 'CookieWeb地址' and not value.isdigit(): - return '配置项不合法,必须为数字' - cls.config.update(config_name=value) + return f"没有配置项为{config_name}" + if ( + "启用" in config_name + or "开关" in config_name + or config_name in {"自动接受好友请求", "自动接受群邀请", "绑定二维码以链接形式发送"} + ): + if value not in ["开", "关", "true", "false", "on", "off"]: + return "参数错误" + value = value in ["开", "true", "on"] + elif config_name == "重启时修改群名片群列表": + return "该配置项暂时不支持此方法修改,请在后台管理页面进行更改" + elif config_name not in ["CookieWeb地址", "Web端管理员密码", "Web端token密钥", "github资源地址"]: + if not value.isdigit(): + return "配置项不合法,必须为数字" + value = int(value) + cls.config.update(**{config_name: value}) cls.save() - return f'成功设置{config_name}为{value}' + return f"成功设置{config_name}为{value}" @classmethod def save(cls): diff --git a/LittlePaimon/config/config/model.py b/LittlePaimon/config/config/model.py index b5358ee..4eed3bf 100644 --- a/LittlePaimon/config/config/model.py +++ b/LittlePaimon/config/config/model.py @@ -9,7 +9,7 @@ class ConfigModel(BaseModel): qrcode_bind_use_url: bool = Field(False, alias='绑定二维码以链接形式发送') img_use_cache: bool = Field(True, alias='图片资源缓存开关') - reboot_card_enable: List[int] = Field([], alias='启用重启时修改群名片群列表') + reboot_card_enable: List[int] = Field([], alias='重启时修改群名片群列表') sim_gacha_cd_group: int = Field(30, alias='模拟抽卡群冷却') sim_gacha_cd_member: int = Field(60, alias='模拟抽卡群员冷却')