From 9f17a525f1f1cc233f14f714d2c5c5aacc926f17 Mon Sep 17 00:00:00 2001 From: HibiKier <775757368@qq.com> Date: Tue, 27 Feb 2024 21:43:40 +0800 Subject: [PATCH] =?UTF-8?q?perf=F0=9F=91=8C:=20=E6=B7=BB=E5=8A=A0shop?= =?UTF-8?q?=E7=9A=84shortcut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zhenxun/builtin_plugins/shop/__init__.py | 42 +++++++++++++++++++----- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/zhenxun/builtin_plugins/shop/__init__.py b/zhenxun/builtin_plugins/shop/__init__.py index 9ea6a6cb..00e9c7e0 100644 --- a/zhenxun/builtin_plugins/shop/__init__.py +++ b/zhenxun/builtin_plugins/shop/__init__.py @@ -16,13 +16,10 @@ __plugin_meta__ = PluginMetadata( usage=""" 商品操作 指令: - 添加商品 name:[名称] price:[价格] des:[描述] ?discount:[折扣](小数) ?limit_time:[限时时间](小时) - 删除商品 [名称或序号] - 修改商品 name:[名称或序号] price:[价格] des:[描述] discount:[折扣] limit_time:[限时] - 示例:添加商品 name:萝莉酒杯 price:9999 des:普通的酒杯,但是里面.. discount:0.4 limit_time:90 - 示例:添加商品 name:可疑的药 price:5 des:效果未知 - 示例:删除商品 2 - 示例:修改商品 name:1 price:900 修改序号为1的商品的价格为900 + 我的金币 + 我的道具 + 使用道具 [名称/Id] + 购买道具 [名称/Id] * 修改商品只需添加需要值即可 * """.strip(), extra=PluginExtraData( @@ -34,11 +31,10 @@ __plugin_meta__ = PluginMetadata( ).dict(), ) -# TODO: 修改操作,shortcut _matcher = on_alconna( Alconna( - "shop", + "商店", Subcommand("my-cost", help_text="我的金币"), Subcommand("my-props", help_text="我的道具"), Subcommand("buy", Args["name", str]["num", int, 1], help_text="购买道具"), @@ -48,6 +44,34 @@ _matcher = on_alconna( block=True, ) +_matcher.shortcut( + "我的金币", + command="商店", + arguments=["my-cost"], + prefix=True, +) + +_matcher.shortcut( + "我的道具", + command="商店", + arguments=["my-props"], + prefix=True, +) + +_matcher.shortcut( + "购买道具", + command="商店", + arguments=["buy", "{%0}"], + prefix=True, +) + +_matcher.shortcut( + "使用道具", + command="商店", + arguments=["use", "{%0}"], + prefix=True, +) + @_matcher.assign("$main") async def _(session: EventSession, arparma: Arparma):