Update _data_source.py

This commit is contained in:
HibiKier 2022-02-23 13:51:19 +08:00 committed by GitHub
parent 7a4e31df80
commit fc53c3c487
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,7 @@ from nonebot.adapters.onebot.v11.message import MessageSegment
from services.log import logger from services.log import logger
from configs.path_config import DATA_PATH from configs.path_config import DATA_PATH
from utils.message_builder import image from utils.message_builder import image
from utils.utils import get_bot from utils.utils import get_bot, get_matchers
from pathlib import Path from pathlib import Path
from models.group_member_info import GroupInfoUser from models.group_member_info import GroupInfoUser
from datetime import datetime from datetime import datetime
@ -187,24 +187,28 @@ def _get_plugin_status() -> MessageSegment:
""" """
rst = "\t功能\n" rst = "\t功能\n"
flag_str = "状态".rjust(4) + "\n" flag_str = "状态".rjust(4) + "\n"
for module in plugins_manager.get_data(): tmp_name = []
flag = plugins_manager.get_plugin_block_type(module) for matcher in get_matchers():
flag = flag.upper() + " CLOSE" if flag else "OPEN" if matcher.plugin_name not in tmp_name:
try: tmp_name.append(matcher.plugin_name)
plugin_name = plugins_manager.get(module)["plugin_name"] module = matcher.plugin_name
if ( flag = plugins_manager.get_plugin_block_type(module)
"[Hidden]" in plugin_name flag = flag.upper() + " CLOSE" if flag else "OPEN"
or "[Admin]" in plugin_name try:
or "[Superuser]" in plugin_name plugin_name = plugins_manager.get(module)["plugin_name"]
): if (
continue "[Hidden]" in plugin_name
rst += f"{plugin_name}" or "[Admin]" in plugin_name
except KeyError: or "[Superuser]" in plugin_name
rst += f"{module}" ):
if plugins_manager.get(module)["error"]: continue
rst += "[ERROR]" rst += f"{plugin_name}"
rst += "\n" except KeyError:
flag_str += f"{flag}\n" rst += f"{module}"
if plugins_manager.get(module)["error"]:
rst += "[ERROR]"
rst += "\n"
flag_str += f"{flag}\n"
height = len(rst.split("\n")) * 24 height = len(rst.split("\n")) * 24
a = BuildImage(250, height, font_size=20) a = BuildImage(250, height, font_size=20)
a.text((10, 10), rst) a.text((10, 10), rst)