koishi-plugin-bilibili-notify 1.2.0-alpha.5 → 1.2.0-rc.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 +2 -0
- package/lib/comRegister.js +32 -4
- package/lib/database.js +2 -2
- package/lib/index.d.ts +8 -4
- package/lib/index.js +44 -32
- package/package.json +2 -2
- package/readme.md +1 -0
package/lib/comRegister.d.ts
CHANGED
package/lib/comRegister.js
CHANGED
|
@@ -293,6 +293,14 @@ class ComRegister {
|
|
|
293
293
|
.example('bili sub 1194210119 目标QQ群号(实验性) -l -d 订阅UID为1194210119的UP主的动态和直播')
|
|
294
294
|
.action(async ({ session, options }, mid, ...guildId) => {
|
|
295
295
|
this.logger.info('调用bili.sub指令');
|
|
296
|
+
// 检查是否是不支持的平台
|
|
297
|
+
switch (session.event.platform) {
|
|
298
|
+
case 'red':
|
|
299
|
+
case 'onebot':
|
|
300
|
+
case 'qq':
|
|
301
|
+
case 'qqguild': break;
|
|
302
|
+
default: return '暂不支持该平台';
|
|
303
|
+
}
|
|
296
304
|
// 检查是否登录
|
|
297
305
|
if (!(await this.checkIfIsLogin(ctx))) {
|
|
298
306
|
// 未登录直接返回
|
|
@@ -784,8 +792,12 @@ class ComRegister {
|
|
|
784
792
|
open = false;
|
|
785
793
|
// 下播了将定时器清零
|
|
786
794
|
timer = 0;
|
|
795
|
+
// 定义下播通知消息
|
|
796
|
+
let liveEndMsg = this.config.customLiveEnd
|
|
797
|
+
.replace('-name', uData.info.uname)
|
|
798
|
+
.replace('-time', await ctx.gimg.getTimeDifference(liveTime));
|
|
787
799
|
// 发送下播通知
|
|
788
|
-
await this.sendMsg(guildId, bot,
|
|
800
|
+
await this.sendMsg(guildId, bot, liveEndMsg);
|
|
789
801
|
}
|
|
790
802
|
// 未进循环,还未开播,继续循环
|
|
791
803
|
break;
|
|
@@ -816,12 +828,19 @@ class ComRegister {
|
|
|
816
828
|
}
|
|
817
829
|
// 主播信息不会变,开播时刷新一次即可
|
|
818
830
|
uData = userData;
|
|
831
|
+
// 定义开播通知语
|
|
832
|
+
let liveStartMsg = this.config.customLiveStart
|
|
833
|
+
.replace('-name', uData.info.uname)
|
|
834
|
+
.replace('-time', await ctx.gimg.getTimeDifference(liveTime));
|
|
819
835
|
// 发送直播通知卡片
|
|
820
836
|
await sendLiveNotifyCard(data, uData, LiveType.StartBroadcasting);
|
|
821
837
|
// 判断是否需要@全体成员
|
|
822
838
|
if (this.config.liveStartAtAll) {
|
|
823
839
|
// 发送@全体成员通知
|
|
824
|
-
await this.sendMsg(guildId, bot, (0, jsx_runtime_1.jsx)("at", { type: "all" }));
|
|
840
|
+
await this.sendMsg(guildId, bot, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("at", { type: "all" }), " ", liveStartMsg, " "] }));
|
|
841
|
+
}
|
|
842
|
+
else {
|
|
843
|
+
await this.sendMsg(guildId, bot, liveStartMsg);
|
|
825
844
|
}
|
|
826
845
|
}
|
|
827
846
|
else { // 还在直播
|
|
@@ -911,18 +930,23 @@ class ComRegister {
|
|
|
911
930
|
}
|
|
912
931
|
async getSubFromDatabase(ctx) {
|
|
913
932
|
// 如果未登录,则直接返回
|
|
933
|
+
this.logger.info('Login info:', await this.checkIfIsLogin(ctx));
|
|
914
934
|
if (!(await this.checkIfIsLogin(ctx)))
|
|
915
935
|
return;
|
|
916
936
|
// 已存在订阅管理对象,不再进行订阅操作
|
|
937
|
+
this.logger.info('Sub Manager num:', this.subManager.length);
|
|
917
938
|
if (this.subManager.length !== 0)
|
|
918
939
|
return;
|
|
919
940
|
// 从数据库中获取数据
|
|
920
941
|
const subData = await ctx.database.get('bilibili', { id: { $gt: 0 } });
|
|
942
|
+
this.logger.info('Sub object:');
|
|
943
|
+
this.logger.info(subData);
|
|
921
944
|
// 设定订阅数量
|
|
922
945
|
this.num = subData.length;
|
|
923
|
-
|
|
924
|
-
//
|
|
946
|
+
this.logger.info('Sub number:' + this.num);
|
|
947
|
+
// 如果订阅数量超过三个则数据库被非法修改
|
|
925
948
|
if (!this.config.unlockSubLimits && this.num > 3) {
|
|
949
|
+
// 在控制台提示重新订阅
|
|
926
950
|
ctx.notifier.create({
|
|
927
951
|
type: 'danger',
|
|
928
952
|
content: '您未解锁订阅限制,且订阅数大于3人,请您手动删除bilibili表中多余的数据后重启本插件'
|
|
@@ -931,6 +955,8 @@ class ComRegister {
|
|
|
931
955
|
}
|
|
932
956
|
// 循环遍历
|
|
933
957
|
for (const sub of subData) {
|
|
958
|
+
this.logger.info('Single sub obj:');
|
|
959
|
+
this.logger.info(sub);
|
|
934
960
|
// 定义Bot
|
|
935
961
|
let bot;
|
|
936
962
|
// 判断是否存在没有任何订阅的数据
|
|
@@ -1119,6 +1145,8 @@ class ComRegister {
|
|
|
1119
1145
|
liveStartAtAll: koishi_1.Schema.boolean().required(),
|
|
1120
1146
|
pushTime: koishi_1.Schema.number().required(),
|
|
1121
1147
|
liveLoopTime: koishi_1.Schema.number().default(10),
|
|
1148
|
+
customLiveStart: koishi_1.Schema.string().required(),
|
|
1149
|
+
customLiveEnd: koishi_1.Schema.string().required(),
|
|
1122
1150
|
dynamicLoopTime: koishi_1.Schema.number().default(60),
|
|
1123
1151
|
dynamicCheckNumber: koishi_1.Schema.number().required()
|
|
1124
1152
|
});
|
package/lib/database.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.name = void 0;
|
|
4
|
+
exports.apply = apply;
|
|
4
5
|
exports.name = 'Database';
|
|
5
6
|
function apply(ctx) {
|
|
6
7
|
// 新增LoginBili表
|
|
@@ -22,4 +23,3 @@ function apply(ctx) {
|
|
|
22
23
|
time: 'timestamp'
|
|
23
24
|
}, { autoInc: true });
|
|
24
25
|
}
|
|
25
|
-
exports.apply = apply;
|
package/lib/index.d.ts
CHANGED
|
@@ -6,18 +6,22 @@ export interface Config {
|
|
|
6
6
|
key: string;
|
|
7
7
|
basicSettings: {};
|
|
8
8
|
unlockSubLimits: boolean;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
renderType: 'render' | 'page';
|
|
10
|
+
dynamic: {};
|
|
11
11
|
dynamicCheckNumber: number;
|
|
12
12
|
dynamicLoopTime: '1分钟' | '2分钟' | '3分钟' | '5分钟';
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
live: {};
|
|
14
|
+
pushTime: number;
|
|
15
|
+
liveStartAtAll: boolean;
|
|
16
|
+
customLiveStart: string;
|
|
17
|
+
customLiveEnd: string;
|
|
15
18
|
style: {};
|
|
16
19
|
removeBorder: boolean;
|
|
17
20
|
cardColorStart: string;
|
|
18
21
|
cardColorEnd: string;
|
|
19
22
|
enableLargeFont: boolean;
|
|
20
23
|
font: string;
|
|
24
|
+
filter: {};
|
|
21
25
|
}
|
|
22
26
|
export declare const Config: Schema<Config>;
|
|
23
27
|
export declare function apply(ctx: Context, config: Config): void;
|
package/lib/index.js
CHANGED
|
@@ -26,7 +26,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.Config = exports.name = exports.inject = void 0;
|
|
30
|
+
exports.apply = apply;
|
|
30
31
|
const koishi_1 = require("koishi");
|
|
31
32
|
// import plugins
|
|
32
33
|
// import Authority from './authority'
|
|
@@ -49,15 +50,11 @@ exports.Config = koishi_1.Schema.object({
|
|
|
49
50
|
unlockSubLimits: koishi_1.Schema.boolean()
|
|
50
51
|
.default(false)
|
|
51
52
|
.description('解锁3个订阅限制,默认只允许订阅3位UP主。订阅过多用户可能有导致IP暂时被封禁的风险'),
|
|
52
|
-
|
|
53
|
-
.
|
|
54
|
-
.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
.max(12)
|
|
58
|
-
.step(0.5)
|
|
59
|
-
.default(1)
|
|
60
|
-
.description('设定隔多长时间推送一次直播状态,单位为小时,默认为一小时'),
|
|
53
|
+
renderType: koishi_1.Schema.union(['render', 'page'])
|
|
54
|
+
.role('')
|
|
55
|
+
.default('render')
|
|
56
|
+
.description('渲染类型,默认为render模式,渲染速度更快,但会出现乱码问题,若出现乱码问题,请切换到page模式。若使用自定义字体,建议选择render模式'),
|
|
57
|
+
dynamic: koishi_1.Schema.object({}).description('动态推送设置'),
|
|
61
58
|
dynamicCheckNumber: koishi_1.Schema.number()
|
|
62
59
|
.min(2)
|
|
63
60
|
.max(10)
|
|
@@ -69,10 +66,41 @@ exports.Config = koishi_1.Schema.object({
|
|
|
69
66
|
.role('')
|
|
70
67
|
.default('2分钟')
|
|
71
68
|
.description('设定多久检测一次动态。若需动态的时效性,可以设置为1分钟。若订阅的UP主经常在短时间内连着发多条动态应该将该值提高,否则会出现动态漏推送和晚推送的问题,默认值为2分钟'),
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
.default(
|
|
75
|
-
.description('
|
|
69
|
+
live: koishi_1.Schema.object({}).description('直播推送设置'),
|
|
70
|
+
liveStartAtAll: koishi_1.Schema.boolean()
|
|
71
|
+
.default(false)
|
|
72
|
+
.description('直播开始时艾特全体成员,默认关闭'),
|
|
73
|
+
pushTime: koishi_1.Schema.number()
|
|
74
|
+
.min(0)
|
|
75
|
+
.max(12)
|
|
76
|
+
.step(0.5)
|
|
77
|
+
.default(1)
|
|
78
|
+
.description('设定隔多长时间推送一次直播状态,单位为小时,默认为一小时'),
|
|
79
|
+
customLiveStart: koishi_1.Schema.string()
|
|
80
|
+
.default('-name开播啦')
|
|
81
|
+
.experimental()
|
|
82
|
+
.description('自定义开播提示语,-name代表UP昵称。例如-name开播啦,会发送为xxxUP开播啦'),
|
|
83
|
+
customLiveEnd: koishi_1.Schema.string()
|
|
84
|
+
.default('-name下播啦,本次直播了-time')
|
|
85
|
+
.experimental()
|
|
86
|
+
.description('自定义下播提示语,-name代表UP昵称,-time代表开播时长。例如-name下播啦,本次直播了-time,会发送为xxxUP下播啦,直播时长为xx小时xx分钟xx秒'),
|
|
87
|
+
style: koishi_1.Schema.object({}).description('美化设置'),
|
|
88
|
+
removeBorder: koishi_1.Schema.boolean()
|
|
89
|
+
.default(false)
|
|
90
|
+
.description('移除推送卡片边框'),
|
|
91
|
+
cardColorStart: koishi_1.Schema.string()
|
|
92
|
+
.pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
|
|
93
|
+
.default('#F38AB5')
|
|
94
|
+
.description('推送卡片的开始渐变背景色,请填入16进制颜色代码,参考网站:https://webkul.github.io/coolhue/'),
|
|
95
|
+
cardColorEnd: koishi_1.Schema.string()
|
|
96
|
+
.pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
|
|
97
|
+
.default('#F9CCDF')
|
|
98
|
+
.description('推送卡片的结束渐变背景色,请填入16进制颜色代码,参考网站:https://colorate.azurewebsites.net/'),
|
|
99
|
+
enableLargeFont: koishi_1.Schema.boolean()
|
|
100
|
+
.default(false)
|
|
101
|
+
.description('是否开启动态推送卡片大字体模式,默认为小字体。小字体更漂亮,但阅读比较吃力,大字体更易阅读,但相对没这么好看'),
|
|
102
|
+
font: koishi_1.Schema.string()
|
|
103
|
+
.description('推送卡片的字体样式,如果你想用你自己的字体可以在此填写,例如:Microsoft YaHei'),
|
|
76
104
|
filter: koishi_1.Schema.intersect([
|
|
77
105
|
koishi_1.Schema.object({
|
|
78
106
|
enable: koishi_1.Schema.boolean()
|
|
@@ -91,23 +119,6 @@ exports.Config = koishi_1.Schema.object({
|
|
|
91
119
|
koishi_1.Schema.object({})
|
|
92
120
|
])
|
|
93
121
|
]),
|
|
94
|
-
style: koishi_1.Schema.object({}).description('美化设置'),
|
|
95
|
-
removeBorder: koishi_1.Schema.boolean()
|
|
96
|
-
.default(false)
|
|
97
|
-
.description('移除推送卡片边框'),
|
|
98
|
-
cardColorStart: koishi_1.Schema.string()
|
|
99
|
-
.pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
|
|
100
|
-
.default('#F38AB5')
|
|
101
|
-
.description('推送卡片的开始渐变背景色,请填入16进制颜色代码,参考网站:https://webkul.github.io/coolhue/'),
|
|
102
|
-
cardColorEnd: koishi_1.Schema.string()
|
|
103
|
-
.pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
|
|
104
|
-
.default('#F9CCDF')
|
|
105
|
-
.description('推送卡片的结束渐变背景色,请填入16进制颜色代码,参考网站:https://colorate.azurewebsites.net/'),
|
|
106
|
-
enableLargeFont: koishi_1.Schema.boolean()
|
|
107
|
-
.default(false)
|
|
108
|
-
.description('是否开启动态推送卡片大字体模式,默认为小字体。小字体更漂亮,但阅读比较吃力,大字体更易阅读,但相对没这么好看'),
|
|
109
|
-
font: koishi_1.Schema.string()
|
|
110
|
-
.description('推送卡片的字体样式,如果你想用你自己的字体可以在此填写,例如:Microsoft YaHei')
|
|
111
122
|
});
|
|
112
123
|
function apply(ctx, config) {
|
|
113
124
|
// 设置提示
|
|
@@ -168,6 +179,8 @@ function apply(ctx, config) {
|
|
|
168
179
|
unlockSubLimits: config.unlockSubLimits,
|
|
169
180
|
liveStartAtAll: config.liveStartAtAll,
|
|
170
181
|
pushTime: config.pushTime,
|
|
182
|
+
customLiveStart: config.customLiveStart,
|
|
183
|
+
customLiveEnd: config.customLiveEnd,
|
|
171
184
|
dynamicCheckNumber: config.dynamicCheckNumber,
|
|
172
185
|
dynamicLoopTime
|
|
173
186
|
});
|
|
@@ -181,4 +194,3 @@ function apply(ctx, config) {
|
|
|
181
194
|
}
|
|
182
195
|
});
|
|
183
196
|
}
|
|
184
|
-
exports.apply = apply;
|
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": "1.2.0-
|
|
4
|
+
"version": "1.2.0-rc.0",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Akokko <admin@akokko.com>"
|
|
7
7
|
],
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"bilibili"
|
|
25
25
|
],
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"koishi": "^4.17.
|
|
27
|
+
"koishi": "^4.17.2"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"axios": "^1.6.7",
|