From dae5f782db364d3cd2d3061b5ad231b8d58009a8 Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 20 Sep 2023 22:50:50 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=9D=E5=A4=96=E9=80=9A=E8=BF=87=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=9D=A5=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E6=98=AF?= =?UTF-8?q?=E7=A4=BC=E7=89=A9=E5=BC=B9=E5=B9=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/api/chat/ChatClientDirectOpenLive.js | 2 +- frontend/src/api/chat/ChatClientDirectWeb.js | 5 ++-- frontend/src/api/chat/ChatClientRelay.js | 5 ++-- frontend/src/api/chat/index.js | 29 +++++++++++++++++++ 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/frontend/src/api/chat/ChatClientDirectOpenLive.js b/frontend/src/api/chat/ChatClientDirectOpenLive.js index b6bf53f..4f48050 100644 --- a/frontend/src/api/chat/ChatClientDirectOpenLive.js +++ b/frontend/src/api/chat/ChatClientDirectOpenLive.js @@ -174,7 +174,7 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase { authorType: authorType, content: data.msg, privilegeType: data.guard_level, - isGiftDanmaku: false, + isGiftDanmaku: chat.isGiftDanmakuByContent(data.msg), authorLevel: 1, isNewbie: false, isMobileVerified: true, diff --git a/frontend/src/api/chat/ChatClientDirectWeb.js b/frontend/src/api/chat/ChatClientDirectWeb.js index 1bfc20a..414f38e 100644 --- a/frontend/src/api/chat/ChatClientDirectWeb.js +++ b/frontend/src/api/chat/ChatClientDirectWeb.js @@ -90,14 +90,15 @@ export default class ChatClientDirectWeb extends ChatClientOfficialBase { } let authorName = info[2][1] + let content = info[1] let data = { avatarUrl: await chat.getAvatarUrl(uid, authorName), timestamp: info[0][4] / 1000, authorName: authorName, authorType: authorType, - content: info[1], + content: content, privilegeType: privilegeType, - isGiftDanmaku: Boolean(info[0][9]), + isGiftDanmaku: Boolean(info[0][9]) || chat.isGiftDanmakuByContent(content), authorLevel: info[4][0], isNewbie: info[2][5] < 10000, isMobileVerified: Boolean(info[2][6]), diff --git a/frontend/src/api/chat/ChatClientRelay.js b/frontend/src/api/chat/ChatClientRelay.js index bc6b059..009a5a0 100644 --- a/frontend/src/api/chat/ChatClientRelay.js +++ b/frontend/src/api/chat/ChatClientRelay.js @@ -133,14 +133,15 @@ export default class ChatClientRelay { emoticon = contentTypeParams[0] } + let content = data[4] data = { avatarUrl: data[0], timestamp: data[1], authorName: data[2], authorType: data[3], - content: data[4], + content: content, privilegeType: data[5], - isGiftDanmaku: Boolean(data[6]), + isGiftDanmaku: Boolean(data[6]) || chat.isGiftDanmakuByContent(content), authorLevel: data[7], isNewbie: Boolean(data[8]), isMobileVerified: Boolean(data[9]), diff --git a/frontend/src/api/chat/index.js b/frontend/src/api/chat/index.js index ae1a352..0b3d6ce 100644 --- a/frontend/src/api/chat/index.js +++ b/frontend/src/api/chat/index.js @@ -42,3 +42,32 @@ export async function getTextEmoticons() { } return res.textEmoticons } + +// 开放平台接口不会发送是否是礼物弹幕,只能用内容判断了 +const GIFT_DANMAKU_CONTENTS = new Set([ + // 红包 + '老板大气!点点红包抽礼物', + '老板大气!点点红包抽礼物!', + '点点红包,关注主播抽礼物~', + '喜欢主播加关注,点点红包抽礼物', + '红包抽礼物,开启今日好运!', + '中奖喷雾!中奖喷雾!', + // 节奏风暴 + '前方高能预警,注意这不是演习', + '我从未见过如此厚颜无耻之人', + '那万一赢了呢', + '你们城里人真会玩', + '左舷弹幕太薄了', + '要优雅,不要污', + '我选择狗带', + '可爱即正义~~', + '糟了,是心动的感觉!', + '这个直播间已经被我们承包了!', + '妈妈问我为什么跪着看直播 w(゚Д゚)w', + '你们对力量一无所知~( ̄▽ ̄)~', + // 好像花式夸夸还有,不想花钱收集内容了 +]) + +export function isGiftDanmakuByContent(content) { + return GIFT_DANMAKU_CONTENTS.has(content) +}