mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-06 20:29:59 +08:00
🐛 修复使用道具后未减去道具数量
This commit is contained in:
@@ -15,6 +15,7 @@ from nonebot_plugin_userinfo import EventUserInfo, UserInfo
|
||||
from zhenxun.configs.utils import BaseBlock, PluginExtraData
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.enum import BlockType, PluginType
|
||||
from zhenxun.utils.exception import GoodsNotFound
|
||||
from zhenxun.utils.message import MessageUtils
|
||||
|
||||
from ._data_source import ShopManage
|
||||
@@ -141,9 +142,16 @@ async def _(
|
||||
name: str,
|
||||
num: int,
|
||||
):
|
||||
result = await ShopManage.use(bot, event, session, message, name, num, "")
|
||||
logger.info(f"使用道具 {name}, 数量: {num}", arparma.header_result, session=session)
|
||||
if isinstance(result, str):
|
||||
await MessageUtils.build_message(result).send(reply_to=True)
|
||||
elif isinstance(result, UniMessage):
|
||||
await result.finish(reply_to=True)
|
||||
try:
|
||||
result = await ShopManage.use(bot, event, session, message, name, num, "")
|
||||
logger.info(
|
||||
f"使用道具 {name}, 数量: {num}", arparma.header_result, session=session
|
||||
)
|
||||
if isinstance(result, str):
|
||||
await MessageUtils.build_message(result).send(reply_to=True)
|
||||
elif isinstance(result, UniMessage):
|
||||
await result.finish(reply_to=True)
|
||||
except GoodsNotFound:
|
||||
await MessageUtils.build_message(f"没有找到道具 {name} 或道具数量不足...").send(
|
||||
reply_to=True
|
||||
)
|
||||
|
||||
@@ -260,9 +260,10 @@ class ShopManage:
|
||||
bot, event, session, message, goods, num, text
|
||||
)
|
||||
if num > param.max_num_limit:
|
||||
return f"{goods_name} 单次使用最大数量为{param.max_num_limit}..."
|
||||
return f"{goods_info.goods_name} 单次使用最大数量为{param.max_num_limit}..."
|
||||
await cls.run_before_after(goods, param, "before", **kwargs)
|
||||
result = await cls.__run(goods, param, session, message, **kwargs)
|
||||
await UserConsole.use_props(session.id1, goods_info.uuid, num, session.platform) # type: ignore
|
||||
await cls.run_before_after(goods, param, "after", **kwargs)
|
||||
if not result and param.send_success_msg:
|
||||
result = f"使用道具 {goods.name} {num} 次成功!"
|
||||
|
||||
Reference in New Issue
Block a user