mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-03 02:30:01 +08:00
🐛 修复webui下载分支 (#2099)
This commit is contained in:
@@ -120,7 +120,7 @@ async def _(
|
||||
):
|
||||
if not all.result and not plugin_name.available:
|
||||
await MessageUtils.build_message("请输入功能/被动名称").finish(reply_to=True)
|
||||
name = plugin_name.result
|
||||
name = plugin_name.result.strip()
|
||||
if session.group:
|
||||
group_id = session.group.id
|
||||
"""修改当前群组的数据"""
|
||||
@@ -234,7 +234,7 @@ async def _(
|
||||
):
|
||||
if not all.result and not plugin_name.available:
|
||||
await MessageUtils.build_message("请输入功能/被动名称").finish(reply_to=True)
|
||||
name = plugin_name.result
|
||||
name = plugin_name.result.strip()
|
||||
if session.group:
|
||||
group_id = session.group.id
|
||||
"""修改当前群组的数据"""
|
||||
@@ -321,13 +321,29 @@ async def _(
|
||||
session=session,
|
||||
)
|
||||
else:
|
||||
parsed_block_type = (
|
||||
block_type.result.lower()
|
||||
if block_type.available and block_type.result
|
||||
else ""
|
||||
)
|
||||
# 兼容中文快捷命令:`关闭功能名 p/g/a`
|
||||
if not parsed_block_type and " " in name:
|
||||
split_name = name.rsplit(maxsplit=1)
|
||||
if len(split_name) == 2 and split_name[1].lower() in {
|
||||
"a",
|
||||
"all",
|
||||
"g",
|
||||
"group",
|
||||
"p",
|
||||
"private",
|
||||
}:
|
||||
name = split_name[0].strip()
|
||||
parsed_block_type = split_name[1].lower()
|
||||
_type = BlockType.ALL
|
||||
if block_type.result in ["p", "private"]:
|
||||
if block_type.available:
|
||||
_type = BlockType.PRIVATE
|
||||
elif block_type.result in ["g", "group"]:
|
||||
if block_type.available:
|
||||
_type = BlockType.GROUP
|
||||
if parsed_block_type in {"p", "private"}:
|
||||
_type = BlockType.PRIVATE
|
||||
elif parsed_block_type in {"g", "group"}:
|
||||
_type = BlockType.GROUP
|
||||
result = await PluginManager.superuser_block(name, _type, group_id)
|
||||
logger.info(
|
||||
f"超级用户关闭功能 {name}, 禁用类型: {_type}",
|
||||
|
||||
@@ -142,6 +142,22 @@ async def build_task(group_id: str | None) -> BuildImage:
|
||||
|
||||
|
||||
class PluginManager:
|
||||
@staticmethod
|
||||
async def _get_plugin_by_name_or_module(plugin_name: str) -> PluginInfo | None:
|
||||
plugin_name = plugin_name.strip()
|
||||
if not plugin_name:
|
||||
return None
|
||||
if plugin_name.isdigit():
|
||||
return await PluginInfo.get_or_none(id=int(plugin_name))
|
||||
plugin = await PluginInfo.get_or_none(
|
||||
name=plugin_name, load_status=True, plugin_type__not=PluginType.PARENT
|
||||
)
|
||||
if plugin:
|
||||
return plugin
|
||||
return await PluginInfo.get_or_none(
|
||||
module=plugin_name, load_status=True, plugin_type__not=PluginType.PARENT
|
||||
)
|
||||
|
||||
@classmethod
|
||||
async def set_default_status(cls, plugin_name: str, status: bool) -> str:
|
||||
"""设置插件进群默认状态
|
||||
@@ -153,12 +169,7 @@ class PluginManager:
|
||||
返回:
|
||||
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_type__not=PluginType.PARENT
|
||||
)
|
||||
plugin = await cls._get_plugin_by_name_or_module(plugin_name)
|
||||
if plugin:
|
||||
plugin.default_status = status
|
||||
await plugin.save(update_fields=["default_status"])
|
||||
@@ -478,12 +489,7 @@ class PluginManager:
|
||||
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_type__not=PluginType.PARENT
|
||||
)
|
||||
plugin = await cls._get_plugin_by_name_or_module(plugin_name)
|
||||
if plugin:
|
||||
status_str = "开启" if status else "关闭"
|
||||
if status:
|
||||
@@ -535,12 +541,7 @@ class PluginManager:
|
||||
返回:
|
||||
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_type__not=PluginType.PARENT
|
||||
)
|
||||
plugin = await cls._get_plugin_by_name_or_module(plugin_name)
|
||||
if plugin:
|
||||
if group_id:
|
||||
if not await GroupConsole.is_superuser_block_plugin(
|
||||
@@ -576,12 +577,7 @@ class PluginManager:
|
||||
返回:
|
||||
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_type__not=PluginType.PARENT
|
||||
)
|
||||
plugin = await cls._get_plugin_by_name_or_module(plugin_name)
|
||||
if plugin:
|
||||
if group_id:
|
||||
if await GroupConsole.is_superuser_block_plugin(
|
||||
|
||||
Reference in New Issue
Block a user