koishi-plugin-bilibili-notify 1.2.3-rc.8 → 1.2.3
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.js +85 -49
- package/lib/database.js +2 -2
- package/lib/generateImg.js +58 -60
- package/lib/index.d.ts +2 -0
- package/lib/index.js +20 -2
- package/package.json +2 -1
- package/readme.md +4 -0
package/lib/comRegister.js
CHANGED
|
@@ -7,6 +7,8 @@ const jsx_runtime_1 = require("@satorijs/element/jsx-runtime");
|
|
|
7
7
|
const koishi_1 = require("koishi");
|
|
8
8
|
// 导入qrcode
|
|
9
9
|
const qrcode_1 = __importDefault(require("qrcode"));
|
|
10
|
+
const axios_1 = __importDefault(require("axios"));
|
|
11
|
+
const sharp_1 = __importDefault(require("sharp"));
|
|
10
12
|
var LiveType;
|
|
11
13
|
(function (LiveType) {
|
|
12
14
|
LiveType[LiveType["NotLiveBroadcast"] = 0] = "NotLiveBroadcast";
|
|
@@ -116,6 +118,8 @@ class ComRegister {
|
|
|
116
118
|
.usage('测试图片生成')
|
|
117
119
|
.example('test.gimg')
|
|
118
120
|
.action(async ({ session }, uid, index) => {
|
|
121
|
+
// logger
|
|
122
|
+
this.logger.info('调用test gimg指令')
|
|
119
123
|
// 获取用户空间动态数据
|
|
120
124
|
const { data } = await ctx.biliAPI.getUserSpaceDynamic(uid)
|
|
121
125
|
// 获取动态推送图片
|
|
@@ -155,12 +159,23 @@ class ComRegister {
|
|
|
155
159
|
.usage('发送下播提示语测试')
|
|
156
160
|
.example('test livestop')
|
|
157
161
|
.action(async ({ session }) => {
|
|
162
|
+
// logger
|
|
163
|
+
this.logger.info('调用test gimg指令')
|
|
164
|
+
// 获取主播信息
|
|
158
165
|
const { data } = await ctx.biliAPI.getMasterInfo('194484313')
|
|
159
|
-
|
|
166
|
+
// 获取图片二进制
|
|
167
|
+
const resp = await axios({
|
|
168
|
+
url: data.info.face,
|
|
169
|
+
method: 'GET',
|
|
170
|
+
responseType: 'arraybuffer'
|
|
171
|
+
})
|
|
172
|
+
// 使用sharp调整图片大小
|
|
173
|
+
const resizedImage = await sharp(resp.data)
|
|
174
|
+
.resize(100, 100)
|
|
175
|
+
.toBuffer()
|
|
176
|
+
// 发送下播提示语
|
|
160
177
|
await session.send(
|
|
161
|
-
<>
|
|
162
|
-
<img width="10px" height="10px" src="https://koishi.chat/logo.png" />
|
|
163
|
-
</>
|
|
178
|
+
<>{h.image(resizedImage, 'image/png')} 主播{data.info.uname}已下播</>
|
|
164
179
|
)
|
|
165
180
|
})
|
|
166
181
|
|
|
@@ -171,7 +186,7 @@ class ComRegister {
|
|
|
171
186
|
.action(async ({ session }) => {
|
|
172
187
|
// 获得对应bot
|
|
173
188
|
const bot = this.getTheCorrespondingBotBasedOnTheSession(session)
|
|
174
|
-
this.sendMsg(['all'], bot, 'Hello World')
|
|
189
|
+
// this.sendMsg(['all'], bot, 'Hello World')
|
|
175
190
|
}) */
|
|
176
191
|
const biliCom = ctx.command('bili', 'bili-notify插件相关指令', { permissions: ['authority:3'] });
|
|
177
192
|
biliCom.subcommand('.login', '登录B站之后才可以进行之后的操作')
|
|
@@ -360,7 +375,7 @@ class ComRegister {
|
|
|
360
375
|
content = await ctx.biliAPI.getUserInfo(mid);
|
|
361
376
|
}
|
|
362
377
|
catch (e) {
|
|
363
|
-
return 'bili sub getUserInfo()
|
|
378
|
+
return 'bili sub getUserInfo() 发生了错误,错误为:' + e.toString();
|
|
364
379
|
}
|
|
365
380
|
// 判断是否有其他问题
|
|
366
381
|
if (content.code !== 0) {
|
|
@@ -378,7 +393,9 @@ class ComRegister {
|
|
|
378
393
|
case -352:
|
|
379
394
|
msg = '请登录后再尝试订阅';
|
|
380
395
|
break;
|
|
381
|
-
default:
|
|
396
|
+
default:
|
|
397
|
+
msg = '未知错误,错误信息:' + content.message;
|
|
398
|
+
break;
|
|
382
399
|
}
|
|
383
400
|
return msg;
|
|
384
401
|
}
|
|
@@ -495,7 +512,7 @@ class ComRegister {
|
|
|
495
512
|
userData = data;
|
|
496
513
|
}
|
|
497
514
|
catch (e) {
|
|
498
|
-
this.logger.error('bili sub指令 getMasterInfo()
|
|
515
|
+
this.logger.error('bili sub指令 getMasterInfo() 发生了错误,错误为:' + e.toString());
|
|
499
516
|
return '订阅出错啦,请重试';
|
|
500
517
|
}
|
|
501
518
|
// 需要订阅直播
|
|
@@ -571,7 +588,7 @@ class ComRegister {
|
|
|
571
588
|
content = await ctx.biliAPI.getLiveRoomInfo(roomId);
|
|
572
589
|
}
|
|
573
590
|
catch (e) {
|
|
574
|
-
return 'bili status指令 getLiveRoomInfo()
|
|
591
|
+
return 'bili status指令 getLiveRoomInfo() 发生了错误,错误为:' + e.toString();
|
|
575
592
|
}
|
|
576
593
|
const { data } = content;
|
|
577
594
|
let userData;
|
|
@@ -580,7 +597,7 @@ class ComRegister {
|
|
|
580
597
|
userData = userInfo;
|
|
581
598
|
}
|
|
582
599
|
catch (e) {
|
|
583
|
-
return 'bili status指令 getMasterInfo()
|
|
600
|
+
return 'bili status指令 getMasterInfo() 发生了错误,错误为:' + e.toString();
|
|
584
601
|
}
|
|
585
602
|
// B站出问题了
|
|
586
603
|
if (content.code !== 0) {
|
|
@@ -588,7 +605,7 @@ class ComRegister {
|
|
|
588
605
|
session.send('未找到该房间');
|
|
589
606
|
}
|
|
590
607
|
else {
|
|
591
|
-
session.send('
|
|
608
|
+
session.send('未知错误,错误信息为:' + content.message);
|
|
592
609
|
}
|
|
593
610
|
return;
|
|
594
611
|
}
|
|
@@ -626,42 +643,42 @@ class ComRegister {
|
|
|
626
643
|
// 发送提示
|
|
627
644
|
await session.send('已发送消息,如未收到则说明您的机器人不支持发送私聊消息或您的信息填写有误');
|
|
628
645
|
});
|
|
629
|
-
biliCom
|
|
646
|
+
/* biliCom
|
|
630
647
|
.subcommand('.reboot', '测试插件自动重启功能', { hidden: true })
|
|
631
648
|
.usage('测试插件自动重启功能')
|
|
632
649
|
.example('bili reboot 测试插件自动重启功能')
|
|
633
650
|
.action(async ({ session }) => {
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
biliCom
|
|
651
|
+
// 发送提示消息
|
|
652
|
+
await session.send('测试biliAPI等服务自动重启功能')
|
|
653
|
+
// 获得对应bot
|
|
654
|
+
const bot = this.getTheCorrespondingBotBasedOnTheSession(session)
|
|
655
|
+
// 发送提示消息,重启服务
|
|
656
|
+
await this.sendPrivateMsgAndRebootService(ctx, bot, '测试biliAPI等服务自动重启功能')
|
|
657
|
+
}) */
|
|
658
|
+
/* biliCom
|
|
642
659
|
.subcommand('.sendall', '测试给机器人加入的所有群发送消息', { hidden: true })
|
|
643
660
|
.usage('测试给机器人加入的所有群发送消息')
|
|
644
661
|
.example('bili sendall 测试给机器人加入的所有群发送消息')
|
|
645
662
|
.action(async ({ session }) => {
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
biliCom
|
|
663
|
+
// 获得对应bot
|
|
664
|
+
const bot = this.getTheCorrespondingBotBasedOnTheSession(session)
|
|
665
|
+
// 发送消息
|
|
666
|
+
await this.sendMsg(ctx, ['all'], bot, 'Hello World')
|
|
667
|
+
// 发送提示
|
|
668
|
+
await session.send('已向机器人加入的所有群发送了消息')
|
|
669
|
+
}) */
|
|
670
|
+
/* biliCom
|
|
654
671
|
.subcommand('.list', '获取机器人加入的所有群组', { hidden: true })
|
|
655
672
|
.usage('获取当前机器人加入的所有群聊')
|
|
656
673
|
.example('bili list 获取当前机器人加入的所有群聊')
|
|
657
674
|
.action(async ({ session }) => {
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
675
|
+
// 获取对应Bot
|
|
676
|
+
const bot = this.getTheCorrespondingBotBasedOnTheSession(session)
|
|
677
|
+
// 获取群列表
|
|
678
|
+
const guildList = (await bot.getGuildList()).data
|
|
679
|
+
// 遍历群列表
|
|
680
|
+
guildList.map(item => this.logger.info(`已加入${item.id}`))
|
|
681
|
+
}) */
|
|
665
682
|
}
|
|
666
683
|
getTheCorrespondingBotBasedOnTheSession(session) {
|
|
667
684
|
// 获取对应Bot
|
|
@@ -708,12 +725,18 @@ class ComRegister {
|
|
|
708
725
|
}
|
|
709
726
|
async sendPrivateMsgAndRebootService(ctx, bot, content) {
|
|
710
727
|
await this.sendPrivateMsg(bot, content);
|
|
711
|
-
//
|
|
712
|
-
ctx.sm.
|
|
713
|
-
//
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
}
|
|
728
|
+
// 重启插件
|
|
729
|
+
const flag = ctx.sm.restartPlugin();
|
|
730
|
+
// 判断是否重启成功
|
|
731
|
+
if (flag) {
|
|
732
|
+
this.logger.info('重启插件成功');
|
|
733
|
+
}
|
|
734
|
+
else {
|
|
735
|
+
// 重启失败,发送消息
|
|
736
|
+
await this.sendPrivateMsg(bot, '已重启插件三次,请检查机器人状态后手动重启');
|
|
737
|
+
// 关闭插件
|
|
738
|
+
ctx.sm.disposePlugin();
|
|
739
|
+
}
|
|
717
740
|
}
|
|
718
741
|
async sendMsg(ctx, targets, bot, content) {
|
|
719
742
|
// 定义需要发送的数组
|
|
@@ -767,7 +790,7 @@ class ComRegister {
|
|
|
767
790
|
content = await ctx.biliAPI.getUserSpaceDynamic(uid);
|
|
768
791
|
}
|
|
769
792
|
catch (e) {
|
|
770
|
-
return this.logger.error('dynamicDetect getUserSpaceDynamic()
|
|
793
|
+
return this.logger.error('dynamicDetect getUserSpaceDynamic() 发生了错误,错误为:' + e.toString());
|
|
771
794
|
}
|
|
772
795
|
// 判断是否出现其他问题
|
|
773
796
|
if (content.code !== 0) {
|
|
@@ -776,10 +799,13 @@ class ComRegister {
|
|
|
776
799
|
await this.sendPrivateMsg(bot, '账号未登录,请登录后重新订阅动态');
|
|
777
800
|
break;
|
|
778
801
|
}
|
|
779
|
-
default: await this.sendPrivateMsg(bot, '
|
|
802
|
+
default: await this.sendPrivateMsg(bot, '获取动态信息错误,错误为:' + content.message); // 未知错误
|
|
780
803
|
}
|
|
781
804
|
// 取消订阅
|
|
782
805
|
this.unsubSingle(ctx, uid, 1); /* 1为取消动态订阅 */
|
|
806
|
+
// 发送取消订阅消息
|
|
807
|
+
await this.sendPrivateMsg(bot, `UID:${uid},已取消订阅动态`);
|
|
808
|
+
// 结束循环
|
|
783
809
|
return;
|
|
784
810
|
}
|
|
785
811
|
// 获取数据内容
|
|
@@ -921,7 +947,7 @@ class ComRegister {
|
|
|
921
947
|
break;
|
|
922
948
|
}
|
|
923
949
|
catch (e) {
|
|
924
|
-
this.logger.error('liveDetect getLiveRoomInfo
|
|
950
|
+
this.logger.error('liveDetect getLiveRoomInfo 发生了错误,错误为:' + e.toString());
|
|
925
951
|
if (i === attempts - 1) { // 已尝试三次
|
|
926
952
|
return await this.sendPrivateMsgAndRebootService(ctx, bot, '插件可能出现某些未知错误,请尝试重启插件,如果仍然发生该错误,请带着日志向作者反馈');
|
|
927
953
|
}
|
|
@@ -943,7 +969,7 @@ class ComRegister {
|
|
|
943
969
|
break;
|
|
944
970
|
}
|
|
945
971
|
catch (e) {
|
|
946
|
-
this.logger.error('liveDetect getMasterInfo()
|
|
972
|
+
this.logger.error('liveDetect getMasterInfo() 发生了错误,错误为:' + e.toString());
|
|
947
973
|
if (i === attempts - 1) { // 已尝试三次
|
|
948
974
|
return await this.sendPrivateMsgAndRebootService(ctx, bot, '插件可能出现某些未知错误,请尝试重启插件,如果仍然发生该错误,请带着日志向作者反馈');
|
|
949
975
|
}
|
|
@@ -975,8 +1001,18 @@ class ComRegister {
|
|
|
975
1001
|
let liveEndMsg = this.config.customLiveEnd
|
|
976
1002
|
.replace('-name', uData.info.uname)
|
|
977
1003
|
.replace('-time', await ctx.gimg.getTimeDifference(liveTime));
|
|
1004
|
+
// 获取图片二进制
|
|
1005
|
+
const resp = await (0, axios_1.default)({
|
|
1006
|
+
url: uData.info.face,
|
|
1007
|
+
method: 'GET',
|
|
1008
|
+
responseType: 'arraybuffer'
|
|
1009
|
+
});
|
|
1010
|
+
// 使用sharp调整图片大小
|
|
1011
|
+
const resizedImage = await (0, sharp_1.default)(resp.data)
|
|
1012
|
+
.resize(100, 100)
|
|
1013
|
+
.toBuffer();
|
|
978
1014
|
// 发送下播通知
|
|
979
|
-
await this.sendMsg(ctx, guildId, bot, liveEndMsg);
|
|
1015
|
+
await this.sendMsg(ctx, guildId, bot, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(resizedImage, 'image/png'), " ", liveEndMsg] }));
|
|
980
1016
|
}
|
|
981
1017
|
// 未进循环,还未开播,继续循环
|
|
982
1018
|
break;
|
|
@@ -999,7 +1035,7 @@ class ComRegister {
|
|
|
999
1035
|
break;
|
|
1000
1036
|
}
|
|
1001
1037
|
catch (e) {
|
|
1002
|
-
this.logger.error('liveDetect open getMasterInfo()
|
|
1038
|
+
this.logger.error('liveDetect open getMasterInfo() 发生了错误,错误为:' + e.toString());
|
|
1003
1039
|
if (i === attempts - 1) { // 已尝试三次
|
|
1004
1040
|
return await this.sendPrivateMsgAndRebootService(ctx, bot, '插件可能出现某些未知错误,请尝试重启插件,如果仍然发生该错误,请带着日志向作者反馈');
|
|
1005
1041
|
}
|
|
@@ -1102,7 +1138,7 @@ class ComRegister {
|
|
|
1102
1138
|
let subTableArray = subInfo.split('\n');
|
|
1103
1139
|
subTableArray.splice(subTableArray.length - 1, 1);
|
|
1104
1140
|
// 定义Table
|
|
1105
|
-
table = (0, jsx_runtime_1.
|
|
1141
|
+
table = (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("p", { children: "\u5F53\u524D\u8BA2\u9605\u5BF9\u8C61\uFF1A" }), (0, jsx_runtime_1.jsx)("ul", { children: subTableArray.map(str => ((0, jsx_runtime_1.jsx)("li", { children: str }))) })] });
|
|
1106
1142
|
}
|
|
1107
1143
|
// 设置更新后的提示
|
|
1108
1144
|
this.subNotifier = ctx.notifier.create(table);
|
|
@@ -1206,7 +1242,7 @@ class ComRegister {
|
|
|
1206
1242
|
break;
|
|
1207
1243
|
}
|
|
1208
1244
|
catch (e) {
|
|
1209
|
-
this.logger.error('getSubFromDatabase() getUserInfo()
|
|
1245
|
+
this.logger.error('getSubFromDatabase() getUserInfo() 发生了错误,错误为:' + e.toString());
|
|
1210
1246
|
if (i === attempts - 1) { // 已尝试三次
|
|
1211
1247
|
return await this.sendPrivateMsgAndRebootService(ctx, bot, '你的网络可能出现了某些问题,请检查后重启插件');
|
|
1212
1248
|
}
|
package/lib/database.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.name = void 0;
|
|
4
|
-
exports.apply = apply;
|
|
3
|
+
exports.apply = exports.name = void 0;
|
|
5
4
|
exports.name = 'Database';
|
|
6
5
|
function apply(ctx) {
|
|
7
6
|
// 新增LoginBili表
|
|
@@ -23,3 +22,4 @@ function apply(ctx) {
|
|
|
23
22
|
time: 'timestamp'
|
|
24
23
|
}, { autoInc: true });
|
|
25
24
|
}
|
|
25
|
+
exports.apply = apply;
|
package/lib/generateImg.js
CHANGED
|
@@ -68,40 +68,38 @@ class GenerateImg extends koishi_1.Service {
|
|
|
68
68
|
* {
|
|
69
69
|
margin: 0;
|
|
70
70
|
padding: 0;
|
|
71
|
+
box-sizing: border-box;
|
|
71
72
|
font-family: "${this.giConfig.font}", "Custom Font", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
|
|
72
73
|
}
|
|
73
|
-
|
|
74
|
+
|
|
74
75
|
html {
|
|
75
|
-
width:
|
|
76
|
+
width: 800px;
|
|
76
77
|
height: auto;
|
|
77
78
|
}
|
|
78
|
-
|
|
79
|
+
|
|
79
80
|
.background {
|
|
80
|
-
width:
|
|
81
|
+
width: 100%;
|
|
81
82
|
height: auto;
|
|
83
|
+
padding: 15px;
|
|
82
84
|
background: linear-gradient(to right bottom, ${this.giConfig.cardColorStart}, ${this.giConfig.cardColorEnd});
|
|
83
85
|
overflow: hidden;
|
|
84
86
|
}
|
|
85
|
-
|
|
86
|
-
.
|
|
87
|
-
width:
|
|
87
|
+
|
|
88
|
+
.base-plate {
|
|
89
|
+
width: 100%;
|
|
88
90
|
height: auto;
|
|
89
91
|
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
overflow: hidden;
|
|
92
|
+
padding: 15px;
|
|
93
|
+
border-radius: 10px;
|
|
93
94
|
background-color: #FFF5EE;
|
|
94
95
|
}
|
|
95
|
-
|
|
96
|
-
.
|
|
97
|
-
|
|
98
|
-
width: 740px;
|
|
99
|
-
` : `
|
|
100
|
-
width: 704px;
|
|
101
|
-
margin: 20px auto;
|
|
102
|
-
`}
|
|
96
|
+
|
|
97
|
+
.card {
|
|
98
|
+
width: 100%;
|
|
103
99
|
height: auto;
|
|
104
|
-
border-radius:
|
|
100
|
+
border-radius: 5px;
|
|
101
|
+
padding: 15px;
|
|
102
|
+
overflow: hidden;
|
|
105
103
|
background-color: #fff;
|
|
106
104
|
}
|
|
107
105
|
|
|
@@ -165,8 +163,8 @@ class GenerateImg extends koishi_1.Service {
|
|
|
165
163
|
</head>
|
|
166
164
|
<body>
|
|
167
165
|
<div class="background">
|
|
168
|
-
<div class="
|
|
169
|
-
<div class="
|
|
166
|
+
<div ${this.giConfig.removeBorder ? '' : 'class="base-plate"'}>
|
|
167
|
+
<div class="card">
|
|
170
168
|
<img src="${cover ? data.user_cover : data.keyframe}"
|
|
171
169
|
alt="封面">
|
|
172
170
|
<div class="card-body">
|
|
@@ -321,8 +319,9 @@ class GenerateImg extends koishi_1.Service {
|
|
|
321
319
|
// 转发动态
|
|
322
320
|
if (dynamicMajorData.type === DYNAMIC_TYPE_FORWARD) {
|
|
323
321
|
//转发动态屏蔽
|
|
324
|
-
if (this.giConfig.filter.enable && this.giConfig.filter.forward)
|
|
322
|
+
if (this.giConfig.filter.enable && this.giConfig.filter.forward) {
|
|
325
323
|
throw new Error('已屏蔽转发动态');
|
|
324
|
+
}
|
|
326
325
|
// User info
|
|
327
326
|
const forward_module_author = dynamicMajorData.orig.modules.module_author;
|
|
328
327
|
const forwardUserAvatarUrl = forward_module_author.face;
|
|
@@ -333,7 +332,7 @@ class GenerateImg extends koishi_1.Service {
|
|
|
333
332
|
main += `
|
|
334
333
|
<div class="card-forward">
|
|
335
334
|
<div class="forward-userinfo">
|
|
336
|
-
<img class="forward-avatar" src="${forwardUserAvatarUrl}" alt="">
|
|
335
|
+
<img class="forward-avatar" src="${forwardUserAvatarUrl}" alt="avatar">
|
|
337
336
|
<span class="forward-username">${forwardUserName} ${forwardInfo ? forwardInfo : ''}</span>
|
|
338
337
|
</div>
|
|
339
338
|
<div class="forward-main">
|
|
@@ -548,38 +547,35 @@ class GenerateImg extends koishi_1.Service {
|
|
|
548
547
|
box-sizing: border-box;
|
|
549
548
|
font-family: "${this.giConfig.font}", "Custom Font", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
|
|
550
549
|
}
|
|
551
|
-
|
|
550
|
+
|
|
552
551
|
html {
|
|
553
|
-
width:
|
|
552
|
+
width: 800px;
|
|
554
553
|
height: auto;
|
|
555
554
|
}
|
|
556
|
-
|
|
555
|
+
|
|
557
556
|
.background {
|
|
558
|
-
width:
|
|
557
|
+
width: 100%;
|
|
559
558
|
height: auto;
|
|
559
|
+
padding: 15px;
|
|
560
560
|
background: linear-gradient(to right bottom, ${this.giConfig.cardColorStart}, ${this.giConfig.cardColorEnd});
|
|
561
561
|
overflow: hidden;
|
|
562
562
|
}
|
|
563
|
-
|
|
564
|
-
.
|
|
565
|
-
width:
|
|
563
|
+
|
|
564
|
+
.base-plate {
|
|
565
|
+
width: 100%;
|
|
566
566
|
height: auto;
|
|
567
567
|
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
overflow: hidden;
|
|
568
|
+
padding: 15px;
|
|
569
|
+
border-radius: 10px;
|
|
571
570
|
background-color: #FFF5EE;
|
|
572
571
|
}
|
|
573
|
-
|
|
574
|
-
.
|
|
575
|
-
|
|
576
|
-
width: 740px;
|
|
577
|
-
` : `
|
|
578
|
-
width: 704px;
|
|
579
|
-
margin: 20px auto;
|
|
580
|
-
`}
|
|
572
|
+
|
|
573
|
+
.card {
|
|
574
|
+
width: 100%;
|
|
581
575
|
height: auto;
|
|
582
|
-
border-radius:
|
|
576
|
+
border-radius: 5px;
|
|
577
|
+
padding: 15px;
|
|
578
|
+
overflow: hidden;
|
|
583
579
|
background-color: #fff;
|
|
584
580
|
}
|
|
585
581
|
|
|
@@ -785,8 +781,8 @@ class GenerateImg extends koishi_1.Service {
|
|
|
785
781
|
}
|
|
786
782
|
|
|
787
783
|
.card .card-forward {
|
|
788
|
-
|
|
789
|
-
padding: 12px
|
|
784
|
+
border-radius: 5px;
|
|
785
|
+
padding: 12px 10px 14px 10px;
|
|
790
786
|
background-color: #F6F7F8;
|
|
791
787
|
}
|
|
792
788
|
|
|
@@ -876,36 +872,38 @@ class GenerateImg extends koishi_1.Service {
|
|
|
876
872
|
* {
|
|
877
873
|
margin: 0;
|
|
878
874
|
padding: 0;
|
|
875
|
+
box-sizing: border-box;
|
|
879
876
|
font-family: "${this.giConfig.font}", "Custom Font", "Microsoft YaHei", "Source Han Sans", "Noto Sans CJK", sans-serif;
|
|
880
877
|
}
|
|
881
878
|
|
|
882
879
|
html {
|
|
883
|
-
width:
|
|
880
|
+
width: 800px;
|
|
884
881
|
height: auto;
|
|
885
882
|
}
|
|
886
883
|
|
|
887
884
|
.background {
|
|
888
|
-
width:
|
|
885
|
+
width: 100%;
|
|
889
886
|
height: auto;
|
|
887
|
+
padding: 15px;
|
|
890
888
|
background: linear-gradient(to right bottom, ${this.giConfig.cardColorStart}, ${this.giConfig.cardColorEnd});
|
|
891
889
|
overflow: hidden;
|
|
892
890
|
}
|
|
893
|
-
|
|
894
|
-
.
|
|
895
|
-
width:
|
|
891
|
+
|
|
892
|
+
.base-plate {
|
|
893
|
+
width: 100%;
|
|
896
894
|
height: auto;
|
|
897
895
|
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
overflow: hidden;
|
|
896
|
+
padding: 15px;
|
|
897
|
+
border-radius: 10px;
|
|
901
898
|
background-color: #FFF5EE;
|
|
902
899
|
}
|
|
903
900
|
|
|
904
|
-
.
|
|
905
|
-
width:
|
|
901
|
+
.card {
|
|
902
|
+
width: 100%;
|
|
906
903
|
height: auto;
|
|
907
|
-
|
|
908
|
-
|
|
904
|
+
border-radius: 5px;
|
|
905
|
+
padding: 15px;
|
|
906
|
+
overflow: hidden;
|
|
909
907
|
background-color: #fff;
|
|
910
908
|
}
|
|
911
909
|
|
|
@@ -1112,8 +1110,8 @@ class GenerateImg extends koishi_1.Service {
|
|
|
1112
1110
|
}
|
|
1113
1111
|
|
|
1114
1112
|
.card .card-forward {
|
|
1115
|
-
|
|
1116
|
-
padding: 12px
|
|
1113
|
+
border-radius: 5px;
|
|
1114
|
+
padding: 12px 10px 14px 10px;
|
|
1117
1115
|
background-color: #F6F7F8;
|
|
1118
1116
|
}
|
|
1119
1117
|
|
|
@@ -1205,8 +1203,8 @@ class GenerateImg extends koishi_1.Service {
|
|
|
1205
1203
|
</head>
|
|
1206
1204
|
<body>
|
|
1207
1205
|
<div class="background">
|
|
1208
|
-
<div class="
|
|
1209
|
-
<div class="
|
|
1206
|
+
<div ${this.giConfig.removeBorder ? '' : 'class="base-plate"'}>
|
|
1207
|
+
<div class="card">
|
|
1210
1208
|
<div class="card-body">
|
|
1211
1209
|
<!-- 主播头像 -->
|
|
1212
1210
|
<img class="anchor-avatar"
|
package/lib/index.d.ts
CHANGED
|
@@ -34,10 +34,12 @@ export declare const Config: Schema<Config>;
|
|
|
34
34
|
declare class ServerManager extends Service {
|
|
35
35
|
servers: ForkScope[];
|
|
36
36
|
renderType: number;
|
|
37
|
+
restartCount: number;
|
|
37
38
|
constructor(ctx: Context);
|
|
38
39
|
protected start(): void | Promise<void>;
|
|
39
40
|
registerPlugin: () => void;
|
|
40
41
|
disposePlugin: () => void;
|
|
42
|
+
restartPlugin: () => boolean;
|
|
41
43
|
}
|
|
42
44
|
export declare function apply(ctx: Context, config: Config): void;
|
|
43
45
|
export {};
|
package/lib/index.js
CHANGED
|
@@ -26,8 +26,7 @@ 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.Config = exports.name = exports.inject = void 0;
|
|
30
|
-
exports.apply = apply;
|
|
29
|
+
exports.apply = exports.Config = exports.name = exports.inject = void 0;
|
|
31
30
|
const koishi_1 = require("koishi");
|
|
32
31
|
// import plugins
|
|
33
32
|
// import Authority from './authority'
|
|
@@ -149,9 +148,12 @@ exports.Config = koishi_1.Schema.object({
|
|
|
149
148
|
]),
|
|
150
149
|
});
|
|
151
150
|
class ServerManager extends koishi_1.Service {
|
|
151
|
+
// 服务
|
|
152
152
|
servers = [];
|
|
153
153
|
// 渲染模式
|
|
154
154
|
renderType;
|
|
155
|
+
// 重启次数
|
|
156
|
+
restartCount = 0;
|
|
155
157
|
constructor(ctx) {
|
|
156
158
|
super(ctx, 'sm');
|
|
157
159
|
}
|
|
@@ -185,6 +187,21 @@ class ServerManager extends koishi_1.Service {
|
|
|
185
187
|
fork.dispose();
|
|
186
188
|
});
|
|
187
189
|
};
|
|
190
|
+
restartPlugin = () => {
|
|
191
|
+
// 重启次数大于等于3次
|
|
192
|
+
if (this.restartCount >= 3)
|
|
193
|
+
return false;
|
|
194
|
+
// 重启次数+1
|
|
195
|
+
this.restartCount++;
|
|
196
|
+
// 停用插件
|
|
197
|
+
this.disposePlugin();
|
|
198
|
+
// 隔一秒启动插件
|
|
199
|
+
this.ctx.setTimeout(() => {
|
|
200
|
+
this.registerPlugin();
|
|
201
|
+
}, 1000);
|
|
202
|
+
// 返回true
|
|
203
|
+
return true;
|
|
204
|
+
};
|
|
188
205
|
}
|
|
189
206
|
function apply(ctx, config) {
|
|
190
207
|
// 设置config
|
|
@@ -244,3 +261,4 @@ function apply(ctx, config) {
|
|
|
244
261
|
}
|
|
245
262
|
});
|
|
246
263
|
}
|
|
264
|
+
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.3
|
|
4
|
+
"version": "1.2.3",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Akokko <admin@akokko.com>"
|
|
7
7
|
],
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"luxon": "^3.4.4",
|
|
34
34
|
"md5": "^2.3.0",
|
|
35
35
|
"qrcode": "^1.5.3",
|
|
36
|
+
"sharp": "^0.33.3",
|
|
36
37
|
"tough-cookie": "^4.1.3"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
package/readme.md
CHANGED
|
@@ -133,6 +133,10 @@
|
|
|
133
133
|
- ver 1.2.3-rc.6 bug测试版本,请跳过
|
|
134
134
|
- ver 1.2.3-rc.7 尝试修复多群推送时部分群未推送的bug
|
|
135
135
|
- ver 1.2.3-rc.8 修复在 `1.2.3-rc.7` 版本引入的连续推送三次的bug
|
|
136
|
+
- ver 1.2.3-rc.9 完善了插件出错时的日志输出
|
|
137
|
+
- ver 1.2.3-rc.10 修复不能移除边框的bug,对图片布局进行了调整,新增下播消息发送主播头像
|
|
138
|
+
- ver 1.2.3-rc.11 测试版本,请跳过
|
|
139
|
+
- ver 1.2.3 完善主播下播消息发送头像功能,优化控制台订阅信息显示
|
|
136
140
|
|
|
137
141
|
## 交流群
|
|
138
142
|
|