mirror of
https://github.com/xfgryujk/blivechat.git
synced 2024-12-25 12:21:00 +08:00
插件上舰消息添加价格
This commit is contained in:
parent
da3e27c8cb
commit
b2fc08def3
@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
__version__ = '0.0.1' # TODO 上舰消息加上price后再改成正式版
|
||||
__version__ = '1.0.0'
|
||||
|
||||
from .handlers import *
|
||||
from .client import *
|
||||
|
@ -321,6 +321,8 @@ class AddMemberMsg:
|
||||
"""数量"""
|
||||
unit: str = ''
|
||||
"""单位(月)"""
|
||||
total_coin: int = 0
|
||||
"""总价付费瓜子数,1000金瓜子 = 1元"""
|
||||
uid: str = ''
|
||||
"""用户Open ID或ID"""
|
||||
medal_level: int = 0
|
||||
@ -338,6 +340,7 @@ class AddMemberMsg:
|
||||
privilege_type=data['privilegeType'],
|
||||
num=data['num'],
|
||||
unit=data['unit'],
|
||||
total_coin=data['total_coin'],
|
||||
uid=data['uid'],
|
||||
medal_level=data['medalLevel'],
|
||||
medal_name=data['medalName'],
|
||||
|
@ -78,7 +78,7 @@ class MsgHandler(blcsdk.BaseHandler):
|
||||
if message.total_coin != 0:
|
||||
content = (
|
||||
f'[paid_gift] {message.author_name} 赠送了 {message.gift_name} x {message.num},'
|
||||
f'总价 {message.total_coin / 1000} 元'
|
||||
f'总价 {message.total_coin / 1000:.1f} 元'
|
||||
)
|
||||
else:
|
||||
content = (
|
||||
@ -101,7 +101,8 @@ class MsgHandler(blcsdk.BaseHandler):
|
||||
guard_name = '总督'
|
||||
else:
|
||||
guard_name = '未知舰队等级'
|
||||
room.log(f'[guard] {message.author_name} 购买了 {message.num}{message.unit} {guard_name}')
|
||||
room.log(f'[guard] {message.author_name} 购买了 {message.num}{message.unit} {guard_name},'
|
||||
f'总价 {message.total_coin / 1000:.1f} 元')
|
||||
|
||||
def _on_add_super_chat(
|
||||
self, client: blcsdk.BlcPluginClient, message: sdk_models.AddSuperChatMsg, extra: sdk_models.ExtraData
|
||||
|
@ -88,19 +88,14 @@ class MsgHandler(blcsdk.BaseHandler):
|
||||
return
|
||||
room = _get_or_add_room(extra.room_key, extra.room_id)
|
||||
|
||||
# 消息里没有价格,这里按最低算
|
||||
if message.privilege_type == sdk_models.GuardLevel.LV1:
|
||||
guard_name = '舰长'
|
||||
price = 138
|
||||
elif message.privilege_type == sdk_models.GuardLevel.LV2:
|
||||
guard_name = '提督'
|
||||
price = 1998
|
||||
elif message.privilege_type == sdk_models.GuardLevel.LV3:
|
||||
guard_name = '总督'
|
||||
price = 19998
|
||||
else:
|
||||
guard_name = '未知舰队等级'
|
||||
price = 0
|
||||
guard_name += f'({message.unit})'
|
||||
|
||||
room.add_gift(GiftRecord(
|
||||
@ -108,7 +103,7 @@ class MsgHandler(blcsdk.BaseHandler):
|
||||
author_name=message.author_name,
|
||||
gift_name=guard_name,
|
||||
num=message.num,
|
||||
price=price,
|
||||
price=message.total_coin / 1000,
|
||||
))
|
||||
|
||||
def _on_add_super_chat(
|
||||
|
@ -56,12 +56,12 @@ class AppConfig:
|
||||
|
||||
self.max_tts_queue_size = 5
|
||||
|
||||
self.template_text = '{author_name} 说:{content}'
|
||||
self.template_text = '{author_name} 说,{content}'
|
||||
# self.template_free_gift = '{author_name} 赠送了{num}个{gift_name},总价{total_coin}银瓜子'
|
||||
self.template_free_gift = '{author_name} 赠送了{num}个{gift_name}'
|
||||
self.template_paid_gift = '{author_name} 赠送了{num}个{gift_name},总价{price:.1f}元'
|
||||
self.template_member = '{author_name} 购买了{num}{unit} {guard_name}'
|
||||
self.template_super_chat = '{author_name} 发送了{price}元的醒目留言:{content}'
|
||||
self.template_member = '{author_name} 购买了{num}{unit} {guard_name},总价{price:.1f}元'
|
||||
self.template_super_chat = '{author_name} 发送了{price}元的醒目留言,{content}'
|
||||
|
||||
def load(self, path):
|
||||
try:
|
||||
|
@ -13,13 +13,13 @@ max_tts_queue_size = 5
|
||||
|
||||
# 消息模板,如果为空则不读
|
||||
# 弹幕
|
||||
template_text = {author_name} 说:{content}
|
||||
template_text = {author_name} 说,{content}
|
||||
# 免费礼物
|
||||
# template_free_gift = {author_name} 赠送了{num}个{gift_name},总价{total_coin}银瓜子
|
||||
template_free_gift = {author_name} 赠送了{num}个{gift_name}
|
||||
# 付费礼物
|
||||
template_paid_gift = {author_name} 赠送了{num}个{gift_name},总价{price:.1f}元
|
||||
# 上舰
|
||||
template_member = {author_name} 购买了{num}{unit} {guard_name}
|
||||
template_member = {author_name} 购买了{num}{unit} {guard_name},总价{price:.1f}元
|
||||
# 醒目留言
|
||||
template_super_chat = {author_name} 发送了{price}元的醒目留言:{content}
|
||||
template_super_chat = {author_name} 发送了{price}元的醒目留言,{content}
|
||||
|
@ -103,6 +103,8 @@ class MsgHandler(blcsdk.BaseHandler):
|
||||
num=message.num,
|
||||
unit=message.unit,
|
||||
guard_name=guard_name,
|
||||
price=message.total_coin / 1000,
|
||||
total_coin=message.total_coin,
|
||||
)
|
||||
tts.say_text(text, tts.Priority.HIGH)
|
||||
|
||||
|
@ -611,7 +611,7 @@ class LiveMsgHandler(blivedm.BaseHandler):
|
||||
# 给插件用的字段
|
||||
'num': message.num,
|
||||
'unit': '月', # 单位在USER_TOAST_MSG消息里,不想改消息。现在没有别的单位,web接口也很少有人用了,先写死吧
|
||||
# TODO price
|
||||
'total_coin': message.price * message.num,
|
||||
'uid': str(message.uid) if message.uid != 0 else message.username,
|
||||
'medalLevel': 0,
|
||||
'medalName': '',
|
||||
@ -813,7 +813,7 @@ class LiveMsgHandler(blivedm.BaseHandler):
|
||||
# 给插件用的字段
|
||||
'num': message.guard_num,
|
||||
'unit': message.guard_unit,
|
||||
# TODO price
|
||||
'total_coin': message.price * message.guard_num,
|
||||
'uid': message.user_info.open_id,
|
||||
'medalLevel': 0 if not message.fans_medal_wearing_status else message.fans_medal_level,
|
||||
'medalName': '' if not message.fans_medal_wearing_status else message.fans_medal_name,
|
||||
|
Loading…
Reference in New Issue
Block a user