mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 06:12:53 +08:00
修复webui插件无法获取修改
This commit is contained in:
parent
182f93d618
commit
d97542a3fd
@ -296,6 +296,12 @@ PS: **ARM平台** 请使用全量版 同时 **如果你的机器 RAM < 1G 可能
|
||||
|
||||
## 更新
|
||||
|
||||
* 修复webui插件无法获取修改
|
||||
|
||||
### 2022/11/22
|
||||
|
||||
* fix switch_rule [@pull/1185](https://github.com/HibiKier/zhenxun_bot/pull/1185)
|
||||
|
||||
### 2022/11/21 \[v0.1.6.5]
|
||||
|
||||
* 优化manager, hook代码
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
from pathlib import Path
|
||||
|
||||
from configs.config import Config
|
||||
import nonebot
|
||||
|
||||
@ -27,4 +29,4 @@ Config.add_plugin_config(
|
||||
default_value=5
|
||||
)
|
||||
|
||||
nonebot.load_plugins("basic_plugins/admin_bot_manage")
|
||||
nonebot.load_plugins(str((Path(__file__).parent / "admin_bot_manage").resolve()))
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
from pydantic import ValidationError
|
||||
|
||||
from configs.config import Config
|
||||
from services.log import logger
|
||||
from utils.manager import (plugins2block_manager, plugins2cd_manager,
|
||||
@ -21,15 +20,15 @@ def _(type_: Optional[str], user: User = Depends(token_to_user)) -> Result:
|
||||
"""
|
||||
global plugin_name_list
|
||||
if not plugin_name_list:
|
||||
plugin_name_list = [x.plugin_name for x in get_matchers()]
|
||||
plugin_name_list = [x.plugin_name for x in get_matchers(True)]
|
||||
plugin_list = []
|
||||
plugin_data = plugins_manager.get_data()
|
||||
for model in plugin_data:
|
||||
if model in plugin_name_list:
|
||||
try:
|
||||
data = plugin_data.get(model)
|
||||
data["model"] = model
|
||||
plugin_name = data.get("plugin_name")
|
||||
# data.model = model
|
||||
plugin_name = data.plugin_name
|
||||
if (
|
||||
(type_ == "hidden" and "[hidden]" not in plugin_name.lower())
|
||||
or (type_ == "admin" and "[admin]" not in plugin_name.lower())
|
||||
@ -47,29 +46,29 @@ def _(type_: Optional[str], user: User = Depends(token_to_user)) -> Result:
|
||||
continue
|
||||
data = {"model": model}
|
||||
if x := plugin_data.get(model):
|
||||
if not x.get("status") and x.get("block_type") in [
|
||||
if not x.status and x.block_type in [
|
||||
"group",
|
||||
"private",
|
||||
"all",
|
||||
]:
|
||||
x["block_type"] = (
|
||||
x.block_type = (
|
||||
"群聊"
|
||||
if x["block_type"] == "group"
|
||||
if x.block_type == "group"
|
||||
else "私聊"
|
||||
if x["block_type"] == "private"
|
||||
if x.block_type == "private"
|
||||
else "全部"
|
||||
)
|
||||
data["plugin_manager"] = PluginManager(**x)
|
||||
data["plugin_manager"] = PluginManager(**x.dict())
|
||||
if x := plugins2settings_manager.get(model):
|
||||
if x.cmd and isinstance(x.cmd, list):
|
||||
x.cmd = ",".join(x.cmd)
|
||||
data["plugin_settings"] = PluginSettings(**x)
|
||||
data["plugin_settings"] = PluginSettings(**x.dict())
|
||||
if x := plugins2cd_manager.get(model):
|
||||
data["cd_limit"] = CdLimit(**x)
|
||||
data["cd_limit"] = CdLimit(**x.dict())
|
||||
if x := plugins2block_manager.get(model):
|
||||
data["block_limit"] = BlockLimit(**x)
|
||||
data["block_limit"] = BlockLimit(**x.dict())
|
||||
if x := plugins2count_manager.get(model):
|
||||
data["count_limit"] = CountLimit(**x)
|
||||
data["count_limit"] = CountLimit(**x.dict())
|
||||
if x := Config.get(model):
|
||||
id_ = 0
|
||||
tmp = []
|
||||
@ -148,10 +147,10 @@ def _(plugin: Plugin, user: User = Depends(token_to_user)) -> Result:
|
||||
for key, value in plugin.plugin_settings:
|
||||
if key == "cmd":
|
||||
value = value.split(",")
|
||||
plugins2settings_manager.set_module_data(plugin.model, key, value)
|
||||
setattr(plugins2settings_manager[plugin.model], key, value)
|
||||
if plugin.plugin_manager:
|
||||
for key, value in plugin.plugin_manager:
|
||||
plugins_manager.set_module_data(plugin.model, key, value)
|
||||
setattr(plugins_manager[plugin.model], key, value)
|
||||
except Exception as e:
|
||||
logger.error(
|
||||
f"WEB_UI POST /webui/plugins model:{plugin.model} 发生错误 {type(e)}:{e}"
|
||||
@ -160,4 +159,6 @@ def _(plugin: Plugin, user: User = Depends(token_to_user)) -> Result:
|
||||
code=500,
|
||||
data=f"WEB_UI POST /webui/plugins model:{plugin.model} 发生错误 {type(e)}:{e}",
|
||||
)
|
||||
plugins2settings_manager.save()
|
||||
plugins_manager.save()
|
||||
return Result(code=200, data="修改成功!")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user