From 4bf5f880bab3993fd9fcde8a0bf901bed9ee506b Mon Sep 17 00:00:00 2001 From: HibiKier <775757368@qq.com> Date: Sun, 2 Mar 2025 14:27:58 +0800 Subject: [PATCH] =?UTF-8?q?:adhesive=5Fbandage:=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=AC=A8=E8=9B=8B=E6=A3=80=E6=B5=8B=E5=92=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=95=86=E5=BA=97=E5=9B=BE=E6=A0=87=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zhenxun/builtin_plugins/help_help.py | 12 ++++++++++-- zhenxun/builtin_plugins/shop/_data_source.py | 7 ++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/zhenxun/builtin_plugins/help_help.py b/zhenxun/builtin_plugins/help_help.py index c315bcd8..e6342b4a 100644 --- a/zhenxun/builtin_plugins/help_help.py +++ b/zhenxun/builtin_plugins/help_help.py @@ -2,9 +2,9 @@ import os import random from nonebot import on_message +from nonebot.adapters import Event from nonebot.matcher import Matcher from nonebot.plugin import PluginMetadata -from nonebot.rule import to_me from nonebot_plugin_alconna import UniMsg from nonebot_plugin_session import EventSession @@ -29,7 +29,13 @@ __plugin_meta__ = PluginMetadata( ).to_dict(), ) -_matcher = on_message(rule=to_me(), priority=996, block=False) + +async def rule(event: Event, message: UniMsg) -> bool: + text = message.extract_plain_text().strip() + return event.is_tome() and bool(text and len(text) < 20) + + +_matcher = on_message(rule=rule, priority=996, block=False) _path = IMAGE_PATH / "_base" / "laugh" @@ -47,6 +53,8 @@ async def _(matcher: Matcher, message: UniMsg, session: EventSession): if g.level < 0: return if text := message.extract_plain_text().strip(): + if len(text) > 100: + return if plugin := await PluginInfo.get_or_none( name=text, load_status=True, diff --git a/zhenxun/builtin_plugins/shop/_data_source.py b/zhenxun/builtin_plugins/shop/_data_source.py index c4343bbb..820bb037 100644 --- a/zhenxun/builtin_plugins/shop/_data_source.py +++ b/zhenxun/builtin_plugins/shop/_data_source.py @@ -492,9 +492,10 @@ class ShopManage: for i, p in enumerate(user.props): if prop := uuid2goods.get(p): icon = "" - icon_path = ICON_PATH / prop.icon - if icon_path.exists(): - icon = (icon_path, 33, 33) + if prop.icon: + icon_path = ICON_PATH / prop.icon + if icon_path.exists(): + icon = (icon_path, 33, 33) data_list.append( [ icon,