koishi-plugin-bilibili-notify 1.2.13 → 1.2.15
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 +11 -15
- package/lib/database.js +2 -2
- package/lib/generateImg.d.ts +2 -0
- package/lib/generateImg.js +9 -3
- package/lib/index.d.ts +1 -0
- package/lib/index.js +7 -3
- package/package.json +1 -1
- package/readme.md +2 -0
package/lib/comRegister.js
CHANGED
|
@@ -933,26 +933,25 @@ class ComRegister {
|
|
|
933
933
|
let firstSubscription = true;
|
|
934
934
|
let timePoint;
|
|
935
935
|
return async () => {
|
|
936
|
-
this.logger.info('动态监测开始');
|
|
937
936
|
// 第一次订阅判断
|
|
938
937
|
if (firstSubscription) {
|
|
939
|
-
this.logger.info(
|
|
938
|
+
this.logger.info(`UID:${uid}-动态监测开始`);
|
|
940
939
|
// 设置第一次的时间点
|
|
941
940
|
timePoint = ctx.ba.getTimeOfUTC8();
|
|
942
941
|
// 设置第一次为false
|
|
943
942
|
firstSubscription = false;
|
|
944
943
|
return;
|
|
945
944
|
}
|
|
946
|
-
this.logger.info(
|
|
945
|
+
this.logger.info(`UID:${uid}-获取动态信息中`);
|
|
947
946
|
// 获取用户空间动态数据
|
|
948
947
|
let content;
|
|
949
948
|
try {
|
|
950
949
|
content = await ctx.ba.getUserSpaceDynamic(uid);
|
|
951
950
|
}
|
|
952
951
|
catch (e) {
|
|
953
|
-
return this.logger.error(
|
|
952
|
+
return this.logger.error(`UID:${uid}-dynamicDetect getUserSpaceDynamic() 发生了错误,错误为:${e.message}`);
|
|
954
953
|
}
|
|
955
|
-
this.logger.info(
|
|
954
|
+
this.logger.info(`UID:${uid}-判断动态信息是否正确`);
|
|
956
955
|
// 判断是否出现其他问题
|
|
957
956
|
if (content.code !== 0) {
|
|
958
957
|
switch (content.code) {
|
|
@@ -996,10 +995,7 @@ class ComRegister {
|
|
|
996
995
|
}
|
|
997
996
|
// 获取数据内容
|
|
998
997
|
const items = content.data.items;
|
|
999
|
-
this.logger.info('
|
|
1000
|
-
items.forEach(element => {
|
|
1001
|
-
this.logger.info(element.basic.rid_str);
|
|
1002
|
-
});
|
|
998
|
+
this.logger.info(`UID:${uid}-获取到的动态信息:${items.map(v => v.basic.rid_str).join('、')}`);
|
|
1003
999
|
// 定义方法:更新时间点为最新发布动态的发布时间
|
|
1004
1000
|
const updatePoint = (num) => {
|
|
1005
1001
|
switch (num) {
|
|
@@ -1019,7 +1015,7 @@ class ComRegister {
|
|
|
1019
1015
|
continue;
|
|
1020
1016
|
// 寻找发布时间比时间点更晚的动态
|
|
1021
1017
|
if (items[num].modules.module_author.pub_ts > timePoint) {
|
|
1022
|
-
this.logger.info(
|
|
1018
|
+
this.logger.info(`UID:${uid}-即将推送的动态:${items[num].basic.rid_str}`);
|
|
1023
1019
|
// 定义变量
|
|
1024
1020
|
let pic;
|
|
1025
1021
|
let buffer;
|
|
@@ -1028,7 +1024,7 @@ class ComRegister {
|
|
|
1028
1024
|
const dynamicId = content.data.items[num].id_str;
|
|
1029
1025
|
// 推送该条动态
|
|
1030
1026
|
let attempts = 3;
|
|
1031
|
-
this.logger.info(
|
|
1027
|
+
this.logger.info(`UID:${uid}-尝试渲染推送图片`);
|
|
1032
1028
|
for (let i = 0; i < attempts; i++) {
|
|
1033
1029
|
// 获取动态推送图片
|
|
1034
1030
|
try {
|
|
@@ -1061,17 +1057,17 @@ class ComRegister {
|
|
|
1061
1057
|
}
|
|
1062
1058
|
}
|
|
1063
1059
|
}
|
|
1064
|
-
this.logger.info(
|
|
1060
|
+
this.logger.info(`UID:${uid}-尝试推送动态卡片`);
|
|
1065
1061
|
// 判断是否需要发送URL
|
|
1066
1062
|
const dUrl = this.config.dynamicUrl ? `${upName}发布了一条动态:https://t.bilibili.com/${dynamicId}` : '';
|
|
1067
1063
|
// 如果pic存在,则直接返回pic
|
|
1068
1064
|
if (pic) {
|
|
1069
|
-
this.logger.info(
|
|
1065
|
+
this.logger.info(`UID:${uid}-推送动态中,使用render模式`);
|
|
1070
1066
|
// pic存在,使用的是render模式
|
|
1071
1067
|
await this.sendMsg(ctx, guildId, bot, pic + (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: dUrl }));
|
|
1072
1068
|
}
|
|
1073
1069
|
else if (buffer) {
|
|
1074
|
-
this.logger.info(
|
|
1070
|
+
this.logger.info(`UID:${uid}-推送动态中,使用page模式`);
|
|
1075
1071
|
// pic不存在,说明使用的是page模式
|
|
1076
1072
|
await this.sendMsg(ctx, guildId, bot, (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [koishi_1.h.image(buffer, 'image/png'), dUrl] }));
|
|
1077
1073
|
}
|
|
@@ -1080,7 +1076,7 @@ class ComRegister {
|
|
|
1080
1076
|
}
|
|
1081
1077
|
// 更新时间点
|
|
1082
1078
|
updatePoint(num);
|
|
1083
|
-
this.logger.info(
|
|
1079
|
+
this.logger.info(`UID:${uid}-推送动态完成`);
|
|
1084
1080
|
}
|
|
1085
1081
|
}
|
|
1086
1082
|
};
|
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.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { Context, Schema, Service } from "koishi";
|
|
2
3
|
declare module 'koishi' {
|
|
3
4
|
interface Context {
|
|
@@ -43,6 +44,7 @@ declare namespace GenerateImg {
|
|
|
43
44
|
cardColorEnd: string;
|
|
44
45
|
enableLargeFont: boolean;
|
|
45
46
|
font: string;
|
|
47
|
+
hideDesc: boolean;
|
|
46
48
|
}
|
|
47
49
|
const Config: Schema<Config>;
|
|
48
50
|
}
|
package/lib/generateImg.js
CHANGED
|
@@ -155,6 +155,8 @@ class GenerateImg extends koishi_1.Service {
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
.card-link {
|
|
158
|
+
display: flex;
|
|
159
|
+
justify-content: space-between;
|
|
158
160
|
text-decoration: none;
|
|
159
161
|
font-size: 20px;
|
|
160
162
|
margin-top: 10px;
|
|
@@ -178,8 +180,11 @@ class GenerateImg extends koishi_1.Service {
|
|
|
178
180
|
<span class="broadcast-message">${userData.info.uname}${titleStatus}</span>
|
|
179
181
|
</div>
|
|
180
182
|
</div>
|
|
181
|
-
|
|
182
|
-
<p class="card-link"
|
|
183
|
+
${this.giConfig.hideDesc ? '' : `<p class="card-text">${data.description ? data.description : '这个主播很懒,什么都简介都没写'}</p>`}
|
|
184
|
+
<p class="card-link">
|
|
185
|
+
<span>${liveTime}</span>
|
|
186
|
+
<span>分区名称:${data.area_name}</span>
|
|
187
|
+
</p>
|
|
183
188
|
</div>
|
|
184
189
|
</div>
|
|
185
190
|
</div>
|
|
@@ -1380,7 +1385,8 @@ class GenerateImg extends koishi_1.Service {
|
|
|
1380
1385
|
cardColorStart: koishi_1.Schema.string(),
|
|
1381
1386
|
cardColorEnd: koishi_1.Schema.string(),
|
|
1382
1387
|
enableLargeFont: koishi_1.Schema.boolean(),
|
|
1383
|
-
font: koishi_1.Schema.string()
|
|
1388
|
+
font: koishi_1.Schema.string(),
|
|
1389
|
+
hideDesc: koishi_1.Schema.boolean()
|
|
1384
1390
|
});
|
|
1385
1391
|
})(GenerateImg || (GenerateImg = {}));
|
|
1386
1392
|
exports.default = GenerateImg;
|
package/lib/index.d.ts
CHANGED
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'
|
|
@@ -52,7 +51,6 @@ exports.Config = koishi_1.Schema.object({
|
|
|
52
51
|
enable: koishi_1.Schema.boolean()
|
|
53
52
|
.default(false)
|
|
54
53
|
.description('是否开启主人账号功能,如果您的机器人没有私聊权限请不要开启此功能。开启后如果机器人运行错误会向您进行报告')
|
|
55
|
-
.experimental()
|
|
56
54
|
}).description('主人账号'),
|
|
57
55
|
koishi_1.Schema.union([
|
|
58
56
|
koishi_1.Schema.object({
|
|
@@ -110,6 +108,10 @@ exports.Config = koishi_1.Schema.object({
|
|
|
110
108
|
customLiveEnd: koishi_1.Schema.string()
|
|
111
109
|
.default('-name下播啦,本次直播了-time')
|
|
112
110
|
.description('自定义下播提示语,-name代表UP昵称,-time代表开播时长。例如-name下播啦,本次直播了-time,会发送为xxxUP下播啦,直播时长为xx小时xx分钟xx秒'),
|
|
111
|
+
hideDesc: koishi_1.Schema.boolean()
|
|
112
|
+
.default(false)
|
|
113
|
+
.description('是否隐藏UP主直播间简介,开启后推送的直播卡片将不再展示简介')
|
|
114
|
+
.experimental(),
|
|
113
115
|
style: koishi_1.Schema.object({}).description('美化设置'),
|
|
114
116
|
removeBorder: koishi_1.Schema.boolean()
|
|
115
117
|
.default(false)
|
|
@@ -247,6 +249,7 @@ class ServerManager extends koishi_1.Service {
|
|
|
247
249
|
removeBorder: globalConfig.removeBorder,
|
|
248
250
|
cardColorStart: globalConfig.cardColorStart,
|
|
249
251
|
cardColorEnd: globalConfig.cardColorEnd,
|
|
252
|
+
hideDesc: globalConfig.hideDesc,
|
|
250
253
|
enableLargeFont: globalConfig.enableLargeFont,
|
|
251
254
|
font: globalConfig.font
|
|
252
255
|
});
|
|
@@ -344,3 +347,4 @@ function apply(ctx, config) {
|
|
|
344
347
|
}
|
|
345
348
|
});
|
|
346
349
|
}
|
|
350
|
+
exports.apply = apply;
|
package/package.json
CHANGED