koishi-plugin-bilibili-notify 3.1.2-alpha.0 → 3.1.4-alpha.0
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 +3 -7
- package/lib/comRegister.js +149 -154
- package/lib/generateImg.d.ts +1 -0
- package/lib/generateImg.js +7 -1
- package/lib/index.js +1 -0
- package/lib/type/index.d.ts +19 -1
- 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, PushType, type SubItem, type SubManager, type Target } from "./type";
|
|
4
|
+
import { LiveType, type MasterInfo, PushType, type Result, type SubItem, type SubManager, type Target } from "./type";
|
|
5
5
|
declare class ComRegister {
|
|
6
6
|
static inject: string[];
|
|
7
7
|
qqRelatedBotList: Array<string>;
|
|
@@ -19,7 +19,6 @@ declare class ComRegister {
|
|
|
19
19
|
constructor(ctx: Context, config: ComRegister.Config);
|
|
20
20
|
init(config: ComRegister.Config): Promise<void>;
|
|
21
21
|
getBot(pf: string): Bot<Context, any>;
|
|
22
|
-
test_wordCloud(): Promise<void>;
|
|
23
22
|
sendPrivateMsg(content: string): Promise<void>;
|
|
24
23
|
sendPrivateMsgAndRebootService(): Promise<void>;
|
|
25
24
|
sendPrivateMsgAndStopService(): Promise<void>;
|
|
@@ -34,11 +33,8 @@ declare class ComRegister {
|
|
|
34
33
|
subShow(): string;
|
|
35
34
|
updateSubNotifier(): void;
|
|
36
35
|
checkIfLoginInfoIsLoaded(): Promise<unknown>;
|
|
37
|
-
subUserInBili(mid: string): Promise<
|
|
38
|
-
|
|
39
|
-
msg: string;
|
|
40
|
-
}>;
|
|
41
|
-
loadSubFromConfig(subs: ComRegister.Config["sub"]): Promise<void>;
|
|
36
|
+
subUserInBili(mid: string): Promise<Result>;
|
|
37
|
+
loadSubFromConfig(subs: ComRegister.Config["sub"]): Promise<Result>;
|
|
42
38
|
checkIfDynamicDetectIsNeeded(): void;
|
|
43
39
|
enableDynamicDetect(): void;
|
|
44
40
|
checkIfIsLogin(): Promise<boolean>;
|
package/lib/comRegister.js
CHANGED
|
@@ -176,7 +176,10 @@ class ComRegister {
|
|
|
176
176
|
// 销毁定时器
|
|
177
177
|
this.loginTimer();
|
|
178
178
|
// 订阅手动订阅中的订阅
|
|
179
|
-
await this.loadSubFromConfig(config.sub);
|
|
179
|
+
const { code, msg } = await this.loadSubFromConfig(config.sub);
|
|
180
|
+
// 判断是否加载成功
|
|
181
|
+
if (code !== 0)
|
|
182
|
+
this.logger.error(msg);
|
|
180
183
|
// 清除控制台通知
|
|
181
184
|
ctx.ba.disposeNotifier();
|
|
182
185
|
// 发送成功登录推送
|
|
@@ -295,7 +298,17 @@ class ComRegister {
|
|
|
295
298
|
return;
|
|
296
299
|
}
|
|
297
300
|
// 从配置获取订阅
|
|
298
|
-
|
|
301
|
+
if (config.sub) {
|
|
302
|
+
const { code, msg } = await this.loadSubFromConfig(config.sub);
|
|
303
|
+
// 判断是否加载成功
|
|
304
|
+
if (code !== 0) {
|
|
305
|
+
this.logger.error(msg);
|
|
306
|
+
this.logger.error("订阅对象加载失败,插件初始化失败!");
|
|
307
|
+
// 发送私聊消息
|
|
308
|
+
await this.sendPrivateMsg("订阅对象加载失败,插件初始化失败!");
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
299
312
|
// 检查是否需要动态监测
|
|
300
313
|
this.checkIfDynamicDetectIsNeeded();
|
|
301
314
|
// 在控制台中显示订阅对象
|
|
@@ -316,42 +329,6 @@ class ComRegister {
|
|
|
316
329
|
getBot(pf) {
|
|
317
330
|
return this.ctx.bots.find((bot) => bot.platform === pf);
|
|
318
331
|
}
|
|
319
|
-
// TODO:WordCloud
|
|
320
|
-
async test_wordCloud() {
|
|
321
|
-
/* const currentLiveDanmakuArr = []
|
|
322
|
-
// 定义获取弹幕权重Record函数
|
|
323
|
-
const getDanmakuWeightRecord = (): Record<string, number> => {
|
|
324
|
-
// 创建segmentit
|
|
325
|
-
const segmentit = useDefault(new Segment());
|
|
326
|
-
// 创建Record
|
|
327
|
-
const danmakuWeightRecord: Record<string, number> = {};
|
|
328
|
-
// 循环遍历currentLiveDanmakuArr
|
|
329
|
-
for (const danmaku of currentLiveDanmakuArr) {
|
|
330
|
-
// 遍历结果
|
|
331
|
-
segmentit.doSegment(danmaku).map((word: { w: string; p: number }) => {
|
|
332
|
-
// 定义权重
|
|
333
|
-
danmakuWeightRecord[word.w] = (danmakuWeightRecord[word.w] || 0) + 1;
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
// 返回Record
|
|
337
|
-
return danmakuWeightRecord;
|
|
338
|
-
}; */
|
|
339
|
-
// Test
|
|
340
|
-
const testTarget = [
|
|
341
|
-
{
|
|
342
|
-
channelArr: [
|
|
343
|
-
{
|
|
344
|
-
channelId: "635762054",
|
|
345
|
-
dynamic: true,
|
|
346
|
-
live: false,
|
|
347
|
-
liveGuardBuy: false,
|
|
348
|
-
atAll: false,
|
|
349
|
-
},
|
|
350
|
-
],
|
|
351
|
-
platform: "qqguild",
|
|
352
|
-
},
|
|
353
|
-
];
|
|
354
|
-
}
|
|
355
332
|
async sendPrivateMsg(content) {
|
|
356
333
|
if (this.config.master.enable) {
|
|
357
334
|
if (this.config.master.masterAccountGuildId) {
|
|
@@ -514,8 +491,10 @@ class ComRegister {
|
|
|
514
491
|
let detectSetup = true;
|
|
515
492
|
// 时间线
|
|
516
493
|
let timeline;
|
|
517
|
-
//
|
|
518
|
-
let
|
|
494
|
+
// 当前推送动态时间线
|
|
495
|
+
let currentTimeline;
|
|
496
|
+
// 动态ID
|
|
497
|
+
let dynId;
|
|
519
498
|
// 定义handler
|
|
520
499
|
const handler = async () => {
|
|
521
500
|
// 动态监测启动初始化
|
|
@@ -537,7 +516,7 @@ class ComRegister {
|
|
|
537
516
|
if (content.code !== 0)
|
|
538
517
|
return;
|
|
539
518
|
// 设置第一条动态的动态ID
|
|
540
|
-
|
|
519
|
+
dynId = content.data?.items[0]?.id_str || "0";
|
|
541
520
|
// 设置时间线
|
|
542
521
|
timeline =
|
|
543
522
|
content.data?.items[0]?.modules.module_author.pub_ts ||
|
|
@@ -613,7 +592,7 @@ class ComRegister {
|
|
|
613
592
|
// 获取动态ID
|
|
614
593
|
const dynamicId = item.id_str;
|
|
615
594
|
// 动态ID如果一致则结束循环
|
|
616
|
-
if (dynamicId ===
|
|
595
|
+
if (dynamicId === dynId)
|
|
617
596
|
break;
|
|
618
597
|
// 获取动态发布时间
|
|
619
598
|
const postTime = item.modules.module_author.pub_ts;
|
|
@@ -648,6 +627,12 @@ class ComRegister {
|
|
|
648
627
|
}
|
|
649
628
|
return;
|
|
650
629
|
}
|
|
630
|
+
if (e.message === "已屏蔽专栏动态") {
|
|
631
|
+
if (this.config.filter.notify) {
|
|
632
|
+
await this.broadcastToTargets(sub.target, `${upName}投稿了一条专栏,已屏蔽`, type_1.PushType.Dynamic);
|
|
633
|
+
}
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
651
636
|
// 未知错误
|
|
652
637
|
this.logger.error(`dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:${e.message}`);
|
|
653
638
|
// 发送私聊消息并重启服务
|
|
@@ -660,8 +645,13 @@ class ComRegister {
|
|
|
660
645
|
let dUrl = "";
|
|
661
646
|
// 判断是否需要发送URL
|
|
662
647
|
if (this.config.dynamicUrl) {
|
|
663
|
-
|
|
664
|
-
|
|
648
|
+
if (item.type === "DYNAMIC_TYPE_AV") {
|
|
649
|
+
dUrl = `${upName}发布了新视频:${item.modules.module_dynamic.major.archive.jump_url}`;
|
|
650
|
+
}
|
|
651
|
+
else {
|
|
652
|
+
// 生成动态链接
|
|
653
|
+
dUrl = `${upName}发布了一条动态:https://t.bilibili.com/${dynamicId}`;
|
|
654
|
+
}
|
|
665
655
|
}
|
|
666
656
|
// logger
|
|
667
657
|
this.logger.info("推送动态中...");
|
|
@@ -678,16 +668,22 @@ class ComRegister {
|
|
|
678
668
|
}
|
|
679
669
|
}
|
|
680
670
|
}
|
|
671
|
+
// 设置timeline
|
|
672
|
+
currentTimeline = postTime;
|
|
681
673
|
// logger
|
|
682
674
|
this.logger.info("动态推送完毕!");
|
|
683
675
|
}
|
|
684
676
|
}
|
|
685
677
|
}
|
|
686
|
-
// 更新本次请求第一条动态的动态ID
|
|
687
|
-
dynamicIdStr1st = items[0].id_str;
|
|
688
678
|
// 更新时间线
|
|
689
|
-
|
|
690
|
-
|
|
679
|
+
if (currentTimeline) {
|
|
680
|
+
timeline = currentTimeline;
|
|
681
|
+
currentTimeline = null;
|
|
682
|
+
}
|
|
683
|
+
// 设置动态ID
|
|
684
|
+
if (items[0].id_str && items[0].id_str !== dynId) {
|
|
685
|
+
dynId = items[0].id_str;
|
|
686
|
+
}
|
|
691
687
|
};
|
|
692
688
|
// 返回一个闭包函数
|
|
693
689
|
return (0, utils_1.withLock)(handler);
|
|
@@ -697,8 +693,10 @@ class ComRegister {
|
|
|
697
693
|
let detectSetup = true;
|
|
698
694
|
// 时间线
|
|
699
695
|
let timeline;
|
|
700
|
-
//
|
|
701
|
-
let
|
|
696
|
+
// 当前推送动态时间线
|
|
697
|
+
let currentTimeline;
|
|
698
|
+
// 动态ID
|
|
699
|
+
let dynId;
|
|
702
700
|
// 定义handler
|
|
703
701
|
const handler = async () => {
|
|
704
702
|
// 动态监测启动初始化
|
|
@@ -728,9 +726,9 @@ class ComRegister {
|
|
|
728
726
|
return;
|
|
729
727
|
}
|
|
730
728
|
// 设置第一条动态的动态ID
|
|
731
|
-
|
|
729
|
+
dynId = content.data?.items[0]?.id_str || "0";
|
|
732
730
|
// logger
|
|
733
|
-
this.logger.info(`获取到第一条动态ID:${
|
|
731
|
+
this.logger.info(`获取到第一条动态ID:${dynId}`);
|
|
734
732
|
// 设置时间线
|
|
735
733
|
timeline =
|
|
736
734
|
content.data?.items[0]?.modules.module_author.pub_ts ||
|
|
@@ -820,11 +818,12 @@ class ComRegister {
|
|
|
820
818
|
const dynamicId = item.id_str;
|
|
821
819
|
// logger
|
|
822
820
|
this.logger.info(`当前动态ID:${dynamicId}`);
|
|
823
|
-
this.logger.info(
|
|
821
|
+
this.logger.info(`上次第一条推送的动态ID:${dynId}`);
|
|
824
822
|
// 动态ID如果一致则结束循环
|
|
825
|
-
if (dynamicId ===
|
|
823
|
+
if (dynamicId === dynId) {
|
|
826
824
|
// logger
|
|
827
|
-
this.logger.info("动态ID
|
|
825
|
+
this.logger.info("动态ID与上次第一条推送动态一致,结束循环");
|
|
826
|
+
// 结束循环
|
|
828
827
|
break;
|
|
829
828
|
}
|
|
830
829
|
// 获取动态发布时间
|
|
@@ -845,16 +844,20 @@ class ComRegister {
|
|
|
845
844
|
break;
|
|
846
845
|
}
|
|
847
846
|
// logger
|
|
848
|
-
this.logger.info("
|
|
847
|
+
this.logger.info("动态时间线大于最后推送动态时间线,开始判断是否是订阅的UP主...");
|
|
849
848
|
// 从动态数据中取出UP主名称、UID
|
|
850
849
|
const upUID = item.modules.module_author.mid.toString();
|
|
851
850
|
const upName = item.modules.module_author.name;
|
|
852
851
|
// logger
|
|
853
852
|
this.logger.info(`当前动态UP主UID:${upUID},UP主名称:${upName}`);
|
|
853
|
+
// 定义是否是订阅的UP主flag
|
|
854
|
+
let isSubscribed = false;
|
|
854
855
|
// 寻找关注的UP主的动态
|
|
855
856
|
for (const sub of this.subManager) {
|
|
856
857
|
// 判断是否是订阅的UP主
|
|
857
858
|
if (sub.dynamic && sub.uid === upUID) {
|
|
859
|
+
// 将flag设置为true
|
|
860
|
+
isSubscribed = true;
|
|
858
861
|
// logger:订阅该UP主,推送该动态
|
|
859
862
|
this.logger.info("订阅该UP主,开始推送该动态...");
|
|
860
863
|
// logger
|
|
@@ -898,8 +901,13 @@ class ComRegister {
|
|
|
898
901
|
if (this.config.dynamicUrl) {
|
|
899
902
|
// logger
|
|
900
903
|
this.logger.info("生成动态链接中...");
|
|
901
|
-
|
|
902
|
-
|
|
904
|
+
if (item.type === "DYNAMIC_TYPE_AV") {
|
|
905
|
+
dUrl = `${upName}发布了新视频:${item.modules.module_dynamic.major.archive.jump_url}`;
|
|
906
|
+
}
|
|
907
|
+
else {
|
|
908
|
+
// 生成动态链接
|
|
909
|
+
dUrl = `${upName}发布了一条动态:https://t.bilibili.com/${item.id_str}`;
|
|
910
|
+
}
|
|
903
911
|
}
|
|
904
912
|
// logger
|
|
905
913
|
this.logger.info("推送动态中...");
|
|
@@ -920,22 +928,33 @@ class ComRegister {
|
|
|
920
928
|
// logger
|
|
921
929
|
this.logger.info("图片推送完毕!");
|
|
922
930
|
}
|
|
931
|
+
// 设置timeline
|
|
932
|
+
currentTimeline = postTime;
|
|
923
933
|
// logger
|
|
924
934
|
this.logger.info("动态推送完毕!");
|
|
925
935
|
}
|
|
936
|
+
}
|
|
937
|
+
if (!isSubscribed) {
|
|
926
938
|
// logger
|
|
927
939
|
this.logger.info("不是关注的UP主,跳过该动态");
|
|
928
940
|
}
|
|
929
941
|
}
|
|
930
|
-
// 更新本次请求第一条动态的动态ID
|
|
931
|
-
dynamicIdStr1st = items[0].id_str;
|
|
932
|
-
// logger
|
|
933
|
-
this.logger.info(`更新本次请求第一条动态的动态ID:${dynamicIdStr1st}`);
|
|
934
942
|
// 更新时间线
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
943
|
+
if (currentTimeline) {
|
|
944
|
+
timeline = currentTimeline;
|
|
945
|
+
currentTimeline = null;
|
|
946
|
+
// logger
|
|
947
|
+
this.logger.info(`更新时间线:${timeline}`);
|
|
948
|
+
}
|
|
949
|
+
else {
|
|
950
|
+
this.logger.info("时间线无需更新!");
|
|
951
|
+
}
|
|
952
|
+
// 更新动态ID
|
|
953
|
+
if (items[0].id_str && items[0].id_str !== dynId) {
|
|
954
|
+
dynId = items[0].id_str;
|
|
955
|
+
// logger
|
|
956
|
+
this.logger.info(`更新动态ID:${dynId}`);
|
|
957
|
+
}
|
|
939
958
|
// logger
|
|
940
959
|
this.logger.info(`时间线格式化:${luxon_1.DateTime.fromSeconds(timeline).toFormat("yyyy-MM-dd HH:mm:ss")}`);
|
|
941
960
|
// logger
|
|
@@ -1316,10 +1335,8 @@ class ComRegister {
|
|
|
1316
1335
|
// 判断分组是否准备好
|
|
1317
1336
|
const resp = await checkGroupIsReady();
|
|
1318
1337
|
// 判断是否创建成功
|
|
1319
|
-
if (resp.code !== 0)
|
|
1320
|
-
// 创建分组失败
|
|
1338
|
+
if (resp.code !== 0)
|
|
1321
1339
|
return resp;
|
|
1322
|
-
}
|
|
1323
1340
|
// 获取分组详情
|
|
1324
1341
|
const getGroupDetailData = async () => {
|
|
1325
1342
|
// 获取分组明细
|
|
@@ -1332,10 +1349,8 @@ class ComRegister {
|
|
|
1332
1349
|
// 分组不存在
|
|
1333
1350
|
const resp = await checkGroupIsReady();
|
|
1334
1351
|
// 判断是否创建成功
|
|
1335
|
-
if (resp.code !== 0)
|
|
1336
|
-
|
|
1337
|
-
return { ...resp, data: undefined };
|
|
1338
|
-
}
|
|
1352
|
+
if (resp.code !== 0)
|
|
1353
|
+
return resp;
|
|
1339
1354
|
// 再次获取分组明细
|
|
1340
1355
|
return getGroupDetailData();
|
|
1341
1356
|
}
|
|
@@ -1442,91 +1457,71 @@ class ComRegister {
|
|
|
1442
1457
|
return { code: 0, msg: "订阅对象添加成功" };
|
|
1443
1458
|
},
|
|
1444
1459
|
};
|
|
1445
|
-
// 获取函数
|
|
1446
|
-
const func = subUserMatchPattern[subUserData.code];
|
|
1447
1460
|
// 执行函数并返回
|
|
1448
|
-
return await
|
|
1461
|
+
return await subUserMatchPattern[subUserData.code]();
|
|
1449
1462
|
}
|
|
1450
1463
|
async loadSubFromConfig(subs) {
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
// 终止
|
|
1467
|
-
controller.abort(`加载订阅UID:${sub.uid}超时`);
|
|
1468
|
-
}, this.config.subLoadTimeout * 1000);
|
|
1464
|
+
for (const sub of subs) {
|
|
1465
|
+
// logger
|
|
1466
|
+
this.logger.info(`加载订阅UID:${sub.uid}中...`);
|
|
1467
|
+
// 定义Data
|
|
1468
|
+
const { code: userInfoCode, msg: userInfoMsg, data: userInfoData, } = await (0, utils_1.withRetry)(async () => {
|
|
1469
|
+
// 获取用户信息
|
|
1470
|
+
const data = await this.ctx.ba.getUserInfo(sub.uid);
|
|
1471
|
+
// 返回用户信息
|
|
1472
|
+
return { code: 0, data };
|
|
1473
|
+
})
|
|
1474
|
+
.then((content) => content.data)
|
|
1475
|
+
.catch((e) => {
|
|
1476
|
+
this.logger.error(`loadSubFromConfig() getUserInfo() 发生了错误,错误为:${e.message}`);
|
|
1477
|
+
// 返回失败
|
|
1478
|
+
return { code: -1, message: `加载订阅UID:${sub.uid}失败!` };
|
|
1469
1479
|
});
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
uid: sub.uid,
|
|
1516
|
-
uname: data.name,
|
|
1517
|
-
roomId: sub.live ? data.live_room.roomid : "",
|
|
1518
|
-
target: sub.target,
|
|
1519
|
-
platform: "",
|
|
1520
|
-
live: sub.live,
|
|
1521
|
-
dynamic: sub.dynamic,
|
|
1522
|
-
card: sub.card,
|
|
1523
|
-
});
|
|
1524
|
-
// logger
|
|
1525
|
-
this.logger.info(`UID:${sub.uid}订阅加载完毕!`);
|
|
1526
|
-
})(),
|
|
1527
|
-
timeoutPromise,
|
|
1528
|
-
]);
|
|
1529
|
-
}));
|
|
1480
|
+
// 判断是否获取成功
|
|
1481
|
+
if (userInfoCode !== 0)
|
|
1482
|
+
return { code: userInfoCode, msg: userInfoMsg };
|
|
1483
|
+
// 判断是否需要订阅直播
|
|
1484
|
+
if (sub.live) {
|
|
1485
|
+
// 检查roomid是否存在
|
|
1486
|
+
if (!userInfoData.live_room) {
|
|
1487
|
+
// 用户没有开通直播间,无法订阅直播
|
|
1488
|
+
sub.live = false;
|
|
1489
|
+
// 发送提示
|
|
1490
|
+
this.logger.warn(`UID:${sub.uid} 用户没有开通直播间,无法订阅直播!`);
|
|
1491
|
+
}
|
|
1492
|
+
// 判断是否订阅直播
|
|
1493
|
+
if (sub.live) {
|
|
1494
|
+
// 启动直播监测
|
|
1495
|
+
await this.liveDetectWithListener(userInfoData.live_room.roomid, sub.target, sub.card);
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
// 在B站中订阅该对象
|
|
1499
|
+
const subInfo = await this.subUserInBili(sub.uid);
|
|
1500
|
+
// 判断订阅是否成功
|
|
1501
|
+
if (subInfo.code !== 0)
|
|
1502
|
+
return subInfo;
|
|
1503
|
+
// 将该订阅添加到sm中
|
|
1504
|
+
this.subManager.push({
|
|
1505
|
+
id: +sub.uid,
|
|
1506
|
+
uid: sub.uid,
|
|
1507
|
+
uname: userInfoData.name,
|
|
1508
|
+
roomId: sub.live ? userInfoData.live_room.roomid : "",
|
|
1509
|
+
target: sub.target,
|
|
1510
|
+
platform: "",
|
|
1511
|
+
live: sub.live,
|
|
1512
|
+
dynamic: sub.dynamic,
|
|
1513
|
+
card: sub.card,
|
|
1514
|
+
});
|
|
1515
|
+
// logger
|
|
1516
|
+
this.logger.info(`UID:${sub.uid}订阅加载完毕!`);
|
|
1517
|
+
// 1-3秒随机延迟
|
|
1518
|
+
const randomDelay = Math.floor(Math.random() * 3) + 1;
|
|
1519
|
+
// logger
|
|
1520
|
+
this.logger.info(`随机延迟:${randomDelay}秒`);
|
|
1521
|
+
// delay
|
|
1522
|
+
await this.ctx.sleep(randomDelay * 1000);
|
|
1523
|
+
}
|
|
1524
|
+
return { code: 0, msg: "订阅加载完毕!" };
|
|
1530
1525
|
}
|
|
1531
1526
|
checkIfDynamicDetectIsNeeded() {
|
|
1532
1527
|
// 检查是否有订阅对象需要动态监测
|
package/lib/generateImg.d.ts
CHANGED
package/lib/generateImg.js
CHANGED
|
@@ -534,8 +534,13 @@ class GenerateImg extends koishi_1.Service {
|
|
|
534
534
|
`${upName}发布了剧集(番剧、电影、纪录片),我暂时无法渲染,请自行查看`,
|
|
535
535
|
link,
|
|
536
536
|
];
|
|
537
|
-
case DYNAMIC_TYPE_ARTICLE:
|
|
537
|
+
case DYNAMIC_TYPE_ARTICLE: {
|
|
538
|
+
//转发动态屏蔽
|
|
539
|
+
if (this.giConfig.filter.enable && this.giConfig.filter.article) {
|
|
540
|
+
throw new Error("已屏蔽专栏动态");
|
|
541
|
+
}
|
|
538
542
|
return [`${upName}投稿了新专栏,我暂时无法渲染,请自行查看`, link];
|
|
543
|
+
}
|
|
539
544
|
case DYNAMIC_TYPE_MUSIC:
|
|
540
545
|
return [`${upName}发行了新歌,我暂时无法渲染,请自行查看`, link];
|
|
541
546
|
case DYNAMIC_TYPE_COMMON_SQUARE:
|
|
@@ -1473,6 +1478,7 @@ class GenerateImg extends koishi_1.Service {
|
|
|
1473
1478
|
regex: koishi_1.Schema.string(),
|
|
1474
1479
|
keywords: koishi_1.Schema.array(String),
|
|
1475
1480
|
forward: koishi_1.Schema.boolean(),
|
|
1481
|
+
article: koishi_1.Schema.boolean(),
|
|
1476
1482
|
}),
|
|
1477
1483
|
removeBorder: koishi_1.Schema.boolean(),
|
|
1478
1484
|
cardColorStart: koishi_1.Schema.string(),
|
package/lib/index.js
CHANGED
|
@@ -387,6 +387,7 @@ exports.Config = koishi_1.Schema.object({
|
|
|
387
387
|
forward: koishi_1.Schema.boolean()
|
|
388
388
|
.default(false)
|
|
389
389
|
.description("是否屏蔽转发动态"),
|
|
390
|
+
article: koishi_1.Schema.boolean().default(false).description("是否屏蔽专栏"),
|
|
390
391
|
}),
|
|
391
392
|
koishi_1.Schema.object({}),
|
|
392
393
|
]),
|
package/lib/type/index.d.ts
CHANGED
|
@@ -75,12 +75,25 @@ export type AllDynamicInfo = {
|
|
|
75
75
|
};
|
|
76
76
|
module_dynamic: {
|
|
77
77
|
major: {
|
|
78
|
-
draw
|
|
78
|
+
draw?: {
|
|
79
79
|
items: Array<{
|
|
80
80
|
src: string;
|
|
81
81
|
alt: string;
|
|
82
82
|
}>;
|
|
83
83
|
};
|
|
84
|
+
archive?: {
|
|
85
|
+
aid: string;
|
|
86
|
+
badge: Object;
|
|
87
|
+
bvid: string;
|
|
88
|
+
cover: string;
|
|
89
|
+
desc: string;
|
|
90
|
+
disable_preview: number;
|
|
91
|
+
duration_text: string;
|
|
92
|
+
jump_url: string;
|
|
93
|
+
stat: string;
|
|
94
|
+
title: string;
|
|
95
|
+
type: number;
|
|
96
|
+
};
|
|
84
97
|
};
|
|
85
98
|
};
|
|
86
99
|
};
|
|
@@ -96,3 +109,8 @@ export declare enum PushType {
|
|
|
96
109
|
StartBroadcasting = 2,
|
|
97
110
|
LiveGuardBuy = 3
|
|
98
111
|
}
|
|
112
|
+
export type Result = {
|
|
113
|
+
code: number;
|
|
114
|
+
msg?: string;
|
|
115
|
+
data?: any;
|
|
116
|
+
};
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -235,6 +235,8 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
|
|
|
235
235
|
- ver 3.1.0 修复:订阅某位UP主直播和动态后,某些群聊只开启推送直播也会推送动态
|
|
236
236
|
- ver 3.1.1-alpha.0 修复:稿件重投后,会将之前日期的动态一起推送; 优化:加强动态debug输出; 移除:不必要选项 `live.liveDetectMode`
|
|
237
237
|
- ver 3.1.2-alpha.0 重构:对消息发送模块进行小型重构,多群多平台推送将不再支持艾特全体成员,仅单平台单群聊支持; 移除:群聊 `all` 选项
|
|
238
|
+
- ver 3.1.3-alpha.0 移除:订阅超时; 新增:屏蔽专栏动态功能; 优化:改进了加载插件的错误提示;
|
|
239
|
+
- ver 3.1.4-alpha.0 修复:动态只推送视频; 优化:动态视频链接将直接发送为视频链接;
|
|
238
240
|
|
|
239
241
|
## 交流群
|
|
240
242
|
|