koishi-plugin-bilibili-notify 3.0.0-alpha.2 → 3.0.0-alpha.20
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 +5 -6
- package/lib/biliAPI.js +394 -300
- package/lib/blive.d.ts +3 -11
- package/lib/blive.js +2 -24
- package/lib/comRegister.d.ts +12 -49
- package/lib/comRegister.js +537 -1117
- package/lib/database.d.ts +2 -13
- package/lib/database.js +6 -17
- package/lib/generateImg.d.ts +4 -3
- package/lib/generateImg.js +198 -159
- package/lib/index.d.ts +18 -19
- package/lib/index.js +212 -211
- package/lib/type/index.d.ts +37 -0
- package/lib/type/index.js +11 -0
- package/lib/utils/retry.d.ts +6 -0
- package/lib/utils/retry.js +24 -0
- package/lib/utils/withLock.d.ts +7 -0
- package/lib/utils/withLock.js +59 -0
- package/package.json +4 -5
- package/readme.md +23 -35
package/lib/index.d.ts
CHANGED
|
@@ -1,19 +1,29 @@
|
|
|
1
|
-
import { Context, ForkScope, Schema, Service } from
|
|
1
|
+
import { type Context, type ForkScope, Schema, Service } from "koishi";
|
|
2
2
|
export declare const inject: string[];
|
|
3
3
|
export declare const name = "bilibili-notify";
|
|
4
|
-
declare module
|
|
4
|
+
declare module "koishi" {
|
|
5
5
|
interface Context {
|
|
6
6
|
sm: ServerManager;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
+
declare class ServerManager extends Service {
|
|
10
|
+
servers: ForkScope[];
|
|
11
|
+
renderType: number;
|
|
12
|
+
dynamicLoopTime: number;
|
|
13
|
+
constructor(ctx: Context);
|
|
14
|
+
protected start(): void | Promise<void>;
|
|
15
|
+
registerPlugin: () => boolean;
|
|
16
|
+
disposePlugin: () => Promise<boolean>;
|
|
17
|
+
restartPlugin: () => Promise<boolean>;
|
|
18
|
+
}
|
|
19
|
+
export declare function apply(ctx: Context, config: Config): void;
|
|
9
20
|
export interface Config {
|
|
10
21
|
require: {};
|
|
11
22
|
key: string;
|
|
12
23
|
master: {};
|
|
13
24
|
basicSettings: {};
|
|
14
|
-
unlockSubLimits: boolean;
|
|
15
25
|
automaticResend: boolean;
|
|
16
|
-
renderType:
|
|
26
|
+
renderType: "render" | "page";
|
|
17
27
|
userAgent: string;
|
|
18
28
|
subTitle: {};
|
|
19
29
|
sub: Array<{
|
|
@@ -25,7 +35,7 @@ export interface Config {
|
|
|
25
35
|
channelId: string;
|
|
26
36
|
dynamic: boolean;
|
|
27
37
|
live: boolean;
|
|
28
|
-
|
|
38
|
+
liveGuardBuy: boolean;
|
|
29
39
|
atAll: boolean;
|
|
30
40
|
}>;
|
|
31
41
|
platform: string;
|
|
@@ -33,15 +43,15 @@ export interface Config {
|
|
|
33
43
|
}>;
|
|
34
44
|
dynamic: {};
|
|
35
45
|
dynamicUrl: boolean;
|
|
36
|
-
|
|
37
|
-
dynamicLoopTime: '1分钟' | '2分钟' | '3分钟' | '5分钟' | '10分钟' | '20分钟';
|
|
46
|
+
dynamicLoopTime: "1分钟" | "2分钟" | "3分钟" | "5分钟" | "10分钟" | "20分钟";
|
|
38
47
|
live: {};
|
|
48
|
+
liveDetectMode: "API" | "WS";
|
|
39
49
|
restartPush: boolean;
|
|
40
50
|
pushTime: number;
|
|
41
|
-
danmakuPushTime: number;
|
|
42
51
|
customLiveStart: string;
|
|
43
52
|
customLive: string;
|
|
44
53
|
customLiveEnd: string;
|
|
54
|
+
followerDisplay: boolean;
|
|
45
55
|
hideDesc: boolean;
|
|
46
56
|
style: {};
|
|
47
57
|
removeBorder: boolean;
|
|
@@ -54,15 +64,4 @@ export interface Config {
|
|
|
54
64
|
dynamicDebugMode: boolean;
|
|
55
65
|
}
|
|
56
66
|
export declare const Config: Schema<Config>;
|
|
57
|
-
declare class ServerManager extends Service {
|
|
58
|
-
servers: ForkScope[];
|
|
59
|
-
renderType: number;
|
|
60
|
-
dynamicLoopTime: number;
|
|
61
|
-
constructor(ctx: Context);
|
|
62
|
-
protected start(): void | Promise<void>;
|
|
63
|
-
registerPlugin: () => boolean;
|
|
64
|
-
disposePlugin: () => Promise<boolean>;
|
|
65
|
-
restartPlugin: () => Promise<boolean>;
|
|
66
|
-
}
|
|
67
|
-
export declare function apply(ctx: Context, config: Config): void;
|
|
68
67
|
export {};
|
package/lib/index.js
CHANGED
|
@@ -38,166 +38,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.Config = exports.name = exports.inject = void 0;
|
|
40
40
|
exports.apply = apply;
|
|
41
|
-
/* eslint-disable @typescript-eslint/ban-types */
|
|
42
41
|
const koishi_1 = require("koishi");
|
|
43
42
|
// import plugins
|
|
44
|
-
// import Authority from './authority'
|
|
45
43
|
const comRegister_1 = __importDefault(require("./comRegister"));
|
|
46
44
|
const Database = __importStar(require("./database"));
|
|
47
45
|
// import Service
|
|
48
46
|
const generateImg_1 = __importDefault(require("./generateImg"));
|
|
49
47
|
const biliAPI_1 = __importDefault(require("./biliAPI"));
|
|
50
48
|
const blive_1 = __importDefault(require("./blive"));
|
|
51
|
-
exports.inject = [
|
|
52
|
-
exports.name =
|
|
49
|
+
exports.inject = ["puppeteer", "database", "notifier"];
|
|
50
|
+
exports.name = "bilibili-notify";
|
|
53
51
|
let globalConfig;
|
|
54
|
-
exports.Config = koishi_1.Schema.object({
|
|
55
|
-
require: koishi_1.Schema.object({}).description('必填设置'),
|
|
56
|
-
key: koishi_1.Schema.string()
|
|
57
|
-
.pattern(/^[0-9a-f]{32}$/)
|
|
58
|
-
.role('secret')
|
|
59
|
-
.required()
|
|
60
|
-
.description('请输入一个32位小写字母的十六进制密钥(例如:9b8db7ae562b9864efefe06289cc5530),使用此密钥将你的B站登录信息存储在数据库中,请一定保存好此密钥。如果你忘记了此密钥,必须重新登录。你可以自行生成,或到这个网站生成:https://www.sexauth.com/'),
|
|
61
|
-
master: koishi_1.Schema.intersect([
|
|
62
|
-
koishi_1.Schema.object({
|
|
63
|
-
enable: koishi_1.Schema.boolean()
|
|
64
|
-
.default(false)
|
|
65
|
-
.description('是否开启主人账号功能,如果您的机器人没有私聊权限请不要开启此功能。开启后如果机器人运行错误会向您进行报告')
|
|
66
|
-
}).description('主人账号'),
|
|
67
|
-
koishi_1.Schema.union([
|
|
68
|
-
koishi_1.Schema.object({
|
|
69
|
-
enable: koishi_1.Schema.const(true).required(),
|
|
70
|
-
platform: koishi_1.Schema.union(['qq', 'qqguild', 'onebot', 'discord', 'red', 'telegram', 'satori', 'chronocat', 'lark'])
|
|
71
|
-
.description('请选择您的私人机器人平台,目前支持QQ、QQ群、OneBot、Discord、RedBot、Telegram、Satori、ChronoCat、Lark。从2.0版本开始,只能在一个平台下使用本插件'),
|
|
72
|
-
masterAccount: koishi_1.Schema.string()
|
|
73
|
-
.role('secret')
|
|
74
|
-
.required()
|
|
75
|
-
.description('主人账号,在Q群使用可直接使用QQ号,若在其他平台使用,请使用inspect插件获取自身ID'),
|
|
76
|
-
masterAccountGuildId: koishi_1.Schema.string()
|
|
77
|
-
.role('secret')
|
|
78
|
-
.description('主人账号所在的群组ID,只有在QQ频道、Discord这样的环境才需要填写,请使用inspect插件获取群组ID'),
|
|
79
|
-
}),
|
|
80
|
-
koishi_1.Schema.object({})
|
|
81
|
-
])
|
|
82
|
-
]),
|
|
83
|
-
basicSettings: koishi_1.Schema.object({}).description('基本设置'),
|
|
84
|
-
unlockSubLimits: koishi_1.Schema.boolean()
|
|
85
|
-
.default(false)
|
|
86
|
-
.description('解锁3个直播订阅限制,默认只允许订阅3位UP主。订阅过多用户可能有导致IP暂时被封禁的风险'),
|
|
87
|
-
automaticResend: koishi_1.Schema.boolean()
|
|
88
|
-
.default(true)
|
|
89
|
-
.description('是否开启自动重发功能,默认开启。开启后,如果推送失败,将会自动重发,尝试三次。关闭后,推送失败将不会再重发,直到下一次推送'),
|
|
90
|
-
renderType: koishi_1.Schema.union(['render', 'page'])
|
|
91
|
-
.role('')
|
|
92
|
-
.default('render')
|
|
93
|
-
.description('渲染类型,默认为render模式,渲染速度更快,但会出现乱码问题,若出现乱码问题,请切换到page模式。若使用自定义字体,建议选择render模式'),
|
|
94
|
-
userAgent: koishi_1.Schema.string()
|
|
95
|
-
.required()
|
|
96
|
-
.description('设置请求头User-Agen,请求出现-352时可以尝试修改,UA获取方法可参考:https://blog.csdn.net/qq_44503987/article/details/104929111'),
|
|
97
|
-
subTitle: koishi_1.Schema.object({}).description('手动订阅'),
|
|
98
|
-
sub: koishi_1.Schema.array(koishi_1.Schema.object({
|
|
99
|
-
uid: koishi_1.Schema.string().description('订阅用户UID'),
|
|
100
|
-
dynamic: koishi_1.Schema.boolean().description('是否订阅用户动态'),
|
|
101
|
-
live: koishi_1.Schema.boolean().description('是否订阅用户直播'),
|
|
102
|
-
target: koishi_1.Schema.array(koishi_1.Schema.object({
|
|
103
|
-
channelIdArr: koishi_1.Schema.array(koishi_1.Schema.object({
|
|
104
|
-
channelId: koishi_1.Schema.string().description('频道/群组号'),
|
|
105
|
-
dynamic: koishi_1.Schema.boolean().description('该频道/群组是否推送动态信息'),
|
|
106
|
-
live: koishi_1.Schema.boolean().description('该频道/群组是否推送直播通知'),
|
|
107
|
-
liveDanmaku: koishi_1.Schema.boolean().description('该频道/群组是否推送弹幕消息'),
|
|
108
|
-
atAll: koishi_1.Schema.boolean().description('推送开播通知时是否艾特全体成员')
|
|
109
|
-
})).description('频道/群组信息'),
|
|
110
|
-
platform: koishi_1.Schema.string().description('推送平台')
|
|
111
|
-
})).description('订阅用户需要发送的频道/群组信息')
|
|
112
|
-
})).role('table').description('手动输入订阅信息,方便自定义订阅内容,这里的订阅内容不会存入数据库。uid: 订阅用户UID,dynamic: 是否需要订阅动态,live: 是否需要订阅直播'),
|
|
113
|
-
dynamic: koishi_1.Schema.object({}).description('动态推送设置'),
|
|
114
|
-
dynamicUrl: koishi_1.Schema.boolean()
|
|
115
|
-
.default(false)
|
|
116
|
-
.description('发送动态时是否同时发送链接。注意:如果使用的是QQ官方机器人不能开启此项!'),
|
|
117
|
-
dynamicCheckNumber: koishi_1.Schema.number()
|
|
118
|
-
.min(2)
|
|
119
|
-
.max(10)
|
|
120
|
-
.role('slider')
|
|
121
|
-
.step(1)
|
|
122
|
-
.default(5)
|
|
123
|
-
.description('设定每次检查动态的数量。若订阅的UP主经常在短时间内连着发多条动态可以将该值提高,若订阅的UP主有置顶动态,在计算该值时应+1。默认值为5条'),
|
|
124
|
-
dynamicLoopTime: koishi_1.Schema.union(['1分钟', '2分钟', '3分钟', '5分钟', '10分钟', '20分钟'])
|
|
125
|
-
.role('')
|
|
126
|
-
.default('2分钟')
|
|
127
|
-
.description('设定多久检测一次动态。若需动态的时效性,可以设置为1分钟。若订阅的UP主经常在短时间内连着发多条动态应该将该值提高,否则会出现动态漏推送和晚推送的问题,默认值为2分钟'),
|
|
128
|
-
live: koishi_1.Schema.object({}).description('直播推送设置'),
|
|
129
|
-
restartPush: koishi_1.Schema.boolean()
|
|
130
|
-
.default(true)
|
|
131
|
-
.description('插件重启后,如果订阅的主播正在直播,是否进行一次推送,默认开启'),
|
|
132
|
-
pushTime: koishi_1.Schema.number()
|
|
133
|
-
.min(0)
|
|
134
|
-
.max(12)
|
|
135
|
-
.step(0.5)
|
|
136
|
-
.default(1)
|
|
137
|
-
.description('设定间隔多长时间推送一次直播状态,单位为小时,默认为一小时'),
|
|
138
|
-
danmakuPushTime: koishi_1.Schema.number()
|
|
139
|
-
.min(0)
|
|
140
|
-
.max(10)
|
|
141
|
-
.step(0.5)
|
|
142
|
-
.default(0.5)
|
|
143
|
-
.description('设定间隔多长时间推送一次弹幕消息,单位为分钟,默认为半分钟'),
|
|
144
|
-
customLiveStart: koishi_1.Schema.string()
|
|
145
|
-
.default('-name开播啦 -link')
|
|
146
|
-
.description('自定义开播提示语,-name代表UP昵称,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用)。例如-name开播啦,会发送为xxxUP开播啦'),
|
|
147
|
-
customLive: koishi_1.Schema.string()
|
|
148
|
-
.description('自定义直播中提示语,-name代表UP昵称,-time代表开播时长,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用)。例如-name正在直播,会发送为xxxUP正在直播xxx'),
|
|
149
|
-
customLiveEnd: koishi_1.Schema.string()
|
|
150
|
-
.default('-name下播啦,本次直播了-time')
|
|
151
|
-
.description('自定义下播提示语,-name代表UP昵称,-time代表开播时长。例如-name下播啦,本次直播了-time,会发送为xxxUP下播啦,直播时长为xx小时xx分钟xx秒'),
|
|
152
|
-
hideDesc: koishi_1.Schema.boolean()
|
|
153
|
-
.default(false)
|
|
154
|
-
.description('是否隐藏UP主直播间简介,开启后推送的直播卡片将不再展示简介'),
|
|
155
|
-
style: koishi_1.Schema.object({}).description('美化设置'),
|
|
156
|
-
removeBorder: koishi_1.Schema.boolean()
|
|
157
|
-
.default(false)
|
|
158
|
-
.description('移除推送卡片边框'),
|
|
159
|
-
cardColorStart: koishi_1.Schema.string()
|
|
160
|
-
.pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
|
|
161
|
-
.default('#F38AB5')
|
|
162
|
-
.description('推送卡片的开始渐变背景色,请填入16进制颜色代码,参考网站:https://webkul.github.io/coolhue/'),
|
|
163
|
-
cardColorEnd: koishi_1.Schema.string()
|
|
164
|
-
.pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
|
|
165
|
-
.default('#F9CCDF')
|
|
166
|
-
.description('推送卡片的结束渐变背景色,请填入16进制颜色代码,参考网站:https://colorate.azurewebsites.net/'),
|
|
167
|
-
enableLargeFont: koishi_1.Schema.boolean()
|
|
168
|
-
.default(false)
|
|
169
|
-
.description('是否开启动态推送卡片大字体模式,默认为小字体。小字体更漂亮,但阅读比较吃力,大字体更易阅读,但相对没这么好看'),
|
|
170
|
-
font: koishi_1.Schema.string()
|
|
171
|
-
.description('推送卡片的字体样式,如果你想用你自己的字体可以在此填写,例如:Microsoft YaHei'),
|
|
172
|
-
filter: koishi_1.Schema.intersect([
|
|
173
|
-
koishi_1.Schema.object({
|
|
174
|
-
enable: koishi_1.Schema.boolean()
|
|
175
|
-
.default(false)
|
|
176
|
-
.description('是否开启动态屏蔽功能')
|
|
177
|
-
}).description('屏蔽设置'),
|
|
178
|
-
koishi_1.Schema.union([
|
|
179
|
-
koishi_1.Schema.object({
|
|
180
|
-
enable: koishi_1.Schema.const(true).required().experimental(),
|
|
181
|
-
notify: koishi_1.Schema.boolean()
|
|
182
|
-
.default(false)
|
|
183
|
-
.description('动态被屏蔽是否发送提示'),
|
|
184
|
-
regex: koishi_1.Schema.string()
|
|
185
|
-
.description('正则表达式屏蔽'),
|
|
186
|
-
keywords: koishi_1.Schema.array(String)
|
|
187
|
-
.description('关键字屏蔽,一个关键字为一项'),
|
|
188
|
-
forward: koishi_1.Schema.boolean()
|
|
189
|
-
.default(false)
|
|
190
|
-
.description("是否屏蔽转发动态"),
|
|
191
|
-
}),
|
|
192
|
-
koishi_1.Schema.object({})
|
|
193
|
-
])
|
|
194
|
-
]),
|
|
195
|
-
debug: koishi_1.Schema.object({}).description('调试设置'),
|
|
196
|
-
dynamicDebugMode: koishi_1.Schema.boolean()
|
|
197
|
-
.default(false)
|
|
198
|
-
.description('动态调试模式,开启后会在控制台输出动态推送的详细信息,用于调试')
|
|
199
|
-
.experimental()
|
|
200
|
-
});
|
|
201
52
|
class ServerManager extends koishi_1.Service {
|
|
202
53
|
// 服务
|
|
203
54
|
servers = [];
|
|
@@ -206,81 +57,83 @@ class ServerManager extends koishi_1.Service {
|
|
|
206
57
|
// 动态循环时间
|
|
207
58
|
dynamicLoopTime;
|
|
208
59
|
constructor(ctx) {
|
|
209
|
-
super(ctx,
|
|
60
|
+
super(ctx, "sm");
|
|
210
61
|
// 插件运行相关指令
|
|
211
|
-
const sysCom = ctx.command(
|
|
62
|
+
const sysCom = ctx.command("sys", "bili-notify插件运行相关指令", {
|
|
63
|
+
permissions: ["authority:5"],
|
|
64
|
+
});
|
|
212
65
|
sysCom
|
|
213
|
-
.subcommand(
|
|
214
|
-
.usage(
|
|
215
|
-
.example(
|
|
66
|
+
.subcommand(".restart", "重启插件")
|
|
67
|
+
.usage("重启插件")
|
|
68
|
+
.example("sys restart")
|
|
216
69
|
.action(async () => {
|
|
217
|
-
this.logger.info(
|
|
70
|
+
this.logger.info("调用sys restart指令");
|
|
218
71
|
if (await this.restartPlugin()) {
|
|
219
|
-
return
|
|
72
|
+
return "插件重启成功";
|
|
220
73
|
}
|
|
221
|
-
return
|
|
74
|
+
return "插件重启失败";
|
|
222
75
|
});
|
|
223
76
|
sysCom
|
|
224
|
-
.subcommand(
|
|
225
|
-
.usage(
|
|
226
|
-
.example(
|
|
77
|
+
.subcommand(".stop", "停止插件")
|
|
78
|
+
.usage("停止插件")
|
|
79
|
+
.example("sys stop")
|
|
227
80
|
.action(async () => {
|
|
228
|
-
this.logger.info(
|
|
81
|
+
this.logger.info("调用sys stop指令");
|
|
229
82
|
if (await this.disposePlugin()) {
|
|
230
|
-
return
|
|
83
|
+
return "插件已停止";
|
|
231
84
|
}
|
|
232
|
-
return
|
|
85
|
+
return "停止插件失败";
|
|
233
86
|
});
|
|
234
87
|
sysCom
|
|
235
|
-
.subcommand(
|
|
236
|
-
.usage(
|
|
237
|
-
.example(
|
|
88
|
+
.subcommand(".start", "启动插件")
|
|
89
|
+
.usage("启动插件")
|
|
90
|
+
.example("sys start")
|
|
238
91
|
.action(async () => {
|
|
239
|
-
this.logger.info(
|
|
92
|
+
this.logger.info("调用sys start指令");
|
|
240
93
|
if (await this.registerPlugin()) {
|
|
241
|
-
return
|
|
94
|
+
return "插件启动成功";
|
|
242
95
|
}
|
|
243
|
-
return
|
|
96
|
+
return "插件启动失败";
|
|
244
97
|
});
|
|
245
98
|
}
|
|
246
99
|
start() {
|
|
247
100
|
// 加载配置
|
|
248
101
|
// 根据用户设置的渲染模式设置
|
|
249
102
|
switch (globalConfig.renderType) {
|
|
250
|
-
case
|
|
103
|
+
case "render":
|
|
251
104
|
this.renderType = 0;
|
|
252
105
|
break;
|
|
253
|
-
case
|
|
106
|
+
case "page":
|
|
254
107
|
this.renderType = 1;
|
|
255
108
|
break;
|
|
256
109
|
}
|
|
257
110
|
// 转换为具体时间
|
|
258
111
|
switch (globalConfig.dynamicLoopTime) {
|
|
259
|
-
case
|
|
112
|
+
case "1分钟":
|
|
260
113
|
this.dynamicLoopTime = 60;
|
|
261
114
|
break;
|
|
262
|
-
case
|
|
115
|
+
case "2分钟":
|
|
263
116
|
this.dynamicLoopTime = 120;
|
|
264
117
|
break;
|
|
265
|
-
case
|
|
118
|
+
case "3分钟":
|
|
266
119
|
this.dynamicLoopTime = 180;
|
|
267
120
|
break;
|
|
268
|
-
case
|
|
121
|
+
case "5分钟":
|
|
269
122
|
this.dynamicLoopTime = 300;
|
|
270
123
|
break;
|
|
271
|
-
case
|
|
124
|
+
case "10分钟":
|
|
272
125
|
this.dynamicLoopTime = 600;
|
|
273
126
|
break;
|
|
274
|
-
case
|
|
127
|
+
case "20分钟":
|
|
275
128
|
this.dynamicLoopTime = 1200;
|
|
276
129
|
break;
|
|
277
130
|
}
|
|
278
131
|
// 注册插件
|
|
279
132
|
if (this.registerPlugin()) {
|
|
280
|
-
this.logger.info(
|
|
133
|
+
this.logger.info("插件启动成功");
|
|
281
134
|
}
|
|
282
135
|
else {
|
|
283
|
-
this.logger.error(
|
|
136
|
+
this.logger.error("插件启动失败");
|
|
284
137
|
}
|
|
285
138
|
}
|
|
286
139
|
registerPlugin = () => {
|
|
@@ -292,7 +145,7 @@ class ServerManager extends koishi_1.Service {
|
|
|
292
145
|
// BA = BiliAPI
|
|
293
146
|
const ba = this.ctx.plugin(biliAPI_1.default, {
|
|
294
147
|
userAgent: globalConfig.userAgent,
|
|
295
|
-
key: globalConfig.key
|
|
148
|
+
key: globalConfig.key,
|
|
296
149
|
});
|
|
297
150
|
// GI = GenerateImg
|
|
298
151
|
const gi = this.ctx.plugin(generateImg_1.default, {
|
|
@@ -303,29 +156,27 @@ class ServerManager extends koishi_1.Service {
|
|
|
303
156
|
cardColorEnd: globalConfig.cardColorEnd,
|
|
304
157
|
hideDesc: globalConfig.hideDesc,
|
|
305
158
|
enableLargeFont: globalConfig.enableLargeFont,
|
|
306
|
-
font: globalConfig.font
|
|
159
|
+
font: globalConfig.font,
|
|
160
|
+
followerDisplay: globalConfig.followerDisplay
|
|
307
161
|
});
|
|
308
162
|
// CR = ComRegister
|
|
309
163
|
const cr = this.ctx.plugin(comRegister_1.default, {
|
|
310
164
|
sub: globalConfig.sub,
|
|
311
165
|
master: globalConfig.master,
|
|
312
|
-
unlockSubLimits: globalConfig.unlockSubLimits,
|
|
313
166
|
automaticResend: globalConfig.automaticResend,
|
|
167
|
+
liveDetectMode: globalConfig.liveDetectMode,
|
|
314
168
|
restartPush: globalConfig.restartPush,
|
|
315
169
|
pushTime: globalConfig.pushTime,
|
|
316
170
|
customLiveStart: globalConfig.customLiveStart,
|
|
317
171
|
customLive: globalConfig.customLive,
|
|
318
172
|
customLiveEnd: globalConfig.customLiveEnd,
|
|
319
|
-
dynamicCheckNumber: globalConfig.dynamicCheckNumber,
|
|
320
173
|
dynamicLoopTime: this.dynamicLoopTime,
|
|
321
174
|
dynamicUrl: globalConfig.dynamicUrl,
|
|
322
175
|
filter: globalConfig.filter,
|
|
323
|
-
dynamicDebugMode: globalConfig.dynamicDebugMode
|
|
176
|
+
dynamicDebugMode: globalConfig.dynamicDebugMode,
|
|
324
177
|
});
|
|
325
178
|
// BL = BLive
|
|
326
|
-
const bl = this.ctx.plugin(blive_1.default
|
|
327
|
-
danmakuPushTime: globalConfig.danmakuPushTime
|
|
328
|
-
});
|
|
179
|
+
const bl = this.ctx.plugin(blive_1.default);
|
|
329
180
|
// 添加服务
|
|
330
181
|
this.servers.push(ba);
|
|
331
182
|
this.servers.push(bl);
|
|
@@ -333,10 +184,10 @@ class ServerManager extends koishi_1.Service {
|
|
|
333
184
|
this.servers.push(cr);
|
|
334
185
|
}
|
|
335
186
|
catch (e) {
|
|
336
|
-
this.logger.error(
|
|
187
|
+
this.logger.error("插件注册失败", e);
|
|
337
188
|
return false;
|
|
338
189
|
}
|
|
339
|
-
// 成功返回true
|
|
190
|
+
// 成功返回true
|
|
340
191
|
return true;
|
|
341
192
|
};
|
|
342
193
|
disposePlugin = async () => {
|
|
@@ -344,13 +195,13 @@ class ServerManager extends koishi_1.Service {
|
|
|
344
195
|
if (this.servers.length === 0)
|
|
345
196
|
return false;
|
|
346
197
|
// 遍历服务
|
|
347
|
-
await new Promise(resolve => {
|
|
348
|
-
this.servers
|
|
198
|
+
await new Promise((resolve) => {
|
|
199
|
+
for (const fork of this.servers) {
|
|
349
200
|
fork.dispose();
|
|
350
|
-
}
|
|
201
|
+
}
|
|
351
202
|
// 清空服务
|
|
352
203
|
this.servers = [];
|
|
353
|
-
resolve(
|
|
204
|
+
resolve("ok");
|
|
354
205
|
});
|
|
355
206
|
// 成功返回true
|
|
356
207
|
return true;
|
|
@@ -362,13 +213,13 @@ class ServerManager extends koishi_1.Service {
|
|
|
362
213
|
// 停用插件
|
|
363
214
|
await this.disposePlugin();
|
|
364
215
|
// 隔一秒启动插件
|
|
365
|
-
return new Promise(resolve => {
|
|
216
|
+
return new Promise((resolve) => {
|
|
366
217
|
this.ctx.setTimeout(() => {
|
|
367
218
|
try {
|
|
368
219
|
this.registerPlugin();
|
|
369
220
|
}
|
|
370
221
|
catch (e) {
|
|
371
|
-
this.logger.error(
|
|
222
|
+
this.logger.error("重启插件失败", e);
|
|
372
223
|
resolve(false);
|
|
373
224
|
}
|
|
374
225
|
resolve(true);
|
|
@@ -381,29 +232,179 @@ function apply(ctx, config) {
|
|
|
381
232
|
globalConfig = config;
|
|
382
233
|
// 设置提示
|
|
383
234
|
ctx.notifier.create({
|
|
384
|
-
|
|
235
|
+
type: "danger",
|
|
236
|
+
content: "3.0.0-alpha.16 全面从指令订阅迁移到配置订阅,以前使用指令的订阅需要全部重新填写到订阅配置中",
|
|
385
237
|
});
|
|
386
238
|
ctx.notifier.create({
|
|
387
|
-
|
|
239
|
+
type: "warning",
|
|
240
|
+
content: "请使用Auth插件创建超级管理员账号,没有权限将无法使用该插件提供的指令",
|
|
388
241
|
});
|
|
389
|
-
if (config.unlockSubLimits) { // 用户允许订阅超过三个用户
|
|
390
|
-
// 设置警告
|
|
391
|
-
ctx.notifier.create({
|
|
392
|
-
type: 'danger',
|
|
393
|
-
content: '过多的订阅可能会导致IP暂时被封禁!'
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
242
|
// load database
|
|
397
243
|
ctx.plugin(Database);
|
|
398
244
|
// Register ServerManager
|
|
399
245
|
ctx.plugin(ServerManager);
|
|
400
246
|
// 当用户输入“恶魔兔,启动!”时,执行 help 指令
|
|
401
247
|
ctx.middleware((session, next) => {
|
|
402
|
-
if (session.content ===
|
|
403
|
-
return session.send(
|
|
404
|
-
}
|
|
405
|
-
else {
|
|
406
|
-
return next();
|
|
248
|
+
if (session.content === "恶魔兔,启动!") {
|
|
249
|
+
return session.send("启动不了一点");
|
|
407
250
|
}
|
|
251
|
+
return next();
|
|
408
252
|
});
|
|
409
253
|
}
|
|
254
|
+
exports.Config = koishi_1.Schema.object({
|
|
255
|
+
require: koishi_1.Schema.object({}).description("必填设置"),
|
|
256
|
+
key: koishi_1.Schema.string()
|
|
257
|
+
.pattern(/^[0-9a-f]{32}$/)
|
|
258
|
+
.role("secret")
|
|
259
|
+
.required()
|
|
260
|
+
.description("请输入一个32位小写字母的十六进制密钥(例如:9b8db7ae562b9864efefe06289cc5530),使用此密钥将你的B站登录信息存储在数据库中,请一定保存好此密钥。如果你忘记了此密钥,必须重新登录。你可以自行生成,或到这个网站生成:https://www.sexauth.com/"),
|
|
261
|
+
master: koishi_1.Schema.intersect([
|
|
262
|
+
koishi_1.Schema.object({
|
|
263
|
+
enable: koishi_1.Schema.boolean()
|
|
264
|
+
.default(false)
|
|
265
|
+
.description("是否开启主人账号功能,如果您的机器人没有私聊权限请不要开启此功能。开启后如果机器人运行错误会向您进行报告"),
|
|
266
|
+
}).description("主人账号"),
|
|
267
|
+
koishi_1.Schema.union([
|
|
268
|
+
koishi_1.Schema.object({
|
|
269
|
+
enable: koishi_1.Schema.const(true).required(),
|
|
270
|
+
platform: koishi_1.Schema.union([
|
|
271
|
+
"qq",
|
|
272
|
+
"qqguild",
|
|
273
|
+
"onebot",
|
|
274
|
+
"discord",
|
|
275
|
+
"red",
|
|
276
|
+
"telegram",
|
|
277
|
+
"satori",
|
|
278
|
+
"chronocat",
|
|
279
|
+
"lark",
|
|
280
|
+
]).description("请选择您的私人机器人平台,目前支持QQ、QQ群、OneBot、Discord、RedBot、Telegram、Satori、ChronoCat、Lark。从2.0版本开始,只能在一个平台下使用本插件"),
|
|
281
|
+
masterAccount: koishi_1.Schema.string()
|
|
282
|
+
.role("secret")
|
|
283
|
+
.required()
|
|
284
|
+
.description("主人账号,在Q群使用可直接使用QQ号,若在其他平台使用,请使用inspect插件获取自身ID"),
|
|
285
|
+
masterAccountGuildId: koishi_1.Schema.string()
|
|
286
|
+
.role("secret")
|
|
287
|
+
.description("主人账号所在的群组ID,只有在QQ频道、Discord这样的环境才需要填写,请使用inspect插件获取群组ID"),
|
|
288
|
+
}),
|
|
289
|
+
koishi_1.Schema.object({}),
|
|
290
|
+
]),
|
|
291
|
+
]),
|
|
292
|
+
basicSettings: koishi_1.Schema.object({}).description("基本设置"),
|
|
293
|
+
automaticResend: koishi_1.Schema.boolean()
|
|
294
|
+
.default(true)
|
|
295
|
+
.description("是否开启自动重发功能,默认开启。开启后,如果推送失败,将会自动重发,尝试三次。关闭后,推送失败将不会再重发,直到下一次推送"),
|
|
296
|
+
renderType: koishi_1.Schema.union(["render", "page"])
|
|
297
|
+
.role("")
|
|
298
|
+
.default("render")
|
|
299
|
+
.description("渲染类型,默认为render模式,渲染速度更快,但会出现乱码问题,若出现乱码问题,请切换到page模式。若使用自定义字体,建议选择render模式"),
|
|
300
|
+
userAgent: koishi_1.Schema.string()
|
|
301
|
+
.required()
|
|
302
|
+
.description("设置请求头User-Agen,请求出现-352时可以尝试修改,UA获取方法可参考:https://blog.csdn.net/qq_44503987/article/details/104929111"),
|
|
303
|
+
subTitle: koishi_1.Schema.object({}).description("订阅配置"),
|
|
304
|
+
sub: koishi_1.Schema.array(koishi_1.Schema.object({
|
|
305
|
+
uid: koishi_1.Schema.string().required().description("订阅用户UID"),
|
|
306
|
+
dynamic: koishi_1.Schema.boolean().default(false).description("是否订阅用户动态"),
|
|
307
|
+
live: koishi_1.Schema.boolean().default(false).description("是否订阅用户直播"),
|
|
308
|
+
target: koishi_1.Schema.array(koishi_1.Schema.object({
|
|
309
|
+
channelIdArr: koishi_1.Schema.array(koishi_1.Schema.object({
|
|
310
|
+
channelId: koishi_1.Schema.string().required().description("频道/群组号"),
|
|
311
|
+
dynamic: koishi_1.Schema.boolean().default(false).description("该频道/群组是否推送动态信息"),
|
|
312
|
+
live: koishi_1.Schema.boolean().default(false).description("该频道/群组是否推送直播通知"),
|
|
313
|
+
liveGuardBuy: koishi_1.Schema.boolean().default(false).description("该频道/群组是否推送上舰消息"),
|
|
314
|
+
atAll: koishi_1.Schema.boolean().default(false).description("推送开播通知时是否艾特全体成员"),
|
|
315
|
+
})).required().description("需推送的频道/群组详细设置"),
|
|
316
|
+
platform: koishi_1.Schema.string().required().description("推送平台"),
|
|
317
|
+
})).description("订阅用户需要发送的平台和频道/群组信息(一个平台下可以推送多个频道/群组)"),
|
|
318
|
+
}))
|
|
319
|
+
.role("table")
|
|
320
|
+
.description("输入订阅信息,自定义订阅内容; uid: 订阅用户UID,dynamic: 是否需要订阅动态,live: 是否需要订阅直播"),
|
|
321
|
+
dynamic: koishi_1.Schema.object({}).description("动态推送设置"),
|
|
322
|
+
dynamicUrl: koishi_1.Schema.boolean()
|
|
323
|
+
.default(false)
|
|
324
|
+
.description("发送动态时是否同时发送链接。注意:如果使用的是QQ官方机器人不能开启此项!"),
|
|
325
|
+
dynamicLoopTime: koishi_1.Schema.union([
|
|
326
|
+
"1分钟",
|
|
327
|
+
"2分钟",
|
|
328
|
+
"3分钟",
|
|
329
|
+
"5分钟",
|
|
330
|
+
"10分钟",
|
|
331
|
+
"20分钟",
|
|
332
|
+
])
|
|
333
|
+
.role("")
|
|
334
|
+
.default("2分钟")
|
|
335
|
+
.description("设定多久检测一次动态。若需动态的时效性,可以设置为1分钟。若订阅的UP主经常在短时间内连着发多条动态应该将该值提高,否则会出现动态漏推送和晚推送的问题,默认值为2分钟"),
|
|
336
|
+
live: koishi_1.Schema.object({}).description("直播推送设置"),
|
|
337
|
+
liveDetectMode: koishi_1.Schema.union([
|
|
338
|
+
koishi_1.Schema.const("WS").description("WebSocket模式:连接到对应的直播间,可推送弹幕消息,开播下播响应最快,但对订阅数有限制"),
|
|
339
|
+
koishi_1.Schema.const("API")
|
|
340
|
+
.description("API模式:请求对应直播间API,无法获取弹幕消息,开播下播响应慢,理论可无限订阅")
|
|
341
|
+
.deprecated(),
|
|
342
|
+
])
|
|
343
|
+
.role("radio")
|
|
344
|
+
.description("直播检测模式")
|
|
345
|
+
.default("WS"),
|
|
346
|
+
restartPush: koishi_1.Schema.boolean()
|
|
347
|
+
.default(true)
|
|
348
|
+
.description("插件重启后,如果订阅的主播正在直播,是否进行一次推送,默认开启"),
|
|
349
|
+
pushTime: koishi_1.Schema.number()
|
|
350
|
+
.min(0)
|
|
351
|
+
.max(12)
|
|
352
|
+
.step(0.5)
|
|
353
|
+
.default(1)
|
|
354
|
+
.description("设定间隔多长时间推送一次直播状态,单位为小时,默认为一小时"),
|
|
355
|
+
customLiveStart: koishi_1.Schema.string()
|
|
356
|
+
.default("-name开播啦,当前粉丝数为-follower -link")
|
|
357
|
+
.description("自定义开播提示语,-name代表UP昵称,-follower代表当前粉丝数,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用)。例如-name开播啦,会发送为xxxUP开播啦"),
|
|
358
|
+
customLive: koishi_1.Schema.string()
|
|
359
|
+
.default("-name正在直播,目前已播-time。累计看过人数:-watched,-link")
|
|
360
|
+
.description("自定义直播中提示语,-name代表UP昵称,-time代表开播时长,-watched代表累计看过人数,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用)。例如-name正在直播,会发送为xxxUP正在直播xxx"),
|
|
361
|
+
customLiveEnd: koishi_1.Schema.string()
|
|
362
|
+
.default("-name下播啦,本次直播了-time。粉丝数变化-follower_change")
|
|
363
|
+
.description("自定义下播提示语,-name代表UP昵称,-follower_change代表本场直播粉丝数变,-time代表开播时长。例如-name下播啦,本次直播了-time,会发送为xxxUP下播啦,直播时长为xx小时xx分钟xx秒"),
|
|
364
|
+
followerDisplay: koishi_1.Schema.boolean()
|
|
365
|
+
.default(true)
|
|
366
|
+
.description("粉丝数变化和看过本场直播的人数是否显示在推送卡片中"),
|
|
367
|
+
hideDesc: koishi_1.Schema.boolean()
|
|
368
|
+
.default(false)
|
|
369
|
+
.description("是否隐藏UP主直播间简介,开启后推送的直播卡片将不再展示简介"),
|
|
370
|
+
style: koishi_1.Schema.object({}).description("美化设置"),
|
|
371
|
+
removeBorder: koishi_1.Schema.boolean().default(false).description("移除推送卡片边框"),
|
|
372
|
+
cardColorStart: koishi_1.Schema.string()
|
|
373
|
+
.pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
|
|
374
|
+
.default("#F38AB5")
|
|
375
|
+
.description("推送卡片的开始渐变背景色,请填入16进制颜色代码,参考网站:https://webkul.github.io/coolhue/"),
|
|
376
|
+
cardColorEnd: koishi_1.Schema.string()
|
|
377
|
+
.pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
|
|
378
|
+
.default("#F9CCDF")
|
|
379
|
+
.description("推送卡片的结束渐变背景色,请填入16进制颜色代码,参考网站:https://colorate.azurewebsites.net/"),
|
|
380
|
+
enableLargeFont: koishi_1.Schema.boolean()
|
|
381
|
+
.default(false)
|
|
382
|
+
.description("是否开启动态推送卡片大字体模式,默认为小字体。小字体更漂亮,但阅读比较吃力,大字体更易阅读,但相对没这么好看"),
|
|
383
|
+
font: koishi_1.Schema.string().description("推送卡片的字体样式,如果你想用你自己的字体可以在此填写,例如:Microsoft YaHei"),
|
|
384
|
+
filter: koishi_1.Schema.intersect([
|
|
385
|
+
koishi_1.Schema.object({
|
|
386
|
+
enable: koishi_1.Schema.boolean()
|
|
387
|
+
.default(false)
|
|
388
|
+
.description("是否开启动态屏蔽功能"),
|
|
389
|
+
}).description("屏蔽设置"),
|
|
390
|
+
koishi_1.Schema.union([
|
|
391
|
+
koishi_1.Schema.object({
|
|
392
|
+
enable: koishi_1.Schema.const(true).required().experimental(),
|
|
393
|
+
notify: koishi_1.Schema.boolean()
|
|
394
|
+
.default(false)
|
|
395
|
+
.description("动态被屏蔽是否发送提示"),
|
|
396
|
+
regex: koishi_1.Schema.string().description("正则表达式屏蔽"),
|
|
397
|
+
keywords: koishi_1.Schema.array(String).description("关键字屏蔽,一个关键字为一项"),
|
|
398
|
+
forward: koishi_1.Schema.boolean()
|
|
399
|
+
.default(false)
|
|
400
|
+
.description("是否屏蔽转发动态"),
|
|
401
|
+
}),
|
|
402
|
+
koishi_1.Schema.object({}),
|
|
403
|
+
]),
|
|
404
|
+
]),
|
|
405
|
+
debug: koishi_1.Schema.object({}).description("调试设置"),
|
|
406
|
+
dynamicDebugMode: koishi_1.Schema.boolean()
|
|
407
|
+
.default(false)
|
|
408
|
+
.description("动态调试模式,开启后会在控制台输出动态推送的详细信息,用于调试")
|
|
409
|
+
.experimental(),
|
|
410
|
+
});
|