Skip to content

Commit

Permalink
optimize: LiveBiliDynamic new config: AT users list
Browse files Browse the repository at this point in the history
  • Loading branch information
snowtafir committed Jan 4, 2025
1 parent c25a8bc commit d5a2e1e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions defaultConfig/bilibili/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,9 @@ splitHeight: 8000
# 直播动态是否@全体成员,默认 0 关闭,1 开启。开启前请检查 <机器人> 是否有 [管理员权限] 或 [聊天平台是否支持],某些聊天平台或类型不支持@全体成员,如qq官方机器人等。
liveAtAll: 0

# 直播动态@全体成员的群组/聊天/私聊列表,默认为空即不在任何群于推送直播动态中执行@全体成员。开启liveAtAll后才会生效。
liveAtAllGroupList:
- 1234567890 # 示例群号

# 直播动态@全体成员的共享冷却时间CD,单位秒,默认 1800 秒(30分钟),即每个群聊30分钟内不论多少条直播动态,只会@一次。注意,qq群有 @全体成员 10次/日 的限制,所以请合理设置。
liveAtAllCD: 1800
7 changes: 4 additions & 3 deletions models/bilibili/bilibili.main.task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export class BiliTask {
let liveAtAll: boolean = biliConfigData.liveAtAll === true ? true : false; // 直播动态是否@全体成员,默认false
let liveAtAllCD: number = biliConfigData.liveAtAllCD || 1800; // 直播动态@全体成员 冷却时间CD,默认 30 分钟
let liveAtAllMark: number | string = await redis.get(`${markKey}${chatId}:liveAtAllMark`); // 直播动态@全体成员标记,默认 0
let liveAtAllGroupList = new Set(Array.isArray(biliConfigData.liveAtAllGroupList) ? biliConfigData.liveAtAllGroupList : []); // 直播动态@全体成员的群组列表,默认空数组,为空则不进行@全体成员操作

if (!!biliConfigData.pushMsgMode) {
const { data, uid } = await BiliQuery.formatDynamicData(pushDynamicData); // 处理动态数据
Expand Down Expand Up @@ -250,7 +251,7 @@ export class BiliTask {

(logger ?? Bot.logger)?.mark('优纪插件:B站动态执行推送');

if (liveAtAll && liveAtAllMark && extentData?.type === 'DYNAMIC_TYPE_LIVE_RCMD') {
if (liveAtAll && liveAtAllMark && extentData?.type === 'DYNAMIC_TYPE_LIVE_RCMD' && liveAtAllGroupList.has(chatId)) {
try {
await this.sendMessage(chatId, bot_id, chatType, segment.at('all'));
await redis.set(`${markKey}${chatId}:liveAtAllMark`, 1, { EX: liveAtAllCD }); // 设置直播动态@全体成员标记为 1
Expand Down Expand Up @@ -287,7 +288,7 @@ export class BiliTask {
let mergeTextPic: boolean = !!biliConfigData.mergeTextPic === false ? false : true; // 是否合并文本和图片,默认为 true
if (mergeTextPic) {
const mergeMsg = [...dynamicMsg.msg, ...dynamicMsg.pics];
if (liveAtAll && liveAtAllMark && dynamicMsg.dynamicType === 'DYNAMIC_TYPE_LIVE_RCMD') {
if (liveAtAll && liveAtAllMark && dynamicMsg.dynamicType === 'DYNAMIC_TYPE_LIVE_RCMD' && liveAtAllGroupList.has(chatId)) {
try {
await this.sendMessage(chatId, bot_id, chatType, segment.at('all'));
await redis.set(`${markKey}${chatId}:liveAtAllMark`, 1, { EX: liveAtAllCD }); // 设置直播动态@全体成员标记为 1
Expand All @@ -298,7 +299,7 @@ export class BiliTask {
}
await this.sendMessage(chatId, bot_id, chatType, mergeMsg);
} else {
if (liveAtAll && liveAtAllMark && dynamicMsg.dynamicType === 'DYNAMIC_TYPE_LIVE_RCMD') {
if (liveAtAll && liveAtAllMark && dynamicMsg.dynamicType === 'DYNAMIC_TYPE_LIVE_RCMD' && liveAtAllGroupList.has(chatId)) {
try {
await this.sendMessage(chatId, bot_id, chatType, segment.at('all'));
await redis.set(`${markKey}${chatId}:liveAtAllMark`, 1, { EX: liveAtAllCD }); // 设置直播动态@全体成员标记为 1
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yuki-plugin",
"version": "2.0.6-5",
"version": "2.0.6-6",
"author": "snowtafir",
"description": "优纪插件,yunzai-V4 关于 微博推送、B站推送 等功能的拓展插件",
"main": "./index",
Expand Down

0 comments on commit d5a2e1e

Please sign in to comment.