From 4da27950c89d4c0bab70ba983ba25bae9f91c19c Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 18 Sep 2023 20:00:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=BC=80=E6=94=BE=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E6=A8=A1=E5=9E=8B=E7=A4=BC=E7=89=A9=E4=BB=B7=E6=A0=BC?= =?UTF-8?q?=E7=9A=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blivedm/models/open_live.py | 2 +- open_live_sample.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/blivedm/models/open_live.py b/blivedm/models/open_live.py index 3a66d4b..33f7606 100644 --- a/blivedm/models/open_live.py +++ b/blivedm/models/open_live.py @@ -135,7 +135,7 @@ class GiftMessage: gift_num: int = 0 """赠送道具数量""" price: int = 0 - """支付金额(1000 = 1元 = 10电池),盲盒:爆出道具的价值""" + """(礼物单价)支付金额(1000 = 1元 = 10电池),盲盒:爆出道具的价值""" # 这个B 站文档又不写清楚是单价还是总价 paid: bool = False """是否是付费道具""" fans_medal_level: int = 0 diff --git a/open_live_sample.py b/open_live_sample.py index 68b1782..6e47410 100644 --- a/open_live_sample.py +++ b/open_live_sample.py @@ -51,8 +51,9 @@ class MyHandler(blivedm.BaseHandler): def _on_open_live_gift(self, client: blivedm.OpenLiveClient, message: open_models.GiftMessage): coin_type = '金瓜子' if message.paid else '银瓜子' + total_coin = message.price * message.gift_num print(f'[{message.room_id}] {message.uname} 赠送{message.gift_name}x{message.gift_num}' - f' ({coin_type}x{message.price})') + f' ({coin_type}x{total_coin})') def _on_open_live_buy_guard(self, client: blivedm.OpenLiveClient, message: open_models.GuardBuyMessage): print(f'[{message.room_id}] {message.user_info.uname} 购买 大航海等级={message.guard_level}')