支持显示at人、开放平台接口支持显示房管

This commit is contained in:
John Smith 2025-01-19 17:09:02 +08:00
parent 87922e0809
commit 3b343464ae
5 changed files with 41 additions and 7 deletions

View File

@ -11,7 +11,7 @@
## 特性
* 兼容YouTube直播评论栏的样式
* 高亮舰队、 ~~房管~~ 、主播的用户名
* 高亮舰队、房管、主播的用户名
* 自带两种样式生成器经典YouTube风格和仿微信风格
* 支持屏蔽弹幕、合并礼物等设置
* 支持前端直连B站服务器或者通过后端转发

@ -1 +1 @@
Subproject commit 0685fe1cfd06157db74fb203f17eb499748d3cd4
Subproject commit 100ed8fdf970bb105a69df52d63ffd49a64b7cf6

View File

@ -233,12 +233,19 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
let authorType
if (data.open_id === this.roomOwnerOpenId) {
authorType = 3
} else if (data.is_admin) {
authorType = 2
} else if (data.guard_level !== 0) {
authorType = 1
} else {
authorType = 0
}
let showContent = data.msg
if (data.reply_uname !== '') {
showContent = `@${data.reply_uname} ${showContent}`
}
let emoticon = null
if (data.dm_type === 1) {
emoticon = data.emoji_img_url
@ -249,7 +256,7 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
timestamp: data.timestamp,
authorName: data.uname,
authorType: authorType,
content: data.msg,
content: showContent,
privilegeType: data.guard_level,
isGiftDanmaku: chat.isGiftDanmakuByContent(data.msg),
medalLevel: data.fans_medal_wearing_status ? data.fans_medal_level : 0,

View File

@ -98,14 +98,30 @@ export default class ChatClientDirectWeb extends ChatClientOfficialBase {
authorType = 0
}
let authorName = info[2][1]
let extra
try {
extra = modeInfo.extra
if (typeof extra !== 'object') {
extra = JSON.parse(extra)
}
} catch {
extra = {}
}
let content = info[1]
let replyUname = extra.reply_uname ?? ''
let showContent = content
if (replyUname !== '') {
showContent = `@${replyUname} ${showContent}`
}
let authorName = info[2][1]
let data = new chatModels.AddTextMsg({
avatarUrl: avatarUrl,
timestamp: info[0][4] / 1000,
authorName: authorName,
authorType: authorType,
content: content,
content: showContent,
privilegeType: privilegeType,
isGiftDanmaku: Boolean(info[0][9]) || chat.isGiftDanmakuByContent(content),
authorLevel: info[4][0],

View File

@ -524,6 +524,11 @@ class LiveMsgHandler(blivedm.BaseHandler):
else:
author_type = 0
show_content = message.msg
reply_uname = message.extra_dict.get('reply_uname', '')
if reply_uname != '':
show_content = f'@{reply_uname} {show_content}'
if message.dm_type == 1:
content_type = api.chat.ContentType.EMOTICON
content_type_params = api.chat.make_emoticon_params(
@ -552,7 +557,7 @@ class LiveMsgHandler(blivedm.BaseHandler):
timestamp=int(message.timestamp / 1000),
author_name=message.uname,
author_type=author_type,
content=message.msg,
content=show_content,
privilege_type=message.privilege_type,
is_gift_danmaku=bool(message.msg_type),
author_level=message.user_level,
@ -736,11 +741,17 @@ class LiveMsgHandler(blivedm.BaseHandler):
if message.open_id == client.room_owner_open_id:
author_type = 3 # 主播
elif message.is_admin:
author_type = 2 # 房管
elif message.guard_level != 0: # 1总督2提督3舰长
author_type = 1 # 舰队
else:
author_type = 0
show_content = message.msg
if message.reply_uname != '':
show_content = f'@{message.reply_uname} {show_content}'
if message.dm_type == 1:
content_type = api.chat.ContentType.EMOTICON
content_type_params = api.chat.make_emoticon_params(message.emoji_img_url)
@ -766,7 +777,7 @@ class LiveMsgHandler(blivedm.BaseHandler):
timestamp=message.timestamp,
author_name=message.uname,
author_type=author_type,
content=message.msg,
content=show_content,
privilege_type=message.guard_level,
medal_level=0 if not message.fans_medal_wearing_status else message.fans_medal_level,
id_=message.msg_id,