添加功能名称当命令检测

This commit is contained in:
HibiKier 2024-08-05 23:07:17 +08:00
parent 1a8378f433
commit 409a4f867d
5 changed files with 55 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -0,0 +1,53 @@
import os
import random
from nonebot import on_message
from nonebot.plugin import PluginMetadata
from nonebot.rule import to_me
from nonebot_plugin_alconna import Image, UniMessage, UniMsg
from nonebot_plugin_session import EventSession
from zhenxun.configs.path_config import IMAGE_PATH
from zhenxun.configs.utils import PluginExtraData
from zhenxun.models.plugin_info import PluginInfo
from zhenxun.services.log import logger
from zhenxun.utils.enum import PluginType
__plugin_meta__ = PluginMetadata(
name="功能名称当命令检测",
description="功能名称当命令检测",
usage=f"""被动""".strip(),
extra=PluginExtraData(
author="HibiKier",
version="0.1",
plugin_type=PluginType.HIDDEN,
).dict(),
)
_matcher = on_message(rule=to_me(), priority=997)
_path = IMAGE_PATH / "_base" / "laugh"
@_matcher.handle()
async def _(message: UniMsg, session: EventSession):
if text := message.extract_plain_text().strip():
if plugin := await PluginInfo.get_or_none(
name=text, load_status=True, plugin_type=PluginType.NORMAL
):
image = None
if _path.exists():
if files := os.listdir(_path):
image = Image(path=_path / random.choice(files))
message_list = []
if image:
message_list.append(image)
message_list.append(
f"桀桀桀,预判到会有 '笨蛋' 把功能名称当命令用,特地前来嘲笑!但还是好心来帮帮你啦!\n请at我发送 '帮助{plugin.name}' 或者 '帮助{plugin.id}' 来获取该功能帮助!"
)
logger.info(
f"检测到功能名称当命令使用,已发送帮助信息", "功能帮助", session=session
)
await UniMessage(message_list).finish(reply_to=True)

View File

@ -18,8 +18,7 @@ __plugin_meta__ = PluginMetadata(
示例:b封面 av86863038
""".strip(),
extra=PluginExtraData(
author="HibiKier",
version="0.1",
author="HibiKier", version="0.1", menu_type="一些工具"
).dict(),
)

View File

@ -9,7 +9,7 @@ _russian_matcher = on_alconna(
"俄罗斯轮盘",
Args["money", int]["num?", int]["at_user?", alcAt],
),
aliases={"装弹"},
aliases={"装弹", "俄罗斯转盘"},
rule=ensure_group,
priority=5,
block=True,