koishi-plugin-bilibili-notify 3.2.1-alpha.7 → 3.2.1-alpha.8
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/biliAPI.d.ts +1 -1
- package/lib/biliAPI.js +46 -51
- package/lib/blive.js +5 -7
- package/lib/comRegister.js +116 -121
- package/lib/database.js +2 -6
- package/lib/generateImg.js +31 -33
- package/lib/index.js +91 -131
- package/lib/type/index.js +4 -7
- package/lib/utils/index.js +3 -8
- package/package.json +4 -4
- package/readme.md +1 -0
package/lib/database.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.name = void 0;
|
|
4
|
-
exports.apply = apply;
|
|
5
|
-
exports.name = "Database";
|
|
6
|
-
function apply(ctx) {
|
|
1
|
+
export const name = "Database";
|
|
2
|
+
export function apply(ctx) {
|
|
7
3
|
// 新增LoginBili表
|
|
8
4
|
ctx.model.extend("loginBili", {
|
|
9
5
|
id: "unsigned",
|
package/lib/generateImg.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const node_url_1 = require("node:url");
|
|
7
|
-
const utils_1 = require("./utils");
|
|
1
|
+
import { Schema, Service } from "koishi";
|
|
2
|
+
import { DateTime } from "luxon";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { pathToFileURL } from "node:url";
|
|
5
|
+
import { withRetry } from "./utils";
|
|
8
6
|
// 动态类型
|
|
9
7
|
const DYNAMIC_TYPE_NONE = "DYNAMIC_TYPE_NONE";
|
|
10
8
|
const DYNAMIC_TYPE_FORWARD = "DYNAMIC_TYPE_FORWARD";
|
|
@@ -22,7 +20,7 @@ const DYNAMIC_TYPE_LIVE_RCMD = "DYNAMIC_TYPE_LIVE_RCMD";
|
|
|
22
20
|
const DYNAMIC_TYPE_UGC_SEASON = "DYNAMIC_TYPE_UGC_SEASON";
|
|
23
21
|
// 内容卡片类型
|
|
24
22
|
const ADDITIONAL_TYPE_RESERVE = "ADDITIONAL_TYPE_RESERVE";
|
|
25
|
-
class GenerateImg extends
|
|
23
|
+
class GenerateImg extends Service {
|
|
26
24
|
static inject = ["puppeteer", "ba"];
|
|
27
25
|
giConfig;
|
|
28
26
|
constructor(ctx, config) {
|
|
@@ -54,7 +52,7 @@ class GenerateImg extends koishi_1.Service {
|
|
|
54
52
|
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
53
|
const [titleStatus, liveTime, cover] = await this.getLiveStatus(data.live_time, liveStatus);
|
|
56
54
|
// 加载字体
|
|
57
|
-
const fontURL =
|
|
55
|
+
const fontURL = pathToFileURL(resolve(__dirname, "font/HYZhengYuan-75W.ttf"));
|
|
58
56
|
// 卡片内容
|
|
59
57
|
const html = /* html */ `
|
|
60
58
|
<!DOCTYPE html>
|
|
@@ -209,7 +207,7 @@ class GenerateImg extends koishi_1.Service {
|
|
|
209
207
|
</html>
|
|
210
208
|
`;
|
|
211
209
|
// 多次尝试生成图片
|
|
212
|
-
return await
|
|
210
|
+
return await withRetry(() => this.imgHandler(html)).catch((e) => {
|
|
213
211
|
// 已尝试三次
|
|
214
212
|
throw new Error(`生成图片失败!错误: ${e.toString()}`);
|
|
215
213
|
});
|
|
@@ -290,7 +288,7 @@ class GenerateImg extends koishi_1.Service {
|
|
|
290
288
|
}
|
|
291
289
|
// 图片
|
|
292
290
|
let major = "";
|
|
293
|
-
const arrowImg =
|
|
291
|
+
const arrowImg = pathToFileURL(resolve(__dirname, "img/arrow.png"));
|
|
294
292
|
if (module_dynamic?.major?.opus?.pics) {
|
|
295
293
|
if (module_dynamic.major.opus.pics.length === 1) {
|
|
296
294
|
const height = module_dynamic.major.opus.pics[0].height;
|
|
@@ -566,7 +564,7 @@ class GenerateImg extends koishi_1.Service {
|
|
|
566
564
|
// 获取动态主要内容
|
|
567
565
|
const [main] = await getDynamicMajor(data, false);
|
|
568
566
|
// 加载字体
|
|
569
|
-
const fontURL =
|
|
567
|
+
const fontURL = pathToFileURL(resolve(__dirname, "font/HYZhengYuan-75W.ttf"));
|
|
570
568
|
// 判断是否开启大字体模式
|
|
571
569
|
let style;
|
|
572
570
|
if (this.giConfig.enableLargeFont) {
|
|
@@ -1397,7 +1395,7 @@ class GenerateImg extends koishi_1.Service {
|
|
|
1397
1395
|
</html>
|
|
1398
1396
|
`;
|
|
1399
1397
|
// 多次尝试生成图片
|
|
1400
|
-
return await
|
|
1398
|
+
return await withRetry(() => this.imgHandler(html)).catch((e) => {
|
|
1401
1399
|
// 已尝试三次
|
|
1402
1400
|
throw new Error(`生成图片失败!错误: ${e.toString()}`);
|
|
1403
1401
|
});
|
|
@@ -1436,11 +1434,11 @@ class GenerateImg extends koishi_1.Service {
|
|
|
1436
1434
|
}
|
|
1437
1435
|
async getTimeDifference(dateString) {
|
|
1438
1436
|
// 将日期字符串转换为Date对象
|
|
1439
|
-
const apiDateTime =
|
|
1437
|
+
const apiDateTime = DateTime.fromFormat(dateString, "yyyy-MM-dd HH:mm:ss", {
|
|
1440
1438
|
zone: "UTC+8",
|
|
1441
1439
|
});
|
|
1442
1440
|
// 获取当前时间
|
|
1443
|
-
const currentDateTime =
|
|
1441
|
+
const currentDateTime = DateTime.now();
|
|
1444
1442
|
// 计算时间差
|
|
1445
1443
|
const diff = currentDateTime.diff(apiDateTime, [
|
|
1446
1444
|
"years",
|
|
@@ -1482,24 +1480,24 @@ class GenerateImg extends koishi_1.Service {
|
|
|
1482
1480
|
}
|
|
1483
1481
|
}
|
|
1484
1482
|
(function (GenerateImg) {
|
|
1485
|
-
GenerateImg.Config =
|
|
1486
|
-
filter:
|
|
1487
|
-
enable:
|
|
1488
|
-
notify:
|
|
1489
|
-
regex:
|
|
1490
|
-
keywords:
|
|
1491
|
-
forward:
|
|
1492
|
-
article:
|
|
1483
|
+
GenerateImg.Config = Schema.object({
|
|
1484
|
+
filter: Schema.object({
|
|
1485
|
+
enable: Schema.boolean(),
|
|
1486
|
+
notify: Schema.boolean(),
|
|
1487
|
+
regex: Schema.string(),
|
|
1488
|
+
keywords: Schema.array(String),
|
|
1489
|
+
forward: Schema.boolean(),
|
|
1490
|
+
article: Schema.boolean(),
|
|
1493
1491
|
}),
|
|
1494
|
-
removeBorder:
|
|
1495
|
-
cardColorStart:
|
|
1496
|
-
cardColorEnd:
|
|
1497
|
-
cardBasePlateColor:
|
|
1498
|
-
cardBasePlateBorder:
|
|
1499
|
-
enableLargeFont:
|
|
1500
|
-
font:
|
|
1501
|
-
hideDesc:
|
|
1502
|
-
followerDisplay:
|
|
1492
|
+
removeBorder: Schema.boolean(),
|
|
1493
|
+
cardColorStart: Schema.string(),
|
|
1494
|
+
cardColorEnd: Schema.string(),
|
|
1495
|
+
cardBasePlateColor: Schema.string(),
|
|
1496
|
+
cardBasePlateBorder: Schema.string(),
|
|
1497
|
+
enableLargeFont: Schema.boolean(),
|
|
1498
|
+
font: Schema.string(),
|
|
1499
|
+
hideDesc: Schema.boolean(),
|
|
1500
|
+
followerDisplay: Schema.boolean(),
|
|
1503
1501
|
});
|
|
1504
1502
|
})(GenerateImg || (GenerateImg = {}));
|
|
1505
|
-
|
|
1503
|
+
export default GenerateImg;
|
package/lib/index.js
CHANGED
|
@@ -1,55 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.Config = exports.name = exports.inject = void 0;
|
|
40
|
-
exports.apply = apply;
|
|
41
|
-
const koishi_1 = require("koishi");
|
|
1
|
+
import { Schema, Service } from "koishi";
|
|
42
2
|
// import plugins
|
|
43
|
-
|
|
44
|
-
|
|
3
|
+
import ComRegister from "./comRegister";
|
|
4
|
+
import * as Database from "./database";
|
|
45
5
|
// import Service
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
6
|
+
import GenerateImg from "./generateImg";
|
|
7
|
+
import BiliAPI from "./biliAPI";
|
|
8
|
+
import BLive from "./blive";
|
|
9
|
+
export const inject = ["puppeteer", "database", "notifier"];
|
|
10
|
+
export const name = "bilibili-notify";
|
|
51
11
|
let globalConfig;
|
|
52
|
-
class ServerManager extends
|
|
12
|
+
class ServerManager extends Service {
|
|
53
13
|
// 服务
|
|
54
14
|
servers = [];
|
|
55
15
|
constructor(ctx) {
|
|
@@ -105,12 +65,12 @@ class ServerManager extends koishi_1.Service {
|
|
|
105
65
|
// 注册插件
|
|
106
66
|
try {
|
|
107
67
|
// BA = BiliAPI
|
|
108
|
-
const ba = this.ctx.plugin(
|
|
68
|
+
const ba = this.ctx.plugin(BiliAPI, {
|
|
109
69
|
userAgent: globalConfig.userAgent,
|
|
110
70
|
key: globalConfig.key,
|
|
111
71
|
});
|
|
112
72
|
// GI = GenerateImg
|
|
113
|
-
const gi = this.ctx.plugin(
|
|
73
|
+
const gi = this.ctx.plugin(GenerateImg, {
|
|
114
74
|
filter: globalConfig.filter,
|
|
115
75
|
removeBorder: globalConfig.removeBorder,
|
|
116
76
|
cardColorStart: globalConfig.cardColorStart,
|
|
@@ -123,7 +83,7 @@ class ServerManager extends koishi_1.Service {
|
|
|
123
83
|
followerDisplay: globalConfig.followerDisplay,
|
|
124
84
|
});
|
|
125
85
|
// CR = ComRegister
|
|
126
|
-
const cr = this.ctx.plugin(
|
|
86
|
+
const cr = this.ctx.plugin(ComRegister, {
|
|
127
87
|
sub: globalConfig.sub,
|
|
128
88
|
master: globalConfig.master,
|
|
129
89
|
liveDetectType: globalConfig.liveDetectType,
|
|
@@ -138,7 +98,7 @@ class ServerManager extends koishi_1.Service {
|
|
|
138
98
|
dynamicDebugMode: globalConfig.dynamicDebugMode,
|
|
139
99
|
});
|
|
140
100
|
// BL = BLive
|
|
141
|
-
const bl = this.ctx.plugin(
|
|
101
|
+
const bl = this.ctx.plugin(BLive);
|
|
142
102
|
// 添加服务
|
|
143
103
|
this.servers.push(ba);
|
|
144
104
|
this.servers.push(bl);
|
|
@@ -189,7 +149,7 @@ class ServerManager extends koishi_1.Service {
|
|
|
189
149
|
});
|
|
190
150
|
};
|
|
191
151
|
}
|
|
192
|
-
function apply(ctx, config) {
|
|
152
|
+
export function apply(ctx, config) {
|
|
193
153
|
// 设置config
|
|
194
154
|
globalConfig = config;
|
|
195
155
|
// 设置提示
|
|
@@ -209,23 +169,23 @@ function apply(ctx, config) {
|
|
|
209
169
|
return next();
|
|
210
170
|
});
|
|
211
171
|
}
|
|
212
|
-
|
|
213
|
-
require:
|
|
214
|
-
key:
|
|
172
|
+
export const Config = Schema.object({
|
|
173
|
+
require: Schema.object({}).description("必填设置"),
|
|
174
|
+
key: Schema.string()
|
|
215
175
|
.pattern(/^[0-9a-f]{32}$/)
|
|
216
176
|
.role("secret")
|
|
217
177
|
.required()
|
|
218
178
|
.description("请输入一个32位小写字母的十六进制密钥(例如:9b8db7ae562b9864efefe06289cc5530),使用此密钥将你的B站登录信息存储在数据库中,请一定保存好此密钥。如果你忘记了此密钥,必须重新登录。你可以自行生成,或到这个网站生成:https://www.sexauth.com/"),
|
|
219
|
-
master:
|
|
220
|
-
|
|
221
|
-
enable:
|
|
179
|
+
master: Schema.intersect([
|
|
180
|
+
Schema.object({
|
|
181
|
+
enable: Schema.boolean()
|
|
222
182
|
.default(false)
|
|
223
183
|
.description("是否开启主人账号功能,如果您的机器人没有私聊权限请不要开启此功能。开启后如果机器人运行错误会向您进行报告"),
|
|
224
184
|
}).description("主人账号"),
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
enable:
|
|
228
|
-
platform:
|
|
185
|
+
Schema.union([
|
|
186
|
+
Schema.object({
|
|
187
|
+
enable: Schema.const(true).required(),
|
|
188
|
+
platform: Schema.union([
|
|
229
189
|
"qq",
|
|
230
190
|
"qqguild",
|
|
231
191
|
"onebot",
|
|
@@ -236,165 +196,165 @@ exports.Config = koishi_1.Schema.object({
|
|
|
236
196
|
"chronocat",
|
|
237
197
|
"lark",
|
|
238
198
|
]).description("请选择您的私人机器人平台,目前支持QQ、QQ群、OneBot、Discord、RedBot、Telegram、Satori、ChronoCat、Lark。从2.0版本开始,只能在一个平台下使用本插件"),
|
|
239
|
-
masterAccount:
|
|
199
|
+
masterAccount: Schema.string()
|
|
240
200
|
.role("secret")
|
|
241
201
|
.required()
|
|
242
202
|
.description("主人账号,在Q群使用可直接使用QQ号,若在其他平台使用,请使用inspect插件获取自身ID"),
|
|
243
|
-
masterAccountGuildId:
|
|
203
|
+
masterAccountGuildId: Schema.string()
|
|
244
204
|
.role("secret")
|
|
245
205
|
.description("主人账号所在的群组ID,只有在QQ频道、Discord这样的环境才需要填写,请使用inspect插件获取群组ID"),
|
|
246
206
|
}),
|
|
247
|
-
|
|
207
|
+
Schema.object({}),
|
|
248
208
|
]),
|
|
249
209
|
]),
|
|
250
|
-
basicSettings:
|
|
251
|
-
userAgent:
|
|
210
|
+
basicSettings: Schema.object({}).description("基本设置"),
|
|
211
|
+
userAgent: Schema.string()
|
|
252
212
|
.required()
|
|
253
213
|
.description("设置请求头User-Agen,请求出现-352时可以尝试修改,UA获取方法可参考:https://blog.csdn.net/qq_44503987/article/details/104929111"),
|
|
254
|
-
subTitle:
|
|
255
|
-
sub:
|
|
256
|
-
name:
|
|
257
|
-
uid:
|
|
258
|
-
dynamic:
|
|
259
|
-
live:
|
|
260
|
-
target:
|
|
261
|
-
platform:
|
|
214
|
+
subTitle: Schema.object({}).description("订阅配置"),
|
|
215
|
+
sub: Schema.array(Schema.object({
|
|
216
|
+
name: Schema.string().description("订阅用户昵称,只是给你自己看的(相当于备注),可填可不填"),
|
|
217
|
+
uid: Schema.string().required().description("订阅用户UID"),
|
|
218
|
+
dynamic: Schema.boolean().default(false).description("是否订阅用户动态"),
|
|
219
|
+
live: Schema.boolean().default(false).description("是否订阅用户直播"),
|
|
220
|
+
target: Schema.array(Schema.object({
|
|
221
|
+
platform: Schema.string()
|
|
262
222
|
.required()
|
|
263
223
|
.description("推送平台,例如onebot、qq、discord"),
|
|
264
|
-
channelArr:
|
|
265
|
-
channelId:
|
|
266
|
-
dynamic:
|
|
224
|
+
channelArr: Schema.array(Schema.object({
|
|
225
|
+
channelId: Schema.string().required().description("频道/群组号"),
|
|
226
|
+
dynamic: Schema.boolean()
|
|
267
227
|
.default(false)
|
|
268
228
|
.description("该频道/群组是否推送动态信息"),
|
|
269
|
-
live:
|
|
229
|
+
live: Schema.boolean()
|
|
270
230
|
.default(false)
|
|
271
231
|
.description("该频道/群组是否推送直播通知"),
|
|
272
|
-
liveGuardBuy:
|
|
232
|
+
liveGuardBuy: Schema.boolean()
|
|
273
233
|
.default(false)
|
|
274
234
|
.description("该频道/群组是否推送上舰消息"),
|
|
275
|
-
atAll:
|
|
235
|
+
atAll: Schema.boolean()
|
|
276
236
|
.default(false)
|
|
277
237
|
.description("推送开播通知时是否艾特全体成员"),
|
|
278
|
-
bot:
|
|
238
|
+
bot: Schema.string()
|
|
279
239
|
.description("若您有多个相同平台机器人,可在此填写当前群聊执行推送的机器人账号。不填则默认第一个")
|
|
280
240
|
}))
|
|
281
241
|
.role("table")
|
|
282
242
|
.required()
|
|
283
243
|
.description("需推送的频道/群组详细设置"),
|
|
284
244
|
})).description("订阅用户需要发送的平台和频道/群组信息(一个平台下可以推送多个频道/群组)"),
|
|
285
|
-
card:
|
|
286
|
-
|
|
287
|
-
enable:
|
|
245
|
+
card: Schema.intersect([
|
|
246
|
+
Schema.object({
|
|
247
|
+
enable: Schema.boolean()
|
|
288
248
|
.default(false)
|
|
289
249
|
.description("是否开启自定义卡片颜色"),
|
|
290
250
|
}),
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
enable:
|
|
294
|
-
cardColorStart:
|
|
251
|
+
Schema.union([
|
|
252
|
+
Schema.object({
|
|
253
|
+
enable: Schema.const(true).required(),
|
|
254
|
+
cardColorStart: Schema.string()
|
|
295
255
|
.pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
|
|
296
256
|
.description("推送卡片的开始渐变背景色,请填入16进制颜色代码,参考网站:https://webkul.github.io/coolhue/"),
|
|
297
|
-
cardColorEnd:
|
|
257
|
+
cardColorEnd: Schema.string()
|
|
298
258
|
.pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
|
|
299
259
|
.description("推送卡片的结束渐变背景色,请填入16进制颜色代码,参考网站:https://colorate.azurewebsites.net/"),
|
|
300
|
-
cardBasePlateColor:
|
|
260
|
+
cardBasePlateColor: Schema.string()
|
|
301
261
|
.pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
|
|
302
262
|
.description("推送卡片底板颜色,请填入16进制颜色代码"),
|
|
303
|
-
cardBasePlateBorder:
|
|
263
|
+
cardBasePlateBorder: Schema.string()
|
|
304
264
|
.pattern(/\d*\.?\d+(?:px|em|rem|%|vh|vw|vmin|vmax)/)
|
|
305
265
|
.description("推送卡片底板边框宽度,请填入css单位,例如1px,12.5rem,100%"),
|
|
306
266
|
}),
|
|
307
|
-
|
|
267
|
+
Schema.object({}),
|
|
308
268
|
]),
|
|
309
269
|
]),
|
|
310
270
|
}).collapse())
|
|
311
271
|
.collapse()
|
|
312
272
|
.description("输入订阅信息,自定义订阅内容; uid: 订阅用户UID,dynamic: 是否需要订阅动态,live: 是否需要订阅直播"),
|
|
313
|
-
dynamic:
|
|
314
|
-
dynamicUrl:
|
|
273
|
+
dynamic: Schema.object({}).description("动态推送设置"),
|
|
274
|
+
dynamicUrl: Schema.boolean()
|
|
315
275
|
.default(false)
|
|
316
276
|
.description("发送动态时是否同时发送链接。注意:如果使用的是QQ官方机器人不能开启此项!"),
|
|
317
|
-
pushImgsInDynamic:
|
|
277
|
+
pushImgsInDynamic: Schema.boolean()
|
|
318
278
|
.default(false)
|
|
319
279
|
.description("是否推送动态中的图片,默认不开启。开启后会单独推送动态中的图片,该功能容易导致QQ风控"),
|
|
320
|
-
live:
|
|
321
|
-
liveDetectType:
|
|
322
|
-
|
|
323
|
-
|
|
280
|
+
live: Schema.object({}).description("直播推送设置"),
|
|
281
|
+
liveDetectType: Schema.union([
|
|
282
|
+
Schema.const("WS").description("使用WebSocket连接到B站消息服务器进行直播检测,推荐使用"),
|
|
283
|
+
Schema.const("API").description("通过轮询API发送请求监测直播状态,此模式理论可无限订阅,但容易产生其他问题,功能没有WS模式全面").experimental(),
|
|
324
284
|
])
|
|
325
285
|
.role("radio")
|
|
326
286
|
.default("WS")
|
|
327
287
|
.description("直播检测方式,WS为连接到B站消息服务器,API为通过轮询发送请求监测,默认使用WS检测"),
|
|
328
|
-
restartPush:
|
|
288
|
+
restartPush: Schema.boolean()
|
|
329
289
|
.default(true)
|
|
330
290
|
.description("插件重启后,如果订阅的主播正在直播,是否进行一次推送,默认开启"),
|
|
331
|
-
pushTime:
|
|
291
|
+
pushTime: Schema.number()
|
|
332
292
|
.min(0)
|
|
333
293
|
.max(12)
|
|
334
294
|
.step(0.5)
|
|
335
295
|
.default(1)
|
|
336
296
|
.description("设定间隔多长时间推送一次直播状态,单位为小时,默认为一小时"),
|
|
337
|
-
customLiveStart:
|
|
297
|
+
customLiveStart: Schema.string()
|
|
338
298
|
.default("-name开播啦,当前粉丝数:-follower\\n-link")
|
|
339
299
|
.description("自定义开播提示语,-name代表UP昵称,-follower代表当前粉丝数,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用),\\n为换行。例如-name开播啦,会发送为xxxUP开播啦"),
|
|
340
|
-
customLive:
|
|
300
|
+
customLive: Schema.string()
|
|
341
301
|
.default("-name正在直播,目前已播-time,累计观看人数:-watched\\n-link")
|
|
342
302
|
.description("自定义直播中提示语,-name代表UP昵称,-time代表开播时长,-watched代表累计观看人数,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用),\\n为换行。例如-name正在直播,会发送为xxxUP正在直播xxx"),
|
|
343
|
-
customLiveEnd:
|
|
303
|
+
customLiveEnd: Schema.string()
|
|
344
304
|
.default("-name下播啦,本次直播了-time,粉丝数变化-follower_change")
|
|
345
305
|
.description("自定义下播提示语,-name代表UP昵称,-follower_change代表本场直播粉丝数变,-time代表开播时长,\\n为换行。例如-name下播啦,本次直播了-time,会发送为xxxUP下播啦,直播时长为xx小时xx分钟xx秒"),
|
|
346
|
-
followerDisplay:
|
|
306
|
+
followerDisplay: Schema.boolean()
|
|
347
307
|
.default(true)
|
|
348
308
|
.description("粉丝数变化和累积观看本场直播的人数是否显示在推送卡片中"),
|
|
349
|
-
hideDesc:
|
|
309
|
+
hideDesc: Schema.boolean()
|
|
350
310
|
.default(false)
|
|
351
311
|
.description("是否隐藏UP主直播间简介,开启后推送的直播卡片将不再展示简介"),
|
|
352
|
-
style:
|
|
353
|
-
removeBorder:
|
|
354
|
-
cardColorStart:
|
|
312
|
+
style: Schema.object({}).description("美化设置"),
|
|
313
|
+
removeBorder: Schema.boolean().default(false).description("移除推送卡片边框"),
|
|
314
|
+
cardColorStart: Schema.string()
|
|
355
315
|
.pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
|
|
356
316
|
.default("#F38AB5")
|
|
357
317
|
.description("推送卡片的开始渐变背景色,请填入16进制颜色代码,参考网站:https://webkul.github.io/coolhue/"),
|
|
358
|
-
cardColorEnd:
|
|
318
|
+
cardColorEnd: Schema.string()
|
|
359
319
|
.pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
|
|
360
320
|
.default("#F9CCDF")
|
|
361
321
|
.description("推送卡片的结束渐变背景色,请填入16进制颜色代码,参考网站:https://colorate.azurewebsites.net/"),
|
|
362
|
-
cardBasePlateColor:
|
|
322
|
+
cardBasePlateColor: Schema.string()
|
|
363
323
|
.pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
|
|
364
324
|
.default("#FFF5EE")
|
|
365
325
|
.description("推送卡片底板颜色,请填入16进制颜色代码"),
|
|
366
|
-
cardBasePlateBorder:
|
|
326
|
+
cardBasePlateBorder: Schema.string()
|
|
367
327
|
.pattern(/\d*\.?\d+(?:px|em|rem|%|vh|vw|vmin|vmax)/)
|
|
368
328
|
.default("15px")
|
|
369
329
|
.description("推送卡片底板边框宽度,请填入css单位,例如1px,12.5rem,100%"),
|
|
370
|
-
enableLargeFont:
|
|
330
|
+
enableLargeFont: Schema.boolean()
|
|
371
331
|
.default(false)
|
|
372
332
|
.description("是否开启动态推送卡片大字体模式,默认为小字体。小字体更漂亮,但阅读比较吃力,大字体更易阅读,但相对没这么好看"),
|
|
373
|
-
font:
|
|
374
|
-
filter:
|
|
375
|
-
|
|
376
|
-
enable:
|
|
333
|
+
font: Schema.string().description("推送卡片的字体样式,如果你想用你自己的字体可以在此填写,例如:Microsoft YaHei"),
|
|
334
|
+
filter: Schema.intersect([
|
|
335
|
+
Schema.object({
|
|
336
|
+
enable: Schema.boolean()
|
|
377
337
|
.default(false)
|
|
378
338
|
.description("是否开启动态屏蔽功能"),
|
|
379
339
|
}).description("屏蔽设置"),
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
enable:
|
|
383
|
-
notify:
|
|
340
|
+
Schema.union([
|
|
341
|
+
Schema.object({
|
|
342
|
+
enable: Schema.const(true).required().experimental(),
|
|
343
|
+
notify: Schema.boolean()
|
|
384
344
|
.default(false)
|
|
385
345
|
.description("动态被屏蔽是否发送提示"),
|
|
386
|
-
regex:
|
|
387
|
-
keywords:
|
|
388
|
-
forward:
|
|
346
|
+
regex: Schema.string().description("正则表达式屏蔽"),
|
|
347
|
+
keywords: Schema.array(String).description("关键字屏蔽,一个关键字为一项"),
|
|
348
|
+
forward: Schema.boolean()
|
|
389
349
|
.default(false)
|
|
390
350
|
.description("是否屏蔽转发动态"),
|
|
391
|
-
article:
|
|
351
|
+
article: Schema.boolean().default(false).description("是否屏蔽专栏"),
|
|
392
352
|
}),
|
|
393
|
-
|
|
353
|
+
Schema.object({}),
|
|
394
354
|
]),
|
|
395
355
|
]),
|
|
396
|
-
debug:
|
|
397
|
-
dynamicDebugMode:
|
|
356
|
+
debug: Schema.object({}).description("调试设置"),
|
|
357
|
+
dynamicDebugMode: Schema.boolean()
|
|
398
358
|
.default(false)
|
|
399
359
|
.description("动态调试模式,开启后会在控制台输出动态推送的详细信息,用于调试"),
|
|
400
360
|
});
|
package/lib/type/index.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PushType = exports.LiveType = void 0;
|
|
4
|
-
var LiveType;
|
|
1
|
+
export var LiveType;
|
|
5
2
|
(function (LiveType) {
|
|
6
3
|
LiveType[LiveType["NotLiveBroadcast"] = 0] = "NotLiveBroadcast";
|
|
7
4
|
LiveType[LiveType["StartBroadcasting"] = 1] = "StartBroadcasting";
|
|
8
5
|
LiveType[LiveType["LiveBroadcast"] = 2] = "LiveBroadcast";
|
|
9
6
|
LiveType[LiveType["StopBroadcast"] = 3] = "StopBroadcast";
|
|
10
7
|
LiveType[LiveType["FirstLiveBroadcast"] = 4] = "FirstLiveBroadcast";
|
|
11
|
-
})(LiveType || (
|
|
12
|
-
var PushType;
|
|
8
|
+
})(LiveType || (LiveType = {}));
|
|
9
|
+
export var PushType;
|
|
13
10
|
(function (PushType) {
|
|
14
11
|
PushType[PushType["Live"] = 0] = "Live";
|
|
15
12
|
PushType[PushType["Dynamic"] = 1] = "Dynamic";
|
|
16
13
|
PushType[PushType["StartBroadcasting"] = 2] = "StartBroadcasting";
|
|
17
14
|
PushType[PushType["LiveGuardBuy"] = 3] = "LiveGuardBuy";
|
|
18
|
-
})(PushType || (
|
|
15
|
+
})(PushType || (PushType = {}));
|
package/lib/utils/index.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Retry = Retry;
|
|
4
|
-
exports.withLock = withLock;
|
|
5
|
-
exports.withRetry = withRetry;
|
|
6
|
-
function Retry(options = { attempts: 3 }) {
|
|
1
|
+
export function Retry(options = { attempts: 3 }) {
|
|
7
2
|
return (
|
|
8
3
|
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
9
4
|
target, propertyKey,
|
|
@@ -35,7 +30,7 @@ function Retry(options = { attempts: 3 }) {
|
|
|
35
30
|
* @param {Function} fn - 需要包装的原始函数
|
|
36
31
|
* @returns {Function} 带锁功能的函数
|
|
37
32
|
*/
|
|
38
|
-
function withLock(fn) {
|
|
33
|
+
export function withLock(fn) {
|
|
39
34
|
// 判断是否是异步函数
|
|
40
35
|
const isAsync = fn.constructor.name === "AsyncFunction";
|
|
41
36
|
// 定义锁标志
|
|
@@ -86,7 +81,7 @@ function withLock(fn) {
|
|
|
86
81
|
}
|
|
87
82
|
};
|
|
88
83
|
}
|
|
89
|
-
async function withRetry(fn, maxAttempts = 3, delayMs = 1000) {
|
|
84
|
+
export async function withRetry(fn, maxAttempts = 3, delayMs = 1000) {
|
|
90
85
|
let attempt = 0;
|
|
91
86
|
while (attempt < maxAttempts) {
|
|
92
87
|
try {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-bilibili-notify",
|
|
3
3
|
"description": "Koishi bilibili notify plugin",
|
|
4
|
-
"version": "3.2.1-alpha.
|
|
4
|
+
"version": "3.2.1-alpha.8",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Akokko <admin@akokko.com>"
|
|
7
7
|
],
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@akokko/blive-message-listener": "^0.5.1",
|
|
31
|
-
"axios": "^1.
|
|
32
|
-
"axios-cookiejar-support": "^
|
|
31
|
+
"axios": "^1.9.0",
|
|
32
|
+
"axios-cookiejar-support": "^6.0.2",
|
|
33
33
|
"cron": "^4.3.0",
|
|
34
34
|
"jsdom": "^26.1.0",
|
|
35
35
|
"luxon": "^3.6.1",
|
|
36
36
|
"md5": "^2.3.0",
|
|
37
37
|
"qrcode": "^1.5.4",
|
|
38
|
-
"tough-cookie": "^
|
|
38
|
+
"tough-cookie": "^5.1.2"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@biomejs/biome": "1.9.4",
|
package/readme.md
CHANGED
|
@@ -264,6 +264,7 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
|
|
|
264
264
|
- ver 3.2.1-alpha.5 修复:临时更换依赖 `blive-message-listener` 为 `@akokko/blive-message-listener` 以解决直播检测 `WS` 模式连接中断的问题;
|
|
265
265
|
- ver 3.2.1-alpha.6 修复:依赖 `axios-cookiejar-support@6.0.2` 为纯ESM依赖,运行报错 Error [ERR_REQUIRE_ESM]: require() of ES Module `xxx` not supported,降级回 `axios-cookiejar-support@5.0.5`
|
|
266
266
|
- ver 3.2.1-alpha.7 修复:依赖 `tough-cookie` 和 `axios` 回退版本;
|
|
267
|
+
- ver 3.2.1-alpha.8 调整:将项目构建产物调整为 `esm`; 优化:所有依赖更新;
|
|
267
268
|
|
|
268
269
|
## 交流群
|
|
269
270
|
|