diff --git a/blivedm b/blivedm index f9b6dc2..68eae6b 160000 --- a/blivedm +++ b/blivedm @@ -1 +1 @@ -Subproject commit f9b6dc2f353f574dc7ae757be63ccacf6c93d06f +Subproject commit 68eae6b6aa1ddde660d317fbccf82cd7edbecd98 diff --git a/frontend/src/api/chat/ChatClientDirectOpenLive.js b/frontend/src/api/chat/ChatClientDirectOpenLive.js index f9c14d8..0be24f7 100644 --- a/frontend/src/api/chat/ChatClientDirectOpenLive.js +++ b/frontend/src/api/chat/ChatClientDirectOpenLive.js @@ -261,7 +261,7 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase { sendGiftCallback(command) { let data = command.data - let totalCoin = data.price * data.gift_num + let totalCoin = data.r_price * data.gift_num data = new chatModels.AddGiftMsg({ id: data.msg_id, avatarUrl: chat.processAvatarUrl(data.uface), diff --git a/frontend/src/api/chat/ChatClientDirectWeb.js b/frontend/src/api/chat/ChatClientDirectWeb.js index 7030f61..6fe420f 100644 --- a/frontend/src/api/chat/ChatClientDirectWeb.js +++ b/frontend/src/api/chat/ChatClientDirectWeb.js @@ -70,6 +70,12 @@ export default class ChatClientDirectWeb extends ChatClientOfficialBase { async danmuMsgCallback(command) { let info = command.info + let modeInfo = info[0][15] + let avatarUrl = modeInfo?.user?.base?.face ?? '' + if (!avatarUrl) { + avatarUrl = await chat.getAvatarUrl(uid, authorName) + } + let roomId, medalLevel if (info[3]) { roomId = info[3][3] @@ -95,7 +101,7 @@ export default class ChatClientDirectWeb extends ChatClientOfficialBase { let authorName = info[2][1] let content = info[1] let data = new chatModels.AddTextMsg({ - avatarUrl: await chat.getAvatarUrl(uid, authorName), + avatarUrl: avatarUrl, timestamp: info[0][4] / 1000, authorName: authorName, authorType: authorType, @@ -126,13 +132,25 @@ export default class ChatClientDirectWeb extends ChatClientOfficialBase { this.msgHandler.onAddGift(data) } - async guardBuyCallback(command) { + async userToastV2Callback(command) { let data = command.data + let { + sender_uinfo: { + uid, + base: { + name: username, + }, + }, + guard_info: { + start_time: timestamp, + guard_level: guardLevel, + }, + } = data data = new chatModels.AddMemberMsg({ - avatarUrl: await chat.getAvatarUrl(data.uid, data.username), - timestamp: data.start_time, - authorName: data.username, - privilegeType: data.guard_level + avatarUrl: await chat.getAvatarUrl(uid, username), + timestamp: timestamp, + authorName: username, + privilegeType: guardLevel, }) this.msgHandler.onAddMember(data) } @@ -163,7 +181,7 @@ export default class ChatClientDirectWeb extends ChatClientOfficialBase { const CMD_CALLBACK_MAP = { DANMU_MSG: ChatClientDirectWeb.prototype.danmuMsgCallback, SEND_GIFT: ChatClientDirectWeb.prototype.sendGiftCallback, - GUARD_BUY: ChatClientDirectWeb.prototype.guardBuyCallback, + USER_TOAST_MSG_V2: ChatClientDirectWeb.prototype.userToastV2Callback, SUPER_CHAT_MESSAGE: ChatClientDirectWeb.prototype.superChatMessageCallback, SUPER_CHAT_MESSAGE_DELETE: ChatClientDirectWeb.prototype.superChatMessageDeleteCallback } diff --git a/services/chat.py b/services/chat.py index 8bee502..ad44c8b 100644 --- a/services/chat.py +++ b/services/chat.py @@ -508,7 +508,9 @@ class LiveMsgHandler(blivedm.BaseHandler): async def __on_danmaku(self, client: WebLiveClient, message: dm_web_models.DanmakuMessage): # 先异步调用再获取房间,因为返回时房间可能已经不存在了 - avatar_url = await services.avatar.get_avatar_url(message.uid, message.uname) + avatar_url = message.face + if avatar_url == '': + avatar_url = await services.avatar.get_avatar_url(message.uid, message.uname) room = client_room_manager.get_room(client.room_key) if room is None: @@ -605,11 +607,11 @@ class LiveMsgHandler(blivedm.BaseHandler): sdk_models.Command.ADD_GIFT, data, make_plugin_msg_extra_from_live_client(client) ) - def _on_buy_guard(self, client: WebLiveClient, message: dm_web_models.GuardBuyMessage): + def _on_user_toast_v2(self, client: WebLiveClient, message: dm_web_models.UserToastV2Message): utils.async_io.create_task_with_ref(self.__on_buy_guard(client, message)) @staticmethod - async def __on_buy_guard(client: WebLiveClient, message: dm_web_models.GuardBuyMessage): + async def __on_buy_guard(client: WebLiveClient, message: dm_web_models.UserToastV2Message): # 先异步调用再获取房间,因为返回时房间可能已经不存在了 avatar_url = await services.avatar.get_avatar_url(message.uid, message.username) @@ -625,7 +627,7 @@ class LiveMsgHandler(blivedm.BaseHandler): 'privilegeType': message.guard_level, # 给插件用的字段 'num': message.num, - 'unit': '月', # 单位在USER_TOAST_MSG消息里,不想改消息。现在没有别的单位,web接口也很少有人用了,先写死吧 + 'unit': message.unit, 'total_coin': message.price * message.num, 'uid': str(message.uid) if message.uid != 0 else message.username, 'medalLevel': 0, @@ -791,7 +793,7 @@ class LiveMsgHandler(blivedm.BaseHandler): if room is None: return - total_coin = message.price * message.gift_num + total_coin = message.r_price * message.gift_num data = { 'id': message.msg_id, 'avatarUrl': services.avatar.process_avatar_url(message.uface),