koishi-plugin-bilibili-notify 2.0.0-alpha.2 → 2.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 +2 -0
- package/lib/biliAPI.js +23 -0
- package/lib/blive.d.ts +9 -0
- package/lib/blive.js +21 -0
- package/lib/comRegister.d.ts +49 -12
- package/lib/comRegister.js +559 -406
- package/lib/database.d.ts +1 -2
- package/lib/database.js +1 -2
- package/lib/generateImg.js +1 -1
- package/lib/index.d.ts +16 -2
- package/lib/index.js +26 -11
- package/package.json +1 -1
- package/{README.md → readme.md} +38 -11
package/lib/biliAPI.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ declare class BiliAPI extends Service {
|
|
|
26
26
|
}): Promise<string>;
|
|
27
27
|
encrypt(text: string): string;
|
|
28
28
|
decrypt(text: string): string;
|
|
29
|
+
getLiveRoomInfoStreamKey(roomId: string): Promise<any>;
|
|
29
30
|
getServerUTCTime(): Promise<number>;
|
|
30
31
|
getTimeNow(): Promise<any>;
|
|
31
32
|
getAllGroup(): Promise<any>;
|
|
@@ -36,6 +37,7 @@ declare class BiliAPI extends Service {
|
|
|
36
37
|
getAllDynamic(updateBaseline?: string): Promise<any>;
|
|
37
38
|
hasNewDynamic(updateBaseline: string): Promise<any>;
|
|
38
39
|
follow(fid: string): Promise<any>;
|
|
40
|
+
getRelationGroupDetail(tagid: string): Promise<any>;
|
|
39
41
|
getCookieInfo(refreshToken: string): Promise<any>;
|
|
40
42
|
getUserInfo(mid: string): Promise<any>;
|
|
41
43
|
getWbiKeys(): Promise<{
|
package/lib/biliAPI.js
CHANGED
|
@@ -40,6 +40,9 @@ const CREATE_GROUP = 'https://api.bilibili.com/x/relation/tag/create';
|
|
|
40
40
|
const MODIFY_GROUP_MEMBER = 'https://api.bilibili.com/x/relation/tags/addUsers';
|
|
41
41
|
const GET_ALL_GROUP = 'https://api.bilibili.com/x/relation/tags';
|
|
42
42
|
const COPY_USER_TO_GROUP = 'https://api.bilibili.com/x/relation/tags/copyUsers';
|
|
43
|
+
const GET_RELATION_GROUP_DETAIL = 'https://api.bilibili.com/x/relation/tag';
|
|
44
|
+
// 直播
|
|
45
|
+
const GET_LIVE_ROOM_INFO_STREAM_KEY = 'https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuInfo';
|
|
43
46
|
class BiliAPI extends koishi_1.Service {
|
|
44
47
|
static inject = ['database', 'notifier'];
|
|
45
48
|
jar;
|
|
@@ -102,6 +105,17 @@ class BiliAPI extends koishi_1.Service {
|
|
|
102
105
|
return decrypted.toString();
|
|
103
106
|
}
|
|
104
107
|
// BA API
|
|
108
|
+
async getLiveRoomInfoStreamKey(roomId) {
|
|
109
|
+
try {
|
|
110
|
+
// 获取直播间信息流密钥
|
|
111
|
+
const { data } = await this.client.get(`${GET_LIVE_ROOM_INFO_STREAM_KEY}?id=${roomId}`);
|
|
112
|
+
// 返回data
|
|
113
|
+
return data;
|
|
114
|
+
}
|
|
115
|
+
catch (e) {
|
|
116
|
+
throw new Error('网络异常,本次请求失败!');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
105
119
|
async getServerUTCTime() {
|
|
106
120
|
try {
|
|
107
121
|
const { data } = await this.client.get(GET_SERVER_UTC_TIME);
|
|
@@ -240,6 +254,15 @@ class BiliAPI extends koishi_1.Service {
|
|
|
240
254
|
throw new Error('网络异常,本次请求失败!');
|
|
241
255
|
}
|
|
242
256
|
}
|
|
257
|
+
async getRelationGroupDetail(tagid) {
|
|
258
|
+
try {
|
|
259
|
+
const { data } = await this.client.get(`${GET_RELATION_GROUP_DETAIL}?tagid=${tagid}`);
|
|
260
|
+
return data;
|
|
261
|
+
}
|
|
262
|
+
catch (e) {
|
|
263
|
+
throw new Error('网络异常,本次请求失败!');
|
|
264
|
+
}
|
|
265
|
+
}
|
|
243
266
|
// Check if Token need refresh
|
|
244
267
|
async getCookieInfo(refreshToken) {
|
|
245
268
|
try {
|
package/lib/blive.d.ts
ADDED
package/lib/blive.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class BLive {
|
|
4
|
+
// 必须服务
|
|
5
|
+
static inject = [''];
|
|
6
|
+
// 定义类属性
|
|
7
|
+
ctx;
|
|
8
|
+
logger;
|
|
9
|
+
// 构造函数
|
|
10
|
+
constructor(ctx) {
|
|
11
|
+
// 将Context赋值给类属性
|
|
12
|
+
this.ctx = ctx;
|
|
13
|
+
// 将logger赋值给类属性
|
|
14
|
+
this.logger = ctx.logger('bl');
|
|
15
|
+
}
|
|
16
|
+
// 定义方法
|
|
17
|
+
connectToLiveBroadcastRoom(roomId) {
|
|
18
|
+
console.log(roomId);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.default = BLive;
|
package/lib/comRegister.d.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
import { Bot, Context, Logger, Schema, Session } from "koishi";
|
|
1
|
+
import { Bot, Context, FlatPick, Logger, Schema, Session } from "koishi";
|
|
2
2
|
import { Notifier } from "@koishijs/plugin-notifier";
|
|
3
|
+
import { LoginBili } from "./database";
|
|
4
|
+
type ChannelIdArr = Array<{
|
|
5
|
+
channelId: string;
|
|
6
|
+
dynamic: boolean;
|
|
7
|
+
live: boolean;
|
|
8
|
+
atAll: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
type TargetItem = {
|
|
11
|
+
channelIdArr: ChannelIdArr;
|
|
12
|
+
platform: string;
|
|
13
|
+
};
|
|
14
|
+
type Target = Array<TargetItem>;
|
|
3
15
|
type SubItem = {
|
|
4
16
|
id: number;
|
|
5
17
|
uid: string;
|
|
6
18
|
roomId: string;
|
|
7
|
-
|
|
19
|
+
target: Target;
|
|
8
20
|
platform: string;
|
|
9
21
|
live: boolean;
|
|
10
22
|
dynamic: boolean;
|
|
@@ -13,6 +25,7 @@ type SubItem = {
|
|
|
13
25
|
type SubManager = Array<SubItem>;
|
|
14
26
|
declare class ComRegister {
|
|
15
27
|
static inject: string[];
|
|
28
|
+
qqRelatedBotList: Array<string>;
|
|
16
29
|
logger: Logger;
|
|
17
30
|
config: ComRegister.Config;
|
|
18
31
|
loginTimer: Function;
|
|
@@ -20,44 +33,68 @@ declare class ComRegister {
|
|
|
20
33
|
rebootCount: number;
|
|
21
34
|
subNotifier: Notifier;
|
|
22
35
|
subManager: SubManager;
|
|
23
|
-
|
|
36
|
+
loginDBData: FlatPick<LoginBili, "dynamic_group_id">;
|
|
37
|
+
privateBot: Bot<Context>;
|
|
24
38
|
dynamicDispose: Function;
|
|
25
|
-
sendMsgFunc: (
|
|
39
|
+
sendMsgFunc: (bot: Bot<Context, any>, channelId: string, content: any) => Promise<void>;
|
|
26
40
|
constructor(ctx: Context, config: ComRegister.Config);
|
|
41
|
+
init(ctx: Context, config: ComRegister.Config): Promise<void>;
|
|
42
|
+
splitMultiPlatformStr(str: string): Target;
|
|
43
|
+
getBot(ctx: Context, pf: string): Bot<Context, any>;
|
|
27
44
|
sendPrivateMsg(content: string): Promise<void>;
|
|
28
45
|
sendPrivateMsgAndRebootService(ctx: Context): Promise<void>;
|
|
29
46
|
sendPrivateMsgAndStopService(ctx: Context): Promise<void>;
|
|
30
|
-
sendMsg(targets:
|
|
47
|
+
sendMsg(ctx: Context, targets: Target, content: any, live?: boolean): Promise<void>;
|
|
31
48
|
dynamicDetect(ctx: Context): () => Promise<void>;
|
|
32
49
|
debug_dynamicDetect(ctx: Context): () => Promise<void>;
|
|
33
|
-
liveDetect(ctx: Context, roomId: string,
|
|
50
|
+
liveDetect(ctx: Context, roomId: string, target: Target): () => Promise<void>;
|
|
34
51
|
subShow(): string;
|
|
35
|
-
checkIfNeedSub(liveSub: boolean, dynamicSub: boolean, session: Session,
|
|
52
|
+
checkIfNeedSub(liveSub: boolean, dynamicSub: boolean, session: Session, liveRoomData: any): Promise<Array<boolean>>;
|
|
36
53
|
updateSubNotifier(ctx: Context): void;
|
|
37
54
|
checkIfLoginInfoIsLoaded(ctx: Context): Promise<unknown>;
|
|
38
|
-
|
|
55
|
+
subUserInBili(ctx: Context, mid: string): Promise<{
|
|
56
|
+
flag: boolean;
|
|
57
|
+
msg: string;
|
|
58
|
+
}>;
|
|
59
|
+
loadSubFromConfig(ctx: Context, subs: ComRegister.Config["sub"]): Promise<void>;
|
|
60
|
+
loadSubFromDatabase(ctx: Context): Promise<void>;
|
|
61
|
+
checkIfDynamicDetectIsNeeded(ctx: Context): void;
|
|
62
|
+
enableDynamicDetect(ctx: Context): void;
|
|
39
63
|
unsubSingle(ctx: Context, id: string, type: number): string;
|
|
40
|
-
|
|
64
|
+
checkIfUserIsTheLastOneWhoSubDyn(): void;
|
|
41
65
|
unsubAll(ctx: Context, uid: string): void;
|
|
42
66
|
checkIfIsLogin(ctx: Context): Promise<boolean>;
|
|
43
67
|
}
|
|
44
68
|
declare namespace ComRegister {
|
|
45
69
|
interface Config {
|
|
46
|
-
|
|
70
|
+
sub: Array<{
|
|
71
|
+
uid: string;
|
|
72
|
+
dynamic: boolean;
|
|
73
|
+
live: boolean;
|
|
74
|
+
target: Array<{
|
|
75
|
+
channelIdArr: Array<{
|
|
76
|
+
channelId: string;
|
|
77
|
+
dynamic: boolean;
|
|
78
|
+
live: boolean;
|
|
79
|
+
atAll: boolean;
|
|
80
|
+
}>;
|
|
81
|
+
platform: string;
|
|
82
|
+
}>;
|
|
83
|
+
}>;
|
|
47
84
|
master: {
|
|
48
85
|
enable: boolean;
|
|
86
|
+
platform: string;
|
|
49
87
|
masterAccount: string;
|
|
50
88
|
masterAccountGuildId: string;
|
|
51
89
|
};
|
|
52
90
|
unlockSubLimits: boolean;
|
|
53
91
|
automaticResend: boolean;
|
|
54
92
|
changeMasterInfoApi: boolean;
|
|
55
|
-
liveStartAtAll: boolean;
|
|
56
93
|
restartPush: boolean;
|
|
57
|
-
pushUrl: boolean;
|
|
58
94
|
pushTime: number;
|
|
59
95
|
liveLoopTime: number;
|
|
60
96
|
customLiveStart: string;
|
|
97
|
+
customLive: string;
|
|
61
98
|
customLiveEnd: string;
|
|
62
99
|
dynamicUrl: boolean;
|
|
63
100
|
dynamicLoopTime: number;
|