koishi-plugin-bilibili-notify 3.2.3 → 3.2.4
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 +1 -0
- package/lib/comRegister.js +41 -15
- package/lib/index.d.ts +2 -0
- package/lib/index.js +9 -6
- package/package.json +1 -1
- package/readme.md +4 -2
package/lib/comRegister.d.ts
CHANGED
package/lib/comRegister.js
CHANGED
|
@@ -177,6 +177,14 @@ class ComRegister {
|
|
|
177
177
|
bili_refresh_token: encryptedRefreshToken,
|
|
178
178
|
},
|
|
179
179
|
]);
|
|
180
|
+
// 检查登录数据库是否有数据
|
|
181
|
+
this.loginDBData = (await this.ctx.database.get("loginBili", 1, [
|
|
182
|
+
"dynamic_group_id",
|
|
183
|
+
]))[0];
|
|
184
|
+
// ba重新加载登录信息
|
|
185
|
+
await this.ctx.ba.loadCookiesFromDatabase();
|
|
186
|
+
// 判断登录信息是否已加载完毕
|
|
187
|
+
await this.checkIfLoginInfoIsLoaded();
|
|
180
188
|
// 销毁定时器
|
|
181
189
|
this.loginTimer();
|
|
182
190
|
// 订阅手动订阅中的订阅
|
|
@@ -189,7 +197,7 @@ class ComRegister {
|
|
|
189
197
|
// 发送成功登录推送
|
|
190
198
|
await session.send("登录成功");
|
|
191
199
|
// bili show
|
|
192
|
-
await session.execute("bili
|
|
200
|
+
await session.execute("bili list");
|
|
193
201
|
// 开启cookies刷新检测
|
|
194
202
|
ctx.ba.enableRefreshCookiesDetect();
|
|
195
203
|
}
|
|
@@ -513,7 +521,7 @@ class ComRegister {
|
|
|
513
521
|
// 获取机器人实例
|
|
514
522
|
const bot = this.getBot(targets[0].platform, targetChannel.bot);
|
|
515
523
|
// 判断bot是否存在
|
|
516
|
-
if (!bot) {
|
|
524
|
+
if (!bot || !bot.isActive) {
|
|
517
525
|
// 发送私聊消息
|
|
518
526
|
this.sendPrivateMsg("未找到对应bot实例,本次消息推送取消!");
|
|
519
527
|
// logger
|
|
@@ -673,7 +681,17 @@ class ComRegister {
|
|
|
673
681
|
// 判断是否需要发送URL
|
|
674
682
|
if (this.config.dynamicUrl) {
|
|
675
683
|
if (item.type === "DYNAMIC_TYPE_AV") {
|
|
676
|
-
|
|
684
|
+
// 判断是否开启url to bv
|
|
685
|
+
if (this.config.dynamicVideoUrlToBV) {
|
|
686
|
+
// 截取bv号
|
|
687
|
+
const bv = item.modules.module_dynamic.major.archive.jump_url.match(/BV[0-9A-Za-z]+/);
|
|
688
|
+
// 获取bv号
|
|
689
|
+
dUrl = bv ? bv[0] : "";
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
// 生成视频链接
|
|
693
|
+
dUrl = `${name}发布了新视频:https:${item.modules.module_dynamic.major.archive.jump_url}`;
|
|
694
|
+
}
|
|
677
695
|
}
|
|
678
696
|
else {
|
|
679
697
|
// 生成动态链接
|
|
@@ -692,11 +710,10 @@ class ComRegister {
|
|
|
692
710
|
const pics = item.modules?.module_dynamic?.major?.opus?.pics;
|
|
693
711
|
// 判断pics是否存在
|
|
694
712
|
if (pics) {
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
}
|
|
713
|
+
// 组合消息
|
|
714
|
+
const picsMsg = ((0, jsx_runtime_1.jsx)("message", { forward: true, children: pics.map((pic) => ((0, jsx_runtime_1.jsx)("img", { src: pic.url, alt: "\u52A8\u6001\u56FE\u7247" }, pic.url))) }));
|
|
715
|
+
// 发送消息
|
|
716
|
+
await this.broadcastToTargets(sub.target, picsMsg, type_1.PushType.Dynamic);
|
|
700
717
|
}
|
|
701
718
|
}
|
|
702
719
|
}
|
|
@@ -860,7 +877,17 @@ class ComRegister {
|
|
|
860
877
|
this.logger.info("需要发送动态链接,开始生成链接...");
|
|
861
878
|
// 判断动态类型
|
|
862
879
|
if (item.type === "DYNAMIC_TYPE_AV") {
|
|
863
|
-
|
|
880
|
+
// 判断是否开启url to bv
|
|
881
|
+
if (this.config.dynamicVideoUrlToBV) {
|
|
882
|
+
// 截取bv号
|
|
883
|
+
const bv = item.modules.module_dynamic.major.archive.jump_url.match(/BV[0-9A-Za-z]+/);
|
|
884
|
+
// 获取bv号
|
|
885
|
+
dUrl = bv ? bv[0] : "";
|
|
886
|
+
}
|
|
887
|
+
else {
|
|
888
|
+
// 生成视频链接
|
|
889
|
+
dUrl = `${name}发布了新视频:https:${item.modules.module_dynamic.major.archive.jump_url}`;
|
|
890
|
+
}
|
|
864
891
|
}
|
|
865
892
|
else {
|
|
866
893
|
// 生成动态链接
|
|
@@ -883,11 +910,10 @@ class ComRegister {
|
|
|
883
910
|
const pics = item.modules?.module_dynamic?.major?.opus?.pics;
|
|
884
911
|
// 判断pics是否存在
|
|
885
912
|
if (pics) {
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
}
|
|
913
|
+
// 组合消息
|
|
914
|
+
const picsMsg = ((0, jsx_runtime_1.jsx)("message", { forward: true, children: pics.map((pic) => ((0, jsx_runtime_1.jsx)("img", { src: pic.url, alt: "\u52A8\u6001\u56FE\u7247" }, pic.url))) }));
|
|
915
|
+
// 发送消息
|
|
916
|
+
await this.broadcastToTargets(sub.target, picsMsg, type_1.PushType.Dynamic);
|
|
891
917
|
}
|
|
892
918
|
}
|
|
893
919
|
// logger
|
|
@@ -920,7 +946,6 @@ class ComRegister {
|
|
|
920
946
|
// 返回一个闭包函数
|
|
921
947
|
return (0, utils_1.withLock)(handler);
|
|
922
948
|
}
|
|
923
|
-
// 定义获取主播信息方法
|
|
924
949
|
async useMasterInfo(uid, masterInfo, liveType) {
|
|
925
950
|
// 获取主播信息
|
|
926
951
|
const { data } = await this.ctx.ba.getMasterInfo(uid);
|
|
@@ -1858,6 +1883,7 @@ class ComRegister {
|
|
|
1858
1883
|
customLive: koishi_1.Schema.string(),
|
|
1859
1884
|
customLiveEnd: koishi_1.Schema.string().required(),
|
|
1860
1885
|
dynamicUrl: koishi_1.Schema.boolean().required(),
|
|
1886
|
+
dynamicVideoUrlToBV: koishi_1.Schema.boolean().required(),
|
|
1861
1887
|
filter: koishi_1.Schema.object({
|
|
1862
1888
|
enable: koishi_1.Schema.boolean(),
|
|
1863
1889
|
notify: koishi_1.Schema.boolean(),
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
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
|
+
export declare const usage = "\n\tBilibili-Notify\n\t\u5982\u9047\u5230\u4F7F\u7528\u95EE\u9898\u6216bug\uFF0C\u8BF7\u52A0\u7FA4\u54A8\u8BE2 801338523\n";
|
|
4
5
|
declare module "koishi" {
|
|
5
6
|
interface Context {
|
|
6
7
|
sm: ServerManager;
|
|
@@ -42,6 +43,7 @@ export interface Config {
|
|
|
42
43
|
}>;
|
|
43
44
|
dynamic: {};
|
|
44
45
|
dynamicUrl: boolean;
|
|
46
|
+
dynamicVideoUrlToBV: boolean;
|
|
45
47
|
pushImgsInDynamic: boolean;
|
|
46
48
|
live: {};
|
|
47
49
|
liveDetectType: "WS" | "API";
|
package/lib/index.js
CHANGED
|
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.Config = exports.name = exports.inject = void 0;
|
|
39
|
+
exports.Config = exports.usage = exports.name = exports.inject = void 0;
|
|
40
40
|
exports.apply = apply;
|
|
41
41
|
const koishi_1 = require("koishi");
|
|
42
42
|
// import plugins
|
|
@@ -48,6 +48,10 @@ const biliAPI_1 = __importDefault(require("./biliAPI"));
|
|
|
48
48
|
const blive_1 = __importDefault(require("./blive"));
|
|
49
49
|
exports.inject = ["puppeteer", "database", "notifier"];
|
|
50
50
|
exports.name = "bilibili-notify";
|
|
51
|
+
exports.usage = `
|
|
52
|
+
Bilibili-Notify
|
|
53
|
+
如遇到使用问题或bug,请加群咨询 801338523
|
|
54
|
+
`;
|
|
51
55
|
let globalConfig;
|
|
52
56
|
class ServerManager extends koishi_1.Service {
|
|
53
57
|
// 服务
|
|
@@ -134,6 +138,7 @@ class ServerManager extends koishi_1.Service {
|
|
|
134
138
|
customLive: globalConfig.customLive,
|
|
135
139
|
customLiveEnd: globalConfig.customLiveEnd,
|
|
136
140
|
dynamicUrl: globalConfig.dynamicUrl,
|
|
141
|
+
dynamicVideoUrlToBV: globalConfig.dynamicVideoUrlToBV,
|
|
137
142
|
filter: globalConfig.filter,
|
|
138
143
|
dynamicDebugMode: globalConfig.dynamicDebugMode,
|
|
139
144
|
});
|
|
@@ -192,11 +197,6 @@ class ServerManager extends koishi_1.Service {
|
|
|
192
197
|
function apply(ctx, config) {
|
|
193
198
|
// 设置config
|
|
194
199
|
globalConfig = config;
|
|
195
|
-
// 设置提示
|
|
196
|
-
ctx.notifier.create({
|
|
197
|
-
type: "warning",
|
|
198
|
-
content: "请使用Auth插件创建超级管理员账号,没有权限将无法使用该插件提供的指令",
|
|
199
|
-
});
|
|
200
200
|
// load database
|
|
201
201
|
ctx.plugin(Database);
|
|
202
202
|
// Register ServerManager
|
|
@@ -314,6 +314,9 @@ exports.Config = koishi_1.Schema.object({
|
|
|
314
314
|
dynamicUrl: koishi_1.Schema.boolean()
|
|
315
315
|
.default(false)
|
|
316
316
|
.description("发送动态时是否同时发送链接。注意:如果使用的是QQ官方机器人不能开启此项!"),
|
|
317
|
+
dynamicVideoUrlToBV: koishi_1.Schema.boolean()
|
|
318
|
+
.default(false)
|
|
319
|
+
.description("如果推送的动态是视频动态,且开启了发送链接选项,开启此选项则会将链接转换为BV号以便其他用途"),
|
|
317
320
|
pushImgsInDynamic: koishi_1.Schema.boolean()
|
|
318
321
|
.default(false)
|
|
319
322
|
.description("是否推送动态中的图片,默认不开启。开启后会单独推送动态中的图片,该功能容易导致QQ风控"),
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -255,8 +255,8 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
|
|
|
255
255
|
- ver 3.2.0-alpha.4 修复:直播卡片推送时间会是设置的 `pushTime` 的两倍;
|
|
256
256
|
- ver 3.2.0-alpha.5 修复:直播检测 `WS` 模式下,直播中推送卡片 `累计观看人数` 位置错误显示为 `粉丝数变化` 、转发动态的留言文字不显示; 优化:直播检测 `API` 模式下,直播推送语 `-watched` 固定显示为 `API模式无法获取`;
|
|
257
257
|
- ver 3.2.0-alpha.6 优化:调整配置项;
|
|
258
|
-
- ver 3.2.0-alpha.7 修复:自 `3.1.7` 版本 `
|
|
259
|
-
- ver 3.2.1-alpha.0 新增:多个相同平台bot可以选择某个群聊/频道指定机器人发送; 优化:直播检测 `WS` 模式下播后仍推送、添加依赖 `cacheable-lookup` 优化网络; 修复:打开 `
|
|
258
|
+
- ver 3.2.0-alpha.7 修复:自 `3.1.7` 版本 `pushImgsInDynamic` 功能失效;
|
|
259
|
+
- ver 3.2.1-alpha.0 新增:多个相同平台bot可以选择某个群聊/频道指定机器人发送; 优化:直播检测 `WS` 模式下播后仍推送、添加依赖 `cacheable-lookup` 优化网络; 修复:打开 `pushImgsInDynamic` 功能时,如果发送的动态里没有图片则会报错 `TypeError: Cannot read properties of null (reading 'opus')`
|
|
260
260
|
- ver 3.2.1-alpha.1 调整:将项目构建产物调整为 `esm`;
|
|
261
261
|
- ver 3.2.1-alpha.2 调整:将项目构建产物调整回 `cjs` 、将依赖 `cacheable-lookup` 导入方式更改为动态导入;
|
|
262
262
|
- ver 3.2.1-alpha.3 修复:直播检测 `WS` 初始化后自动断开连接;
|
|
@@ -268,6 +268,8 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
|
|
|
268
268
|
- ver 3.2.1 优化:移除不必要成员变量、创建自动上传npm `github actions`,添加相关开发依赖;
|
|
269
269
|
- ver 3.2.2 调整:修改 `github actions`;
|
|
270
270
|
- ver 3.2.3 优化:移除不必要的代码;
|
|
271
|
+
- ver 3.2.4-alpha.0 优化:选项 `pushImgsInDynamic` 发送多图会以转发消息的格式发送; 新增:选项 `dynamicVideoUrlToBV` 开启后将链接转换为bv号以用作特殊用途;
|
|
272
|
+
- ver 3.2.4 修复:第一次使用插件时,使用登录指令报错; 插件配置页新增和删除提示信息;
|
|
271
273
|
|
|
272
274
|
## 交流群
|
|
273
275
|
|