2022-04-04 20:33:37 +08:00
|
|
|
from configs.config import Config as gConfig
|
2022-04-05 13:14:29 +08:00
|
|
|
from .api import *
|
2022-04-04 20:33:37 +08:00
|
|
|
from .auth import *
|
2022-06-19 16:44:37 +08:00
|
|
|
from nonebot.matcher import Matcher
|
|
|
|
|
from nonebot.message import run_preprocessor, IgnoredException
|
|
|
|
|
from utils.manager import plugins2settings_manager
|
|
|
|
|
from nonebot.typing import T_State
|
|
|
|
|
from nonebot.adapters.onebot.v11 import (
|
|
|
|
|
Bot,
|
|
|
|
|
MessageEvent
|
|
|
|
|
)
|
2022-04-04 20:33:37 +08:00
|
|
|
|
|
|
|
|
|
2022-06-19 16:44:37 +08:00
|
|
|
gConfig.add_plugin_config("web-ui", "username", "admin", name="web-ui", help_="前端管理用户名")
|
2022-04-04 20:33:37 +08:00
|
|
|
|
2022-06-19 16:44:37 +08:00
|
|
|
gConfig.add_plugin_config("web-ui", "password", None, name="web-ui", help_="前端管理密码")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 使用webui访问api后plugins2settings中的cmd字段将从list变为str
|
|
|
|
|
# 暂时找不到原因
|
|
|
|
|
# 先使用hook修复
|
|
|
|
|
@run_preprocessor
|
|
|
|
|
async def _(matcher: Matcher, bot: Bot, event: MessageEvent, state: T_State):
|
2022-06-20 21:54:10 +08:00
|
|
|
flag = False
|
2022-06-19 16:44:37 +08:00
|
|
|
for module in plugins2settings_manager.keys():
|
|
|
|
|
if isinstance(plugins2settings_manager.get_plugin_data(module).get("cmd"), str):
|
|
|
|
|
plugins2settings_manager.set_module_data(
|
|
|
|
|
module,
|
|
|
|
|
"cmd",
|
|
|
|
|
plugins2settings_manager.get_plugin_data(module).get("cmd").split(","),
|
2022-06-20 21:54:10 +08:00
|
|
|
False
|
2022-06-19 16:44:37 +08:00
|
|
|
)
|
2022-06-20 21:54:10 +08:00
|
|
|
flag = True
|
|
|
|
|
if flag:
|
|
|
|
|
plugins2settings_manager.save()
|
|
|
|
|
|