diff --git a/basic_plugins/shop/buy.py b/basic_plugins/shop/buy.py index 5d725e50..430a0fa6 100644 --- a/basic_plugins/shop/buy.py +++ b/basic_plugins/shop/buy.py @@ -41,11 +41,15 @@ async def _(bot: Bot, event: GroupMessageEvent, state: T_State): goods = None if get_message_text(event.json()) in ["神秘药水"]: await buy.finish("你们看看就好啦,这是不可能卖给你们的~", at_sender=True) - goods_name_lst = [ - x.goods_name + goods_list = [ + x for x in await GoodsInfo.get_all_goods() if x.goods_limit_time > time.time() or x.goods_limit_time == 0 ] + goods_name_list = [ + x.goods_name + for x in goods_list + ] msg = get_message_text(event.json()).split() num = 1 if len(msg) > 1: @@ -55,14 +59,14 @@ async def _(bot: Bot, event: GroupMessageEvent, state: T_State): await buy.finish("购买的数量要是数字且大于0!", at_sender=True) if is_number(msg[0]): msg = int(msg[0]) - if msg > len(goods_name_lst) or msg < 1: + if msg > len(goods_name_list) or msg < 1: await buy.finish("请输入正确的商品id!", at_sender=True) - goods = goods_name_lst[msg - 1] + goods = goods_list[msg - 1] else: - if msg[0] in goods_name_lst: - for i in range(len(goods_name_lst)): - if msg[0] == goods_name_lst[i]: - goods = goods_name_lst[i] + if msg[0] in goods_name_list: + for i in range(len(goods_name_list)): + if msg[0] == goods_name_list[i]: + goods = goods_list[i] break else: await buy.finish("请输入正确的商品名称!")