mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
✨ : 所有插件管理允许群组管理员使用
This commit is contained in:
parent
d45baaddbc
commit
167555016a
@ -12,7 +12,7 @@ from zhenxun.utils.enum import BlockType, PluginType
|
|||||||
from ._data_source import PluginManage, build_plugin, build_task
|
from ._data_source import PluginManage, build_plugin, build_task
|
||||||
from .command import _group_status_matcher, _status_matcher
|
from .command import _group_status_matcher, _status_matcher
|
||||||
|
|
||||||
base_config = Config.get("admin_bot_manage")
|
base_config = Config.get("plugin_switch")
|
||||||
|
|
||||||
|
|
||||||
__plugin_meta__ = PluginMetadata(
|
__plugin_meta__ = PluginMetadata(
|
||||||
@ -23,6 +23,7 @@ __plugin_meta__ = PluginMetadata(
|
|||||||
格式:
|
格式:
|
||||||
开启/关闭[功能名称] : 开关功能
|
开启/关闭[功能名称] : 开关功能
|
||||||
开启/关闭群被动[被动名称] : 群被动开关
|
开启/关闭群被动[被动名称] : 群被动开关
|
||||||
|
开启/关闭所有插件 : 开启/关闭当前群组所有插件状态
|
||||||
群被动状态 : 查看被动技能开关状态
|
群被动状态 : 查看被动技能开关状态
|
||||||
醒来 : 结束休眠
|
醒来 : 结束休眠
|
||||||
休息吧 : 群组休眠, 不会再响应命令
|
休息吧 : 群组休眠, 不会再响应命令
|
||||||
@ -112,20 +113,7 @@ async def _(
|
|||||||
result = await PluginManage.unblock_group_task(name, gid)
|
result = await PluginManage.unblock_group_task(name, gid)
|
||||||
logger.info(f"开启群组被动 {name}", arparma.header_result, session=session)
|
logger.info(f"开启群组被动 {name}", arparma.header_result, session=session)
|
||||||
else:
|
else:
|
||||||
if session.id1 in bot.config.superusers and (
|
if session.id1 in bot.config.superusers and default_status.result:
|
||||||
all.result or default_status.result
|
|
||||||
):
|
|
||||||
if all.result:
|
|
||||||
"""所有插件"""
|
|
||||||
result = await PluginManage.set_all_plugin_status(
|
|
||||||
True, default_status.result, gid
|
|
||||||
)
|
|
||||||
logger.info(
|
|
||||||
f"超级用户开启群组中全部功能",
|
|
||||||
arparma.header_result,
|
|
||||||
session=session,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
"""单个插件的进群默认修改"""
|
"""单个插件的进群默认修改"""
|
||||||
result = await PluginManage.set_default_status(name, True)
|
result = await PluginManage.set_default_status(name, True)
|
||||||
logger.info(
|
logger.info(
|
||||||
@ -133,9 +121,22 @@ async def _(
|
|||||||
arparma.header_result,
|
arparma.header_result,
|
||||||
session=session,
|
session=session,
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
if all.result:
|
||||||
|
"""所有插件"""
|
||||||
|
result = await PluginManage.set_all_plugin_status(
|
||||||
|
True, default_status.result, gid
|
||||||
|
)
|
||||||
|
logger.info(
|
||||||
|
f"开启群组中全部功能",
|
||||||
|
arparma.header_result,
|
||||||
|
session=session,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
result = await PluginManage.block_group_plugin(name, gid)
|
result = await PluginManage.block_group_plugin(name, gid)
|
||||||
logger.info(f"开启功能 {name}", arparma.header_result, session=session)
|
logger.info(
|
||||||
|
f"开启功能 {name}", arparma.header_result, session=session
|
||||||
|
)
|
||||||
await Text(result).send(reply=True)
|
await Text(result).send(reply=True)
|
||||||
elif session.id1 in bot.config.superusers:
|
elif session.id1 in bot.config.superusers:
|
||||||
"""私聊"""
|
"""私聊"""
|
||||||
@ -199,20 +200,7 @@ async def _(
|
|||||||
if task.result:
|
if task.result:
|
||||||
result = await PluginManage.block_group_task(name, gid)
|
result = await PluginManage.block_group_task(name, gid)
|
||||||
else:
|
else:
|
||||||
if session.id1 in bot.config.superusers and (
|
if session.id1 in bot.config.superusers and default_status.result:
|
||||||
all.result or default_status.result
|
|
||||||
):
|
|
||||||
if all.result:
|
|
||||||
"""所有插件"""
|
|
||||||
result = await PluginManage.set_all_plugin_status(
|
|
||||||
False, default_status.result, gid
|
|
||||||
)
|
|
||||||
logger.info(
|
|
||||||
f"超级用户开启群组中全部功能",
|
|
||||||
arparma.header_result,
|
|
||||||
session=session,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
"""单个插件的进群默认修改"""
|
"""单个插件的进群默认修改"""
|
||||||
result = await PluginManage.set_default_status(name, False)
|
result = await PluginManage.set_default_status(name, False)
|
||||||
logger.info(
|
logger.info(
|
||||||
@ -220,9 +208,22 @@ async def _(
|
|||||||
arparma.header_result,
|
arparma.header_result,
|
||||||
session=session,
|
session=session,
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
if all.result:
|
||||||
|
"""所有插件"""
|
||||||
|
result = await PluginManage.set_all_plugin_status(
|
||||||
|
False, default_status.result, gid
|
||||||
|
)
|
||||||
|
logger.info(
|
||||||
|
f"关闭群组中全部功能",
|
||||||
|
arparma.header_result,
|
||||||
|
session=session,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
result = await PluginManage.unblock_group_plugin(name, gid)
|
result = await PluginManage.unblock_group_plugin(name, gid)
|
||||||
logger.info(f"关闭功能 {name}", arparma.header_result, session=session)
|
logger.info(
|
||||||
|
f"关闭功能 {name}", arparma.header_result, session=session
|
||||||
|
)
|
||||||
await Text(result).send(reply=True)
|
await Text(result).send(reply=True)
|
||||||
elif session.id1 in bot.config.superusers:
|
elif session.id1 in bot.config.superusers:
|
||||||
group_id = group.result if group.available else None
|
group_id = group.result if group.available else None
|
||||||
|
|||||||
@ -37,14 +37,14 @@ _status_matcher = on_alconna(
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
rule=admin_check("admin_bot_manage", "CHANGE_GROUP_SWITCH_LEVEL"),
|
rule=admin_check("plugin_switch", "CHANGE_GROUP_SWITCH_LEVEL"),
|
||||||
priority=5,
|
priority=5,
|
||||||
block=True,
|
block=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
_group_status_matcher = on_alconna(
|
_group_status_matcher = on_alconna(
|
||||||
Alconna("group-status", Args["status", ["sleep", "wake"]]),
|
Alconna("group-status", Args["status", ["sleep", "wake"]]),
|
||||||
rule=admin_check("admin_bot_manage", "CHANGE_GROUP_SWITCH_LEVEL")
|
rule=admin_check("plugin_switch", "CHANGE_GROUP_SWITCH_LEVEL")
|
||||||
& ensure_group
|
& ensure_group
|
||||||
& to_me(),
|
& to_me(),
|
||||||
priority=5,
|
priority=5,
|
||||||
@ -75,21 +75,21 @@ _status_matcher.shortcut(
|
|||||||
|
|
||||||
|
|
||||||
_status_matcher.shortcut(
|
_status_matcher.shortcut(
|
||||||
r"开启所有插件",
|
r"开启所有(插件|功能)",
|
||||||
command="switch",
|
command="switch",
|
||||||
arguments=["open", "s", "--all"],
|
arguments=["open", "s", "--all"],
|
||||||
prefix=True,
|
prefix=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
_status_matcher.shortcut(
|
_status_matcher.shortcut(
|
||||||
r"开启所有插件df",
|
r"开启所有(插件|功能)df",
|
||||||
command="switch",
|
command="switch",
|
||||||
arguments=["open", "s", "-df", "--all"],
|
arguments=["open", "s", "-df", "--all"],
|
||||||
prefix=True,
|
prefix=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
_status_matcher.shortcut(
|
_status_matcher.shortcut(
|
||||||
r"开启插件df(?P<name>.+)",
|
r"开启(插件|功能)df(?P<name>.+)",
|
||||||
command="switch",
|
command="switch",
|
||||||
arguments=["open", "{name}", "-df"],
|
arguments=["open", "{name}", "-df"],
|
||||||
prefix=True,
|
prefix=True,
|
||||||
@ -112,21 +112,21 @@ _status_matcher.shortcut(
|
|||||||
|
|
||||||
|
|
||||||
_status_matcher.shortcut(
|
_status_matcher.shortcut(
|
||||||
r"关闭所有插件",
|
r"关闭所有(插件|功能)",
|
||||||
command="switch",
|
command="switch",
|
||||||
arguments=["close", "s", "--all"],
|
arguments=["close", "s", "--all"],
|
||||||
prefix=True,
|
prefix=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
_status_matcher.shortcut(
|
_status_matcher.shortcut(
|
||||||
r"关闭所有插件df",
|
r"关闭所有(插件|功能)df",
|
||||||
command="switch",
|
command="switch",
|
||||||
arguments=["close", "s", "-df", "--all"],
|
arguments=["close", "s", "-df", "--all"],
|
||||||
prefix=True,
|
prefix=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
_status_matcher.shortcut(
|
_status_matcher.shortcut(
|
||||||
r"关闭插件df(?P<name>.+)",
|
r"关闭(插件|功能)df(?P<name>.+)",
|
||||||
command="switch",
|
command="switch",
|
||||||
arguments=["close", "{name}", "-df"],
|
arguments=["close", "{name}", "-df"],
|
||||||
prefix=True,
|
prefix=True,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user