支持屏蔽跨房弹幕

This commit is contained in:
John Smith
2026-02-08 15:48:48 +08:00
parent 4e8521d27a
commit aa697ac7c8
14 changed files with 53 additions and 10 deletions

View File

@@ -74,6 +74,7 @@ def make_text_message_data(
content_type_params: list = None,
uid: str = '',
medal_name: str = '',
is_mirror: bool = False,
):
# 为了节省带宽用list而不是dict
return [
@@ -113,6 +114,8 @@ def make_text_message_data(
uid,
# 17: medalName
medal_name,
# 18: isMirror
1 if is_mirror else 0,
]

Submodule blivedm updated: 438d7ac89d...5e01cdfa75

View File

@@ -227,6 +227,11 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
this.discardWebsocket()
}
dmMirrorCallback(command) {
command._isMirror = true
this.dmCallback(command)
}
dmCallback(command) {
let data = command.data
@@ -262,6 +267,7 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
medalLevel: data.fans_medal_wearing_status ? data.fans_medal_level : 0,
id: data.msg_id,
emoticon: emoticon,
isMirror: Boolean(command._isMirror),
// 给模板用的字段
uid: data.open_id,
medalName: data.fans_medal_wearing_status ? data.fans_medal_name : '',
@@ -342,7 +348,7 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
const CMD_CALLBACK_MAP = {
LIVE_OPEN_PLATFORM_INTERACTION_END: ChatClientDirectOpenLive.prototype.interactionEndCallback,
LIVE_OPEN_PLATFORM_DM: ChatClientDirectOpenLive.prototype.dmCallback,
LIVE_OPEN_PLATFORM_DM_MIRROR: ChatClientDirectOpenLive.prototype.dmCallback,
LIVE_OPEN_PLATFORM_DM_MIRROR: ChatClientDirectOpenLive.prototype.dmMirrorCallback,
LIVE_OPEN_PLATFORM_SEND_GIFT: ChatClientDirectOpenLive.prototype.sendGiftCallback,
LIVE_OPEN_PLATFORM_GUARD: ChatClientDirectOpenLive.prototype.guardCallback,
LIVE_OPEN_PLATFORM_SUPER_CHAT: ChatClientDirectOpenLive.prototype.superChatCallback,

View File

@@ -67,6 +67,11 @@ export default class ChatClientDirectWeb extends ChatClientOfficialBase {
this.websocket.send(this.makePacket(authParams, base.OP_AUTH))
}
async danmuMsgMirrorCallback(command) {
command._isMirror = true
this.danmuMsgCallback(command)
}
async danmuMsgCallback(command) {
let info = command.info
@@ -131,6 +136,7 @@ export default class ChatClientDirectWeb extends ChatClientOfficialBase {
isMobileVerified: Boolean(info[2][6]),
medalLevel: medalRoomId === this.roomId ? medalLevel : 0,
emoticon: info[0][13].url || null,
isMirror: Boolean(command._isMirror),
// 给模板用的字段
uid: info[2][0] ? info[2][0].toString() : authorName,
medalName: medalRoomId === this.roomId ? medalName : '',
@@ -252,7 +258,7 @@ export default class ChatClientDirectWeb extends ChatClientOfficialBase {
const CMD_CALLBACK_MAP = {
DANMU_MSG: ChatClientDirectWeb.prototype.danmuMsgCallback,
DANMU_MSG_MIRROR: ChatClientDirectWeb.prototype.danmuMsgCallback,
DANMU_MSG_MIRROR: ChatClientDirectWeb.prototype.danmuMsgMirrorCallback,
SEND_GIFT: ChatClientDirectWeb.prototype.sendGiftCallback,
USER_TOAST_MSG_V2: ChatClientDirectWeb.prototype.userToastV2Callback,
SUPER_CHAT_MESSAGE: ChatClientDirectWeb.prototype.superChatMessageCallback,

View File

@@ -182,6 +182,7 @@ export default class ChatClientRelay {
id: data[11],
translation: data[12],
emoticon: emoticon,
isMirror: data[18],
uid: data[16],
medalName: data[17],
})

View File

@@ -18,6 +18,7 @@ export class AddTextMsg {
id = getUuid4Hex(),
translation = '',
emoticon = null,
isMirror = false,
// 给模板用的字段
uid = '',
medalName = '',
@@ -36,6 +37,7 @@ export class AddTextMsg {
this.id = id
this.translation = translation
this.emoticon = emoticon
this.isMirror = isMirror
// 给模板用的字段
this.uid = uid
this.medalName = medalName

View File

@@ -12,6 +12,7 @@ export const DEFAULT_CONFIG = {
maxNumber: 60,
blockGiftDanmaku: true,
blockMirrorMessages: false,
blockLevel: 0,
blockNewbie: false,
blockNotMobileVerified: false,

View File

@@ -174,14 +174,21 @@ export function getShowContent(message) {
}
export function getShowContentParts(message) {
let contentParts = [...message.contentParts]
let frontParts = []
if (message.isMirror) {
frontParts.push({
type: CONTENT_PART_TYPE_TEXT,
text: i18n.i18n.t('chat.mirrorMsg')
})
}
let backParts = []
if (message.translation) {
contentParts.push({
backParts.push({
type: CONTENT_PART_TYPE_TEXT,
text: `${message.translation}`
})
}
return contentParts
return frontParts.concat(message.contentParts, backParts)
}
export function getGiftShowContent(message, showGiftName) {

View File

@@ -36,6 +36,7 @@ export default {
block: 'Block',
giftDanmaku: 'Block system messages (gift effect)',
mirrorMessage: 'Block mirror messages',
blockLevel: 'Block user level lower than',
informalUser: 'Block informal users',
unverifiedUser: 'Block unverified users',
@@ -195,6 +196,7 @@ export default {
guardLevel1: 'governor',
guardLevel2: 'admiral',
guardLevel3: 'captain',
mirrorMsg: '[Mirror] ',
sendGift: 'Sent {giftName}x{num}',
membershipTitle: 'New member',
tickerMembership: 'Member'

View File

@@ -36,6 +36,7 @@ export default {
block: 'ブロック',
giftDanmaku: 'ブロックシステムコメント(プレゼント効果)',
mirrorMessage: 'ブロック転送コメント',
blockLevel: 'ブロックユーザーレベルがx未満',
informalUser: 'ブロック非公式ユーザー',
unverifiedUser: 'ブロック認証されていないユーザー',
@@ -195,6 +196,7 @@ export default {
guardLevel1: '総督',
guardLevel2: '提督',
guardLevel3: '艦長',
mirrorMsg: '[転送] ',
sendGift: '{giftName}x{num} を贈りました',
membershipTitle: '新規メンバー',
tickerMembership: 'メンバー'

View File

@@ -35,7 +35,8 @@ export default {
maxNumber: '最大弹幕数',
block: '屏蔽',
giftDanmaku: '屏蔽礼物弹幕',
giftDanmaku: '屏蔽抽奖弹幕',
mirrorMessage: '屏蔽跨房弹幕',
blockLevel: '屏蔽用户等级低于',
informalUser: '屏蔽非正式会员',
unverifiedUser: '屏蔽未绑定手机用户',
@@ -193,6 +194,7 @@ export default {
guardLevel1: '总督',
guardLevel2: '提督',
guardLevel3: '舰长',
mirrorMsg: '[跨房] ',
sendGift: '赠送 {giftName}x{num}',
membershipTitle: '新会员',
tickerMembership: '会员'

View File

@@ -100,19 +100,24 @@
<el-tab-pane :label="$t('home.block')">
<el-row :gutter="20">
<el-col :xs="24" :sm="8">
<el-col :xs="24" :sm="6">
<el-form-item :label="$t('home.giftDanmaku')">
<el-switch v-model="form.blockGiftDanmaku"></el-switch>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="8">
<el-col :xs="24" :sm="6">
<el-form-item :label="$t('home.mirrorMessage')">
<el-switch v-model="form.blockMirrorMessages"></el-switch>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="6">
<el-tooltip :content="$t('home.unavailableWhenUsingAuthCode')">
<el-form-item :label="$t('home.informalUser')">
<el-switch v-model="form.blockNewbie"></el-switch>
</el-form-item>
</el-tooltip>
</el-col>
<el-col :xs="24" :sm="8">
<el-col :xs="24" :sm="6">
<el-tooltip :content="$t('home.unavailableWhenUsingAuthCode')">
<el-form-item :label="$t('home.unverifiedUser')">
<el-switch v-model="form.blockNotMobileVerified"></el-switch>

View File

@@ -358,6 +358,7 @@ export default {
cfg.maxNumber = toInt(cfg.maxNumber, chatConfig.DEFAULT_CONFIG.maxNumber)
cfg.blockGiftDanmaku = toBool(cfg.blockGiftDanmaku)
cfg.blockMirrorMessages = toBool(cfg.blockMirrorMessages)
cfg.blockLevel = toInt(cfg.blockLevel, chatConfig.DEFAULT_CONFIG.blockLevel)
cfg.blockNewbie = toBool(cfg.blockNewbie)
cfg.blockNotMobileVerified = toBool(cfg.blockNotMobileVerified)
@@ -485,6 +486,7 @@ export default {
privilegeType: data.privilegeType,
repeated: 1,
translation: this.config.autoTranslate ? data.translation : '',
isMirror: data.isMirror,
// 给模板用的字段
uid: data.uid,
medalLevel: data.medalLevel,
@@ -625,6 +627,8 @@ export default {
filterTextMessage(data) {
if (this.config.blockGiftDanmaku && data.isGiftDanmaku) {
return false
} else if (this.config.blockMirrorMessages && data.isMirror) {
return false
} else if (this.config.blockLevel > 0 && data.authorLevel < this.config.blockLevel) {
return false
} else if (this.config.blockNewbie && data.isNewbie) {

View File

@@ -568,6 +568,7 @@ class LiveMsgHandler(blivedm.BaseHandler):
translation=translation,
content_type=content_type,
content_type_params=content_type_params,
is_mirror=message.is_mirror,
# 给插件用的字段
uid=str(message.uid) if message.uid != 0 else message.uname,
medal_name='' if message.medal_room_id != client.room_id else message.medal_name,
@@ -787,6 +788,7 @@ class LiveMsgHandler(blivedm.BaseHandler):
translation=translation,
content_type=content_type,
content_type_params=content_type_params,
is_mirror=message.is_mirror,
# 给插件用的字段
uid=message.open_id,
medal_name='' if not message.fans_medal_wearing_status else message.fans_medal_name,