mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-08 05:10:01 +08:00
feat✨: 画廊操作
This commit is contained in:
@@ -26,7 +26,7 @@ from ._data_source import BanManage
|
||||
base_config = Config.get("ban")
|
||||
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="封禁用户/群组",
|
||||
name="Ban",
|
||||
description="你被逮捕了!丢进小黑屋!封禁用户以及群组,屏蔽消息",
|
||||
usage="""
|
||||
普通管理员
|
||||
@@ -37,8 +37,13 @@ __plugin_meta__ = PluginMetadata(
|
||||
ban @用户 : 永久拉黑用户
|
||||
ban @用户 100 : 拉黑用户100分钟
|
||||
unban @用户 : 从小黑屋中拉出来
|
||||
|
||||
超级管理员额外命令
|
||||
""".strip(),
|
||||
extra=PluginExtraData(
|
||||
author="HibiKier",
|
||||
version="0.1",
|
||||
plugin_type=PluginType.SUPER_AND_ADMIN,
|
||||
superuser_help="""
|
||||
超级管理员额外命令
|
||||
格式:
|
||||
ban [At用户/用户Id] [时长]
|
||||
ban列表: 获取所有Ban数据
|
||||
@@ -54,11 +59,7 @@ __plugin_meta__ = PluginMetadata(
|
||||
|
||||
unban 123456789 : 从小黑屋中拉出来
|
||||
unban -g 999999 : 将群组9999999从小黑屋中拉出来
|
||||
""".strip(),
|
||||
extra=PluginExtraData(
|
||||
author="HibiKier",
|
||||
version="0.1",
|
||||
plugin_type=PluginType.SUPER_AND_ADMIN,
|
||||
""",
|
||||
admin_level=base_config.get("BAN_LEVEL", 5),
|
||||
configs=[
|
||||
RegisterConfig(
|
||||
|
||||
@@ -32,22 +32,24 @@ __plugin_meta__ = PluginMetadata(
|
||||
关闭签到 : 关闭签到
|
||||
开启群被动早晚安 : 关闭被动任务早晚安
|
||||
|
||||
超级管理员额外命令
|
||||
格式:
|
||||
插件列表
|
||||
开启/关闭[功能名称] ?[-t ["private", "p", "group", "g"](关闭类型)] ?[-g 群组Id]
|
||||
|
||||
私聊下:
|
||||
示例:
|
||||
开启签到 : 全局开启签到
|
||||
关闭签到 : 全局关闭签到
|
||||
关闭签到 p : 全局私聊关闭签到
|
||||
关闭签到 -g 12345678 : 关闭群组12345678的签到功能(普通管理员无法开启)
|
||||
""".strip(),
|
||||
extra=PluginExtraData(
|
||||
author="HibiKier",
|
||||
version="0.1",
|
||||
plugin_type=PluginType.SUPER_AND_ADMIN,
|
||||
superuser_help="""
|
||||
超级管理员额外命令
|
||||
格式:
|
||||
插件列表
|
||||
开启/关闭[功能名称] ?[-t ["private", "p", "group", "g"](关闭类型)] ?[-g 群组Id]
|
||||
|
||||
私聊下:
|
||||
示例:
|
||||
开启签到 : 全局开启签到
|
||||
关闭签到 : 全局关闭签到
|
||||
关闭签到 p : 全局私聊关闭签到
|
||||
关闭签到 -g 12345678 : 关闭群组12345678的签到功能(普通管理员无法开启)
|
||||
""",
|
||||
admin_level=base_config.get("CHANGE_GROUP_SWITCH_LEVEL", 2),
|
||||
configs=[
|
||||
RegisterConfig(
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from pathlib import Path
|
||||
from nonebot.adapters import Bot
|
||||
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from nonebot.rule import to_me
|
||||
from nonebot_plugin_alconna import Alconna, Args, Match, on_alconna
|
||||
from nonebot_plugin_alconna import Alconna, AlconnaQuery, Args, Match, Option, Query, on_alconna, store_true
|
||||
from nonebot_plugin_saa import Image, Text
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
@@ -43,6 +44,7 @@ _matcher = on_alconna(
|
||||
Alconna(
|
||||
"功能",
|
||||
Args["name?", str],
|
||||
Option("-s|--superuser", action=store_true, help_text="超级用户帮助")
|
||||
),
|
||||
aliases={"help", "帮助"},
|
||||
rule=to_me(),
|
||||
@@ -53,11 +55,18 @@ _matcher = on_alconna(
|
||||
|
||||
@_matcher.handle()
|
||||
async def _(
|
||||
bot: Bot,
|
||||
name: Match[str],
|
||||
session: EventSession,
|
||||
is_superuser: Query[bool] = AlconnaQuery("superuser.value", False)
|
||||
):
|
||||
_is_superuser = False
|
||||
if is_superuser.available:
|
||||
_is_superuser = is_superuser.result
|
||||
if name.available:
|
||||
if result := await get_plugin_help(name.result):
|
||||
if _is_superuser and session.id1 not in bot.config.superusers:
|
||||
_is_superuser = False
|
||||
if result := await get_plugin_help(name.result, _is_superuser):
|
||||
if isinstance(result, BuildImage):
|
||||
await Image(result.pic2bytes()).send(reply=True)
|
||||
else:
|
||||
|
||||
@@ -21,19 +21,30 @@ async def create_help_img(group_id: str | None):
|
||||
await HelpImageBuild().build_image(group_id)
|
||||
|
||||
|
||||
async def get_plugin_help(name: str) -> str | BuildImage:
|
||||
async def get_plugin_help(name: str, is_superuser: bool) -> str | BuildImage:
|
||||
"""获取功能的帮助信息
|
||||
|
||||
参数:
|
||||
name: 插件名称
|
||||
is_superuser: 是否为超级用户
|
||||
"""
|
||||
if plugin := await PluginInfo.get_or_none(name=name):
|
||||
if plugin := await PluginInfo.get_or_none(name__iexact=name):
|
||||
_plugin = nonebot.get_plugin_by_module_name(plugin.module_path)
|
||||
if _plugin and _plugin.metadata:
|
||||
items = {
|
||||
"简介": _plugin.metadata.description,
|
||||
"用法": _plugin.metadata.usage,
|
||||
}
|
||||
return await ImageTemplate.hl_page(name, items)
|
||||
items = None
|
||||
if is_superuser:
|
||||
extra = _plugin.metadata.extra
|
||||
if usage := extra.get("superuser_help"):
|
||||
items = {
|
||||
"简介": _plugin.metadata.description,
|
||||
"用法": usage,
|
||||
}
|
||||
else:
|
||||
items = {
|
||||
"简介": _plugin.metadata.description,
|
||||
"用法": _plugin.metadata.usage,
|
||||
}
|
||||
if items:
|
||||
return await ImageTemplate.hl_page(name, items)
|
||||
return "糟糕! 该功能没有帮助喔..."
|
||||
return "没有查找到这个功能噢..."
|
||||
|
||||
Reference in New Issue
Block a user