Merge pull request #431 from forchannot/Bot

🐛 修复 pm set无效
This commit is contained in:
惜月 2023-04-23 15:07:55 +08:00 committed by GitHub
commit cf754de6bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 10 deletions

View File

@ -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):

View File

@ -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='模拟抽卡群员冷却')