Skip to content

Commit

Permalink
🐛 过滤父插件
Browse files Browse the repository at this point in the history
  • Loading branch information
HibiKier committed Sep 7, 2024
1 parent 807b2f6 commit 62fd93c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
16 changes: 12 additions & 4 deletions zhenxun/builtin_plugins/admin/plugin_switch/_data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ async def set_default_status(cls, plugin_name: str, status: bool) -> str:
if plugin_name.isdigit():
plugin = await PluginInfo.get_or_none(id=int(plugin_name))
else:
plugin = await PluginInfo.get_or_none(name=plugin_name, load_status=True)
plugin = await PluginInfo.get_or_none(
name=plugin_name, load_status=True, plugin_type__not=PluginType.PARENT
)
if plugin:
plugin.default_status = status
await plugin.save(update_fields=["default_status"])
Expand Down Expand Up @@ -461,7 +463,9 @@ async def _change_group_plugin(
if plugin_name.isdigit():
plugin = await PluginInfo.get_or_none(id=int(plugin_name))
else:
plugin = await PluginInfo.get_or_none(name=plugin_name, load_status=True)
plugin = await PluginInfo.get_or_none(
name=plugin_name, load_status=True, plugin_type__not=PluginType.PARENT
)
if plugin:
group, _ = await GroupConsole.get_or_create(
group_id=group_id, channel_id__isnull=True
Expand Down Expand Up @@ -527,7 +531,9 @@ async def superuser_block(
if plugin_name.isdigit():
plugin = await PluginInfo.get_or_none(id=int(plugin_name))
else:
plugin = await PluginInfo.get_or_none(name=plugin_name, load_status=True)
plugin = await PluginInfo.get_or_none(
name=plugin_name, load_status=True, plugin_type__not=PluginType.PARENT
)
if plugin:
if group_id:
if group := await GroupConsole.get_or_none(
Expand Down Expand Up @@ -571,7 +577,9 @@ async def superuser_unblock(
if plugin_name.isdigit():
plugin = await PluginInfo.get_or_none(id=int(plugin_name))
else:
plugin = await PluginInfo.get_or_none(name=plugin_name, load_status=True)
plugin = await PluginInfo.get_or_none(
name=plugin_name, load_status=True, plugin_type__not=PluginType.PARENT
)
if plugin:
if group_id:
if group := await GroupConsole.get_or_none(
Expand Down
7 changes: 5 additions & 2 deletions zhenxun/builtin_plugins/help/_data_source.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import nonebot

from zhenxun.utils.enum import PluginType
from zhenxun.models.plugin_info import PluginInfo
from zhenxun.configs.path_config import IMAGE_PATH
from zhenxun.utils.image_utils import BuildImage, ImageTemplate
Expand Down Expand Up @@ -29,9 +30,11 @@ async def get_plugin_help(name: str, is_superuser: bool) -> str | BuildImage:
is_superuser: 是否为超级用户
"""
if name.isdigit():
plugin = await PluginInfo.get_or_none(id=int(name), load_status=True)
plugin = await PluginInfo.get_or_none(id=int(name))
else:
plugin = await PluginInfo.get_or_none(name__iexact=name, load_status=True)
plugin = await PluginInfo.get_or_none(
name__iexact=name, load_status=True, plugin_type__not=PluginType.PARENT
)
if plugin:
_plugin = nonebot.get_plugin_by_module_name(plugin.module_path)
if _plugin and _plugin.metadata:
Expand Down

0 comments on commit 62fd93c

Please sign in to comment.