koishi-plugin-bilibili-notify 3.0.0-beta.0 → 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/comRegister.d.ts +10 -8
- package/lib/comRegister.js +75 -51
- package/lib/generateImg.d.ts +12 -2
- package/lib/generateImg.js +13 -13
- package/lib/index.d.ts +2 -0
- package/lib/index.js +29 -0
- package/lib/type/index.d.ts +7 -0
- package/package.json +1 -1
- package/readme.md +2 -0
package/lib/comRegister.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Bot, type Context, type FlatPick, type Logger, Schema } from "koishi";
|
|
2
2
|
import type { Notifier } from "@koishijs/plugin-notifier";
|
|
3
3
|
import type { LoginBili } from "./database";
|
|
4
|
-
import { LiveType, type MasterInfo, type SubManager, type Target } from "./type";
|
|
4
|
+
import { LiveType, type MasterInfo, type SubItem, type SubManager, type Target } from "./type";
|
|
5
5
|
declare class ComRegister {
|
|
6
6
|
static inject: string[];
|
|
7
7
|
qqRelatedBotList: Array<string>;
|
|
@@ -28,15 +28,9 @@ declare class ComRegister {
|
|
|
28
28
|
sendMsg(targets: Target, content: any, live?: boolean): Promise<void>;
|
|
29
29
|
dynamicDetect(): (...args: any[]) => void;
|
|
30
30
|
debug_dynamicDetect(): (...args: any[]) => void;
|
|
31
|
-
sendLiveNotifyCard(info: {
|
|
32
|
-
username: string;
|
|
33
|
-
userface: string;
|
|
34
|
-
target: Target;
|
|
35
|
-
data: any;
|
|
36
|
-
}, liveType: LiveType, followerDisplay: string, liveNotifyMsg?: string): Promise<void>;
|
|
37
31
|
useMasterInfo(uid: string, masterInfo: MasterInfo, liveType: LiveType): Promise<MasterInfo>;
|
|
38
32
|
useLiveRoomInfo(roomId: string): Promise<any>;
|
|
39
|
-
liveDetectWithListener(roomId: string, target: Target): Promise<void>;
|
|
33
|
+
liveDetectWithListener(roomId: string, target: Target, cardStyle: SubItem["card"]): Promise<void>;
|
|
40
34
|
subShow(): string;
|
|
41
35
|
updateSubNotifier(): void;
|
|
42
36
|
checkIfLoginInfoIsLoaded(): Promise<unknown>;
|
|
@@ -65,6 +59,13 @@ declare namespace ComRegister {
|
|
|
65
59
|
}>;
|
|
66
60
|
platform: string;
|
|
67
61
|
}>;
|
|
62
|
+
card: {
|
|
63
|
+
enable: boolean;
|
|
64
|
+
cardColorStart: string;
|
|
65
|
+
cardColorEnd: string;
|
|
66
|
+
cardBasePlateColor: string;
|
|
67
|
+
cardBasePlateBorder: string;
|
|
68
|
+
};
|
|
68
69
|
}>;
|
|
69
70
|
master: {
|
|
70
71
|
enable: boolean;
|
|
@@ -76,6 +77,7 @@ declare namespace ComRegister {
|
|
|
76
77
|
liveDetectMode: "API" | "WS";
|
|
77
78
|
restartPush: boolean;
|
|
78
79
|
pushTime: number;
|
|
80
|
+
pushImgsInDynamic: boolean;
|
|
79
81
|
liveLoopTime: number;
|
|
80
82
|
customLiveStart: string;
|
|
81
83
|
customLive: string;
|
package/lib/comRegister.js
CHANGED
|
@@ -590,7 +590,7 @@ class ComRegister {
|
|
|
590
590
|
// 推送该条动态
|
|
591
591
|
const buffer = await (0, utils_1.withRetry)(async () => {
|
|
592
592
|
// 渲染图片
|
|
593
|
-
return await this.ctx.gi.generateDynamicImg(items[num]);
|
|
593
|
+
return await this.ctx.gi.generateDynamicImg(items[num], sub.card);
|
|
594
594
|
}, 1).catch(async (e) => {
|
|
595
595
|
// 直播开播动态,不做处理
|
|
596
596
|
if (e.message === "直播开播动态,不做处理")
|
|
@@ -604,12 +604,14 @@ class ComRegister {
|
|
|
604
604
|
}
|
|
605
605
|
if (e.message === "已屏蔽转发动态") {
|
|
606
606
|
if (this.config.filter.notify) {
|
|
607
|
-
await this.sendMsg(sub.target, `${upName}
|
|
607
|
+
await this.sendMsg(sub.target, `${upName}转发了一条动态,已屏蔽`);
|
|
608
608
|
}
|
|
609
609
|
return;
|
|
610
610
|
}
|
|
611
611
|
// 未知错误
|
|
612
612
|
this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
|
|
613
|
+
// 发送私聊消息并重启服务
|
|
614
|
+
await this.sendPrivateMsgAndStopService();
|
|
613
615
|
});
|
|
614
616
|
// 判断是否执行成功,未执行成功直接返回
|
|
615
617
|
if (!buffer)
|
|
@@ -622,6 +624,19 @@ class ComRegister {
|
|
|
622
624
|
this.logger.info("推送动态中...");
|
|
623
625
|
// 发送推送卡片
|
|
624
626
|
await this.sendMsg(sub.target, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/png"), dUrl] }));
|
|
627
|
+
// 判断是否需要发送动态中的图片
|
|
628
|
+
if (this.config.pushImgsInDynamic) {
|
|
629
|
+
// 判断是否为图文动态,且存在draw
|
|
630
|
+
if (items[num].type === "DYNAMIC_TYPE_DRAW" &&
|
|
631
|
+
items[num].modules.module_dynamic.major?.draw) {
|
|
632
|
+
for (const img of items[num].modules.module_dynamic.major.draw
|
|
633
|
+
.items) {
|
|
634
|
+
await this.sendMsg(sub.target, (0, jsx_runtime_1.jsx)("img", { src: img.src, alt: "\u52A8\u6001\u56FE\u7247" }));
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
// logger
|
|
639
|
+
this.logger.info("动态推送完毕!");
|
|
625
640
|
}
|
|
626
641
|
}
|
|
627
642
|
}
|
|
@@ -763,7 +778,7 @@ class ComRegister {
|
|
|
763
778
|
// 推送该条动态
|
|
764
779
|
const buffer = await (0, utils_1.withRetry)(async () => {
|
|
765
780
|
// 渲染图片
|
|
766
|
-
return await this.ctx.gi.generateDynamicImg(items[num]);
|
|
781
|
+
return await this.ctx.gi.generateDynamicImg(items[num], sub.card);
|
|
767
782
|
}, 1).catch(async (e) => {
|
|
768
783
|
// 直播开播动态,不做处理
|
|
769
784
|
if (e.message === "直播开播动态,不做处理")
|
|
@@ -783,18 +798,38 @@ class ComRegister {
|
|
|
783
798
|
}
|
|
784
799
|
// 未知错误
|
|
785
800
|
this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
|
|
801
|
+
// 发送私聊消息并重启服务
|
|
802
|
+
await this.sendPrivateMsgAndStopService();
|
|
786
803
|
});
|
|
787
|
-
//
|
|
804
|
+
// 屏蔽动态直接返回
|
|
788
805
|
if (!buffer)
|
|
789
|
-
return
|
|
806
|
+
return;
|
|
790
807
|
// 判断是否需要发送URL
|
|
791
808
|
const dUrl = this.config.dynamicUrl
|
|
792
809
|
? `${upName}发布了一条动态:https://t.bilibili.com/${dynamicId}`
|
|
793
810
|
: "";
|
|
794
|
-
//
|
|
811
|
+
// logger
|
|
795
812
|
this.logger.info("推送动态中...");
|
|
796
|
-
//
|
|
813
|
+
// 推送动态卡片
|
|
797
814
|
await this.sendMsg(sub.target, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/png"), dUrl] }));
|
|
815
|
+
// 判断是否需要发送动态中的图片
|
|
816
|
+
if (this.config.pushImgsInDynamic) {
|
|
817
|
+
// 判断是否为图文动态,且存在draw
|
|
818
|
+
if (items[num].type === "DYNAMIC_TYPE_DRAW" &&
|
|
819
|
+
items[num].modules.module_dynamic.major?.draw) {
|
|
820
|
+
// logger
|
|
821
|
+
this.logger.info("推送动态图片中...");
|
|
822
|
+
// 循环遍历图片
|
|
823
|
+
for (const img of items[num].modules.module_dynamic.major.draw
|
|
824
|
+
.items) {
|
|
825
|
+
await this.sendMsg(sub.target, (0, jsx_runtime_1.jsx)("img", { src: img.src, alt: "\u52A8\u6001\u56FE\u7247" }));
|
|
826
|
+
}
|
|
827
|
+
// logger
|
|
828
|
+
this.logger.info("推送动态图片完毕!");
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
// logger
|
|
832
|
+
this.logger.info("动态推送完毕!");
|
|
798
833
|
}
|
|
799
834
|
}
|
|
800
835
|
}
|
|
@@ -802,23 +837,6 @@ class ComRegister {
|
|
|
802
837
|
// 加工handler并返回
|
|
803
838
|
return (0, utils_1.withLock)(handler);
|
|
804
839
|
}
|
|
805
|
-
// 定义发送直播通知卡片方法
|
|
806
|
-
async sendLiveNotifyCard(info, liveType, followerDisplay, liveNotifyMsg) {
|
|
807
|
-
// 生成图片
|
|
808
|
-
const buffer = await (0, utils_1.withRetry)(async () => {
|
|
809
|
-
// 获取直播通知卡片
|
|
810
|
-
return await this.ctx.gi.generateLiveImg(info.data, info.username, info.userface, followerDisplay, liveType);
|
|
811
|
-
}, 1).catch((e) => {
|
|
812
|
-
this.logger.error(`liveDetect generateLiveImg() 推送卡片生成失败,原因:${e.message}`);
|
|
813
|
-
});
|
|
814
|
-
// 发送私聊消息并重启服务
|
|
815
|
-
if (!buffer)
|
|
816
|
-
return await this.sendPrivateMsgAndStopService();
|
|
817
|
-
// 推送直播信息
|
|
818
|
-
const msg = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/png"), liveNotifyMsg || ""] }));
|
|
819
|
-
// 只有在开播时才艾特全体成员
|
|
820
|
-
return await this.sendMsg(info.target, msg, liveType === type_1.LiveType.StartBroadcasting);
|
|
821
|
-
}
|
|
822
840
|
// 定义获取主播信息方法
|
|
823
841
|
async useMasterInfo(uid, masterInfo, liveType) {
|
|
824
842
|
// 获取主播信息
|
|
@@ -871,7 +889,7 @@ class ComRegister {
|
|
|
871
889
|
// 返回
|
|
872
890
|
return data;
|
|
873
891
|
}
|
|
874
|
-
async liveDetectWithListener(roomId, target) {
|
|
892
|
+
async liveDetectWithListener(roomId, target, cardStyle) {
|
|
875
893
|
// 定义开播时间
|
|
876
894
|
let liveTime;
|
|
877
895
|
// 定义定时推送定时器
|
|
@@ -888,6 +906,23 @@ class ComRegister {
|
|
|
888
906
|
let liveRoomInfo;
|
|
889
907
|
let masterInfo;
|
|
890
908
|
let watchedNum;
|
|
909
|
+
// 定义发送直播通知卡片方法
|
|
910
|
+
const sendLiveNotifyCard = async (liveType, followerDisplay, liveNotifyMsg) => {
|
|
911
|
+
// 生成图片
|
|
912
|
+
const buffer = await (0, utils_1.withRetry)(async () => {
|
|
913
|
+
// 获取直播通知卡片
|
|
914
|
+
return await this.ctx.gi.generateLiveImg(liveRoomInfo, masterInfo.username, masterInfo.userface, followerDisplay, liveType, cardStyle);
|
|
915
|
+
}, 1).catch((e) => {
|
|
916
|
+
this.logger.error(`liveDetect generateLiveImg() 推送卡片生成失败,原因:${e.message}`);
|
|
917
|
+
});
|
|
918
|
+
// 发送私聊消息并重启服务
|
|
919
|
+
if (!buffer)
|
|
920
|
+
return await this.sendPrivateMsgAndStopService();
|
|
921
|
+
// 推送直播信息
|
|
922
|
+
const msg = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, "image/png"), liveNotifyMsg || ""] }));
|
|
923
|
+
// 只有在开播时才艾特全体成员
|
|
924
|
+
return await this.sendMsg(target, msg, liveType === type_1.LiveType.StartBroadcasting);
|
|
925
|
+
};
|
|
891
926
|
// 找到频道/群组对应的
|
|
892
927
|
const liveGuardBuyPushTargetArr = target.map((channel) => {
|
|
893
928
|
// 获取符合条件的target
|
|
@@ -920,12 +955,7 @@ class ComRegister {
|
|
|
920
955
|
.replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`)
|
|
921
956
|
: null;
|
|
922
957
|
// 发送直播通知卡片
|
|
923
|
-
await
|
|
924
|
-
username: masterInfo.username,
|
|
925
|
-
userface: masterInfo.userface,
|
|
926
|
-
target,
|
|
927
|
-
data: liveRoomInfo,
|
|
928
|
-
}, type_1.LiveType.LiveBroadcast, watched, liveMsg);
|
|
958
|
+
await sendLiveNotifyCard(type_1.LiveType.LiveBroadcast, watched, liveMsg);
|
|
929
959
|
};
|
|
930
960
|
// 定义直播间信息获取函数
|
|
931
961
|
const useMasterAndLiveRoomInfo = async (liveType) => {
|
|
@@ -971,7 +1001,7 @@ class ComRegister {
|
|
|
971
1001
|
},
|
|
972
1002
|
onGuardBuy: ({ body }) => {
|
|
973
1003
|
// 定义消息
|
|
974
|
-
const content =
|
|
1004
|
+
const content = `[${masterInfo.username}的直播间]「${body.user.uname}」加入了大航海(${body.gift_name})`;
|
|
975
1005
|
// 直接发送消息
|
|
976
1006
|
channelIdArrLen > 0 && this.sendMsg(liveGuardBuyPushTargetArr, content);
|
|
977
1007
|
},
|
|
@@ -1003,12 +1033,7 @@ class ComRegister {
|
|
|
1003
1033
|
.replace("-link", `https://live.bilibili.com/${liveRoomInfo.short_id === 0 ? liveRoomInfo.room_id : liveRoomInfo.short_id}`)
|
|
1004
1034
|
: null;
|
|
1005
1035
|
// 推送开播通知
|
|
1006
|
-
await
|
|
1007
|
-
username: masterInfo.username,
|
|
1008
|
-
userface: masterInfo.userface,
|
|
1009
|
-
target,
|
|
1010
|
-
data: liveRoomInfo,
|
|
1011
|
-
}, type_1.LiveType.StartBroadcasting, follower, liveStartMsg);
|
|
1036
|
+
await sendLiveNotifyCard(type_1.LiveType.StartBroadcasting, follower, liveStartMsg);
|
|
1012
1037
|
// 判断定时器是否已开启
|
|
1013
1038
|
if (!pushAtTimeTimer) {
|
|
1014
1039
|
// 开始直播,开启定时器
|
|
@@ -1049,12 +1074,7 @@ class ComRegister {
|
|
|
1049
1074
|
.replace("-follower_change", followerChange)
|
|
1050
1075
|
: null;
|
|
1051
1076
|
// 推送通知卡片
|
|
1052
|
-
await
|
|
1053
|
-
username: masterInfo.username,
|
|
1054
|
-
userface: masterInfo.userface,
|
|
1055
|
-
target,
|
|
1056
|
-
data: liveRoomInfo,
|
|
1057
|
-
}, type_1.LiveType.StopBroadcast, followerChange, liveEndMsg);
|
|
1077
|
+
await sendLiveNotifyCard(type_1.LiveType.StopBroadcast, followerChange, liveEndMsg);
|
|
1058
1078
|
// 关闭定时推送定时器
|
|
1059
1079
|
pushAtTimeTimer();
|
|
1060
1080
|
// 将推送定时器变量置空
|
|
@@ -1084,12 +1104,7 @@ class ComRegister {
|
|
|
1084
1104
|
: null;
|
|
1085
1105
|
// 发送直播通知卡片
|
|
1086
1106
|
if (this.config.restartPush) {
|
|
1087
|
-
await
|
|
1088
|
-
username: masterInfo.username,
|
|
1089
|
-
userface: masterInfo.userface,
|
|
1090
|
-
target,
|
|
1091
|
-
data: liveRoomInfo,
|
|
1092
|
-
}, type_1.LiveType.LiveBroadcast, watched, liveMsg);
|
|
1107
|
+
await sendLiveNotifyCard(type_1.LiveType.LiveBroadcast, watched, liveMsg);
|
|
1093
1108
|
}
|
|
1094
1109
|
// 正在直播,开启定时器,判断定时器是否已开启
|
|
1095
1110
|
if (!pushAtTimeTimer) {
|
|
@@ -1276,7 +1291,7 @@ class ComRegister {
|
|
|
1276
1291
|
// 判断是否订阅直播
|
|
1277
1292
|
if (sub.live) {
|
|
1278
1293
|
// 启动直播监测
|
|
1279
|
-
await this.liveDetectWithListener(data.live_room.roomid, sub.target);
|
|
1294
|
+
await this.liveDetectWithListener(data.live_room.roomid, sub.target, sub.card);
|
|
1280
1295
|
}
|
|
1281
1296
|
}
|
|
1282
1297
|
// 在B站中订阅该对象
|
|
@@ -1294,6 +1309,7 @@ class ComRegister {
|
|
|
1294
1309
|
platform: "",
|
|
1295
1310
|
live: sub.live,
|
|
1296
1311
|
dynamic: sub.dynamic,
|
|
1312
|
+
card: sub.card,
|
|
1297
1313
|
});
|
|
1298
1314
|
this.logger.info(`UID:${sub.uid}订阅加载完毕!`);
|
|
1299
1315
|
}
|
|
@@ -1340,6 +1356,13 @@ class ComRegister {
|
|
|
1340
1356
|
})).description("频道/群组信息"),
|
|
1341
1357
|
platform: koishi_1.Schema.string().description("推送平台"),
|
|
1342
1358
|
})).description("订阅用户需要发送的频道/群组信息"),
|
|
1359
|
+
card: koishi_1.Schema.object({
|
|
1360
|
+
enable: koishi_1.Schema.boolean(),
|
|
1361
|
+
cardColorStart: koishi_1.Schema.string(),
|
|
1362
|
+
cardColorEnd: koishi_1.Schema.string(),
|
|
1363
|
+
cardBasePlateColor: koishi_1.Schema.string(),
|
|
1364
|
+
cardBasePlateBorder: koishi_1.Schema.string(),
|
|
1365
|
+
}).description("自定义推送卡片颜色,默认使用插件内置的颜色,设置后会覆盖插件内置的颜色"),
|
|
1343
1366
|
}))
|
|
1344
1367
|
.role("table")
|
|
1345
1368
|
.description("手动输入订阅信息,方便自定义订阅内容,这里的订阅内容不会存入数据库。uid: 订阅用户UID,dynamic: 是否需要订阅动态,live: 是否需要订阅直播"),
|
|
@@ -1356,6 +1379,7 @@ class ComRegister {
|
|
|
1356
1379
|
]).required(),
|
|
1357
1380
|
restartPush: koishi_1.Schema.boolean().required(),
|
|
1358
1381
|
pushTime: koishi_1.Schema.number().required(),
|
|
1382
|
+
pushImgsInDynamic: koishi_1.Schema.boolean().required(),
|
|
1359
1383
|
liveLoopTime: koishi_1.Schema.number().default(10),
|
|
1360
1384
|
customLiveStart: koishi_1.Schema.string().required(),
|
|
1361
1385
|
customLive: koishi_1.Schema.string(),
|
package/lib/generateImg.d.ts
CHANGED
|
@@ -9,8 +9,18 @@ declare class GenerateImg extends Service {
|
|
|
9
9
|
giConfig: GenerateImg.Config;
|
|
10
10
|
constructor(ctx: Context, config: GenerateImg.Config);
|
|
11
11
|
imgHandler(html: string): Promise<Buffer<ArrayBufferLike>>;
|
|
12
|
-
generateLiveImg(data: any, username: string, userface: string, followerDisplay: string, liveStatus: number
|
|
13
|
-
|
|
12
|
+
generateLiveImg(data: any, username: string, userface: string, followerDisplay: string, liveStatus: number, { cardColorStart, cardColorEnd, cardBasePlateColor, cardBasePlateBorder, }: {
|
|
13
|
+
cardColorStart?: string;
|
|
14
|
+
cardColorEnd?: string;
|
|
15
|
+
cardBasePlateColor?: string;
|
|
16
|
+
cardBasePlateBorder?: string;
|
|
17
|
+
}): Promise<Buffer<ArrayBufferLike>>;
|
|
18
|
+
generateDynamicImg(data: any, { cardColorStart, cardColorEnd, cardBasePlateColor, cardBasePlateBorder, }: {
|
|
19
|
+
cardColorStart?: string;
|
|
20
|
+
cardColorEnd?: string;
|
|
21
|
+
cardBasePlateColor?: string;
|
|
22
|
+
cardBasePlateBorder?: string;
|
|
23
|
+
}): Promise<Buffer<ArrayBufferLike>>;
|
|
14
24
|
getLiveStatus(time: string, liveStatus: number): Promise<[string, string, boolean]>;
|
|
15
25
|
getTimeDifference(dateString: string): Promise<string>;
|
|
16
26
|
unixTimestampToString(timestamp: number): string;
|
package/lib/generateImg.js
CHANGED
|
@@ -51,7 +51,7 @@ class GenerateImg extends koishi_1.Service {
|
|
|
51
51
|
}
|
|
52
52
|
async generateLiveImg(
|
|
53
53
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
54
|
-
data, username, userface, followerDisplay, liveStatus /*0未开播 1刚开播 2已开播 3
|
|
54
|
+
data, username, userface, followerDisplay, liveStatus /*0未开播 1刚开播 2已开播 3停止直播*/, { cardColorStart = this.giConfig.cardColorStart, cardColorEnd = this.giConfig.cardColorEnd, cardBasePlateColor = this.giConfig.cardBasePlateColor, cardBasePlateBorder = this.giConfig.cardBasePlateBorder, }) {
|
|
55
55
|
const [titleStatus, liveTime, cover] = await this.getLiveStatus(data.live_time, liveStatus);
|
|
56
56
|
// 加载字体
|
|
57
57
|
const fontURL = (0, node_url_1.pathToFileURL)((0, node_path_1.resolve)(__dirname, "font/HYZhengYuan-75W.ttf"));
|
|
@@ -83,7 +83,7 @@ class GenerateImg extends koishi_1.Service {
|
|
|
83
83
|
width: 100%;
|
|
84
84
|
height: auto;
|
|
85
85
|
padding: 15px;
|
|
86
|
-
background: linear-gradient(to right bottom, ${
|
|
86
|
+
background: linear-gradient(to right bottom, ${cardColorStart}, ${cardColorEnd});
|
|
87
87
|
overflow: hidden;
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -91,11 +91,11 @@ class GenerateImg extends koishi_1.Service {
|
|
|
91
91
|
width: 100%;
|
|
92
92
|
height: auto;
|
|
93
93
|
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
|
|
94
|
-
padding: ${
|
|
94
|
+
padding: ${cardBasePlateBorder};
|
|
95
95
|
border-radius: 10px;
|
|
96
|
-
background-color: ${
|
|
96
|
+
background-color: ${cardBasePlateColor};
|
|
97
97
|
}
|
|
98
|
-
|
|
98
|
+
|
|
99
99
|
.card {
|
|
100
100
|
width: 100%;
|
|
101
101
|
height: auto;
|
|
@@ -214,8 +214,9 @@ class GenerateImg extends koishi_1.Service {
|
|
|
214
214
|
throw new Error(`生成图片失败!错误: ${e.toString()}`);
|
|
215
215
|
});
|
|
216
216
|
}
|
|
217
|
+
async generateDynamicImg(
|
|
217
218
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
218
|
-
|
|
219
|
+
data, { cardColorStart = this.giConfig.cardColorStart, cardColorEnd = this.giConfig.cardColorEnd, cardBasePlateColor = this.giConfig.cardBasePlateColor, cardBasePlateBorder = this.giConfig.cardBasePlateBorder, }) {
|
|
219
220
|
// module_author
|
|
220
221
|
const module_author = data.modules.module_author;
|
|
221
222
|
const avatarUrl = module_author.face;
|
|
@@ -288,7 +289,6 @@ class GenerateImg extends koishi_1.Service {
|
|
|
288
289
|
if (module_dynamic.major?.draw) {
|
|
289
290
|
if (module_dynamic.major.draw.items.length === 1) {
|
|
290
291
|
const height = module_dynamic.major.draw.items[0].height;
|
|
291
|
-
console.log(height);
|
|
292
292
|
if (height > 3000) {
|
|
293
293
|
major += /* html */ `
|
|
294
294
|
<div class="single-photo-container">
|
|
@@ -586,7 +586,7 @@ class GenerateImg extends koishi_1.Service {
|
|
|
586
586
|
width: 100%;
|
|
587
587
|
height: auto;
|
|
588
588
|
padding: 15px;
|
|
589
|
-
background: linear-gradient(to right bottom, ${
|
|
589
|
+
background: linear-gradient(to right bottom, ${cardColorStart}, ${cardColorEnd});
|
|
590
590
|
overflow: hidden;
|
|
591
591
|
}
|
|
592
592
|
|
|
@@ -594,9 +594,9 @@ class GenerateImg extends koishi_1.Service {
|
|
|
594
594
|
width: 100%;
|
|
595
595
|
height: auto;
|
|
596
596
|
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
|
|
597
|
-
padding: ${
|
|
597
|
+
padding: ${cardBasePlateBorder};
|
|
598
598
|
border-radius: 10px;
|
|
599
|
-
background-color: ${
|
|
599
|
+
background-color: ${cardBasePlateColor};
|
|
600
600
|
}
|
|
601
601
|
|
|
602
602
|
.card {
|
|
@@ -951,7 +951,7 @@ class GenerateImg extends koishi_1.Service {
|
|
|
951
951
|
width: 100%;
|
|
952
952
|
height: auto;
|
|
953
953
|
padding: 15px;
|
|
954
|
-
background: linear-gradient(to right bottom, ${
|
|
954
|
+
background: linear-gradient(to right bottom, ${cardColorStart}, ${cardColorEnd});
|
|
955
955
|
overflow: hidden;
|
|
956
956
|
}
|
|
957
957
|
|
|
@@ -959,9 +959,9 @@ class GenerateImg extends koishi_1.Service {
|
|
|
959
959
|
width: 100%;
|
|
960
960
|
height: auto;
|
|
961
961
|
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
|
|
962
|
-
padding: ${
|
|
962
|
+
padding: ${cardBasePlateBorder};
|
|
963
963
|
border-radius: 10px;
|
|
964
|
-
background-color: ${
|
|
964
|
+
background-color: ${cardBasePlateColor};
|
|
965
965
|
}
|
|
966
966
|
|
|
967
967
|
.card {
|
package/lib/index.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export interface Config {
|
|
|
36
36
|
uid: string;
|
|
37
37
|
dynamic: boolean;
|
|
38
38
|
live: boolean;
|
|
39
|
+
card: {};
|
|
39
40
|
target: Array<{
|
|
40
41
|
channelIdArr: Array<{
|
|
41
42
|
channelId: string;
|
|
@@ -50,6 +51,7 @@ export interface Config {
|
|
|
50
51
|
dynamic: {};
|
|
51
52
|
dynamicUrl: boolean;
|
|
52
53
|
dynamicLoopTime: "1分钟" | "2分钟" | "3分钟" | "5分钟" | "10分钟" | "20分钟";
|
|
54
|
+
pushImgsInDynamic: boolean;
|
|
53
55
|
live: {};
|
|
54
56
|
liveDetectMode: "API" | "WS";
|
|
55
57
|
restartPush: boolean;
|
package/lib/index.js
CHANGED
|
@@ -145,6 +145,7 @@ class ServerManager extends koishi_1.Service {
|
|
|
145
145
|
liveDetectMode: globalConfig.liveDetectMode,
|
|
146
146
|
restartPush: globalConfig.restartPush,
|
|
147
147
|
pushTime: globalConfig.pushTime,
|
|
148
|
+
pushImgsInDynamic: globalConfig.pushImgsInDynamic,
|
|
148
149
|
customLiveStart: globalConfig.customLiveStart,
|
|
149
150
|
customLive: globalConfig.customLive,
|
|
150
151
|
customLiveEnd: globalConfig.customLiveEnd,
|
|
@@ -302,6 +303,31 @@ exports.Config = koishi_1.Schema.object({
|
|
|
302
303
|
.required()
|
|
303
304
|
.description("需推送的频道/群组详细设置"),
|
|
304
305
|
})).description("订阅用户需要发送的平台和频道/群组信息(一个平台下可以推送多个频道/群组)"),
|
|
306
|
+
card: koishi_1.Schema.intersect([
|
|
307
|
+
koishi_1.Schema.object({
|
|
308
|
+
enable: koishi_1.Schema.boolean()
|
|
309
|
+
.default(false)
|
|
310
|
+
.description("是否开启自定义卡片颜色"),
|
|
311
|
+
}),
|
|
312
|
+
koishi_1.Schema.union([
|
|
313
|
+
koishi_1.Schema.object({
|
|
314
|
+
enable: koishi_1.Schema.const(true).required(),
|
|
315
|
+
cardColorStart: koishi_1.Schema.string()
|
|
316
|
+
.pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
|
|
317
|
+
.description("推送卡片的开始渐变背景色,请填入16进制颜色代码,参考网站:https://webkul.github.io/coolhue/"),
|
|
318
|
+
cardColorEnd: koishi_1.Schema.string()
|
|
319
|
+
.pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
|
|
320
|
+
.description("推送卡片的结束渐变背景色,请填入16进制颜色代码,参考网站:https://colorate.azurewebsites.net/"),
|
|
321
|
+
cardBasePlateColor: koishi_1.Schema.string()
|
|
322
|
+
.pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
|
|
323
|
+
.description("推送卡片底板颜色,请填入16进制颜色代码"),
|
|
324
|
+
cardBasePlateBorder: koishi_1.Schema.string()
|
|
325
|
+
.pattern(/\d*\.?\d+(?:px|em|rem|%|vh|vw|vmin|vmax)/)
|
|
326
|
+
.description("推送卡片底板边框宽度,请填入css单位,例如1px,12.5rem,100%"),
|
|
327
|
+
}),
|
|
328
|
+
koishi_1.Schema.object({}),
|
|
329
|
+
]),
|
|
330
|
+
]),
|
|
305
331
|
}).collapse())
|
|
306
332
|
.collapse()
|
|
307
333
|
.description("输入订阅信息,自定义订阅内容; uid: 订阅用户UID,dynamic: 是否需要订阅动态,live: 是否需要订阅直播"),
|
|
@@ -320,6 +346,9 @@ exports.Config = koishi_1.Schema.object({
|
|
|
320
346
|
.role("")
|
|
321
347
|
.default("2分钟")
|
|
322
348
|
.description("设定多久检测一次动态。若需动态的时效性,可以设置为1分钟。若订阅的UP主经常在短时间内连着发多条动态应该将该值提高,否则会出现动态漏推送和晚推送的问题,默认值为2分钟"),
|
|
349
|
+
pushImgsInDynamic: koishi_1.Schema.boolean()
|
|
350
|
+
.default(false)
|
|
351
|
+
.description("是否推送动态中的图片,默认不开启。开启后会单独推送动态中的图片"),
|
|
323
352
|
live: koishi_1.Schema.object({}).description("直播推送设置"),
|
|
324
353
|
liveDetectMode: koishi_1.Schema.union([
|
|
325
354
|
koishi_1.Schema.const("WS").description("WebSocket模式:连接到对应的直播间,可推送弹幕消息,开播下播响应最快,但对订阅数有限制"),
|
package/lib/type/index.d.ts
CHANGED
|
@@ -26,6 +26,13 @@ export type SubItem = {
|
|
|
26
26
|
platform: string;
|
|
27
27
|
live: boolean;
|
|
28
28
|
dynamic: boolean;
|
|
29
|
+
card: {
|
|
30
|
+
enable: boolean;
|
|
31
|
+
cardColorStart: string;
|
|
32
|
+
cardColorEnd: string;
|
|
33
|
+
cardBasePlateColor: string;
|
|
34
|
+
cardBasePlateBorder: string;
|
|
35
|
+
};
|
|
29
36
|
};
|
|
30
37
|
export type SubManager = Array<SubItem>;
|
|
31
38
|
export type MasterInfo = {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -210,6 +210,8 @@
|
|
|
210
210
|
- ver 3.0.0-alpha.24 新增:配置项,`cardBasePlateColor` 和 `cardBasePlateBorder`,分别设置卡片底板颜色和底板边框宽度; 优化:部分代码结构
|
|
211
211
|
- ver 3.0.0-alpha.25 修复:输入指令 `bili ll` 时报错 `TypeError: Cannot read properties of null (reading 'items')`,当某个订阅只订阅动态时无法成功订阅且后续订阅都无法加载; 优化:部分代码结构
|
|
212
212
|
- ver 3.0.0-beta.0 移除:配置项 `renderType`,推送卡片渲染模式 `render`,现默认为 `page` 渲染模式; 优化:部分代码结构
|
|
213
|
+
- ver 3.0.0-beta.1 修复:使用动态屏蔽时,同时开启动态debug模式,当检测到屏蔽动态时会直接报错关闭插件; 新增:配置项 `pushImgsInDynamic` 是否推送动态中的图片,默认不开启。开启后会单独推送动态中的图片,上舰信息直播间提示
|
|
214
|
+
- ver 3.0.0-beta.2 新增:配置项 `sub.card`,能更改每个订阅的推送卡片样式,未更改的样式与全局样式保持一致
|
|
213
215
|
|
|
214
216
|
## 交流群
|
|
215
217
|
|