koishi-plugin-bilibili-notify 3.0.0-alpha.2 → 3.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.
@@ -0,0 +1,37 @@
1
+ export declare enum LiveType {
2
+ NotLiveBroadcast = 0,
3
+ StartBroadcasting = 1,
4
+ LiveBroadcast = 2,
5
+ StopBroadcast = 3,
6
+ FirstLiveBroadcast = 4
7
+ }
8
+ export type ChannelIdArr = Array<{
9
+ channelId: string;
10
+ dynamic: boolean;
11
+ live: boolean;
12
+ liveGuardBuy: boolean;
13
+ atAll: boolean;
14
+ }>;
15
+ export type TargetItem = {
16
+ channelIdArr: ChannelIdArr;
17
+ platform: string;
18
+ };
19
+ export type Target = Array<TargetItem>;
20
+ export type SubItem = {
21
+ id: number;
22
+ uid: string;
23
+ roomId: string;
24
+ target: Target;
25
+ platform: string;
26
+ live: boolean;
27
+ dynamic: boolean;
28
+ };
29
+ export type SubManager = Array<SubItem>;
30
+ export type MasterInfo = {
31
+ username: string;
32
+ userface: string;
33
+ roomId: number;
34
+ liveOpenFollowerNum: number;
35
+ liveEndFollowerNum: number;
36
+ liveFollowerChange: number;
37
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LiveType = void 0;
4
+ var LiveType;
5
+ (function (LiveType) {
6
+ LiveType[LiveType["NotLiveBroadcast"] = 0] = "NotLiveBroadcast";
7
+ LiveType[LiveType["StartBroadcasting"] = 1] = "StartBroadcasting";
8
+ LiveType[LiveType["LiveBroadcast"] = 2] = "LiveBroadcast";
9
+ LiveType[LiveType["StopBroadcast"] = 3] = "StopBroadcast";
10
+ LiveType[LiveType["FirstLiveBroadcast"] = 4] = "FirstLiveBroadcast";
11
+ })(LiveType || (exports.LiveType = LiveType = {}));
@@ -0,0 +1,6 @@
1
+ interface RetryOptions {
2
+ attempts: number;
3
+ onFailure?: (error: Error, attempts: number) => Promise<void> | void;
4
+ }
5
+ declare function Retry(options?: RetryOptions): MethodDecorator;
6
+ export default Retry;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function Retry(options = { attempts: 3 }) {
4
+ return function (target, propertyKey, descriptor) {
5
+ const originalMethod = descriptor.value;
6
+ descriptor.value = async function (...args) {
7
+ let lastError;
8
+ for (let i = 0; i < options.attempts; i++) {
9
+ try {
10
+ return await originalMethod.apply(this, args);
11
+ }
12
+ catch (error) {
13
+ lastError = error;
14
+ if (options.onFailure) {
15
+ await options.onFailure.call(this, lastError, i + 1);
16
+ }
17
+ }
18
+ }
19
+ throw lastError;
20
+ };
21
+ return descriptor;
22
+ };
23
+ }
24
+ exports.default = Retry;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 高阶函数:为函数添加锁机制
3
+ * @param {Function} fn - 需要包装的原始函数
4
+ * @returns {Function} 带锁功能的函数
5
+ */
6
+ declare function withLock(fn: any): (...args: any[]) => void;
7
+ export default withLock;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * 高阶函数:为函数添加锁机制
5
+ * @param {Function} fn - 需要包装的原始函数
6
+ * @returns {Function} 带锁功能的函数
7
+ */
8
+ function withLock(fn) {
9
+ // 判断是否是异步函数
10
+ const isAsync = fn.constructor.name === 'AsyncFunction';
11
+ // 定义锁标志
12
+ let locked = false;
13
+ // 判断是否为异步函数
14
+ if (isAsync) {
15
+ // 变为Promise
16
+ return function (...args) {
17
+ // 已加锁则跳过执行
18
+ if (locked)
19
+ return;
20
+ // 获取锁
21
+ locked = true;
22
+ // 将异步函数转为Promise链
23
+ Promise.resolve(fn(...args))
24
+ .catch(err => {
25
+ // 打印错误
26
+ console.error("Execution error:", err);
27
+ // 重新抛出错误
28
+ throw err;
29
+ })
30
+ .finally(() => {
31
+ // 确保释放锁
32
+ locked = false;
33
+ });
34
+ };
35
+ }
36
+ // 不是异步函数
37
+ return function (...args) {
38
+ // 已加锁则跳过执行
39
+ if (locked)
40
+ return;
41
+ // 获取锁
42
+ locked = true;
43
+ try {
44
+ // 执行函数
45
+ fn(...args);
46
+ }
47
+ catch (err) {
48
+ // 打印错误
49
+ console.error("Execution error:", err);
50
+ // 重新抛出错误
51
+ throw err;
52
+ }
53
+ finally {
54
+ // 无论成功失败都释放锁
55
+ locked = false;
56
+ }
57
+ };
58
+ }
59
+ exports.default = withLock;
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": "3.0.0-alpha.2",
4
+ "version": "3.0.0-alpha.20",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
@@ -34,18 +34,17 @@
34
34
  "luxon": "^3.5.0",
35
35
  "md5": "^2.3.0",
36
36
  "qrcode": "^1.5.4",
37
+ "segmentit": "^2.0.3",
37
38
  "tough-cookie": "^4.1.4"
38
39
  },
39
40
  "devDependencies": {
40
- "@eslint/js": "^9.20.0",
41
+ "@biomejs/biome": "1.9.4",
41
42
  "@types/luxon": "^3.4.2",
42
43
  "@types/md5": "^2.3.5",
43
44
  "@types/qrcode": "^1.5.5",
44
45
  "@types/tough-cookie": "^4.0.5",
45
- "eslint": "^9.20.0",
46
46
  "globals": "^15.14.0",
47
- "koishi-plugin-puppeteer": "^3.9.0",
48
- "typescript-eslint": "^7.18.1-alpha.3"
47
+ "koishi-plugin-puppeteer": "^3.9.0"
49
48
  },
50
49
  "koishi": {
51
50
  "service": {
package/readme.md CHANGED
@@ -53,43 +53,11 @@
53
53
 
54
54
  订阅UP主:订阅你想要推送的UP主
55
55
 
56
- - 使用指令 `bili sub <uid> [...groupId]` 订阅需要订阅的UP主
57
- - 参数说明:
58
- - `uid` 为必填参数,为 `up主` 的 `uid`
59
- - `groupId` 为可选参数,为需要推送的群号/频道号,可输入多个群号
60
- - 选项说明:`bili sub <uid>` 有四个选项:-l -d -m -a
61
- - `-l` 为订阅UP主直播间,包括直播开播通知,定时推送直播内容,下播通知
62
- - `-d` 为订阅UP主动态推送,目前实现推送的动态类型有:普通图文动态,转发动态,直播预约动态
63
- - `-m` 为多平台动态推送,格式为:群号/频道号,群号/频道号,群号/频道号.平台名;群号/频道号,群号/频道号.平台号。如果群号/频道号为 `all` 代表推送该平台下的所有群聊或/频道。在群号/频道号后加 `@` 则代表这个群聊/频道需要@全体成员。订阅TG群组时请使用 `bili sub xxx -m "xxxxxxx"` 这样的格式
64
- - `-a` 为是否艾特全体成员,对 `-m` 参数不生效
65
-
66
- 例如:
67
- `-m 3247293,324389,89874324.qq;EDBWIUBIU.qqguild;79324792,3247892.onebot` 代表推送QQ下3247293,324389,89874324这三个群聊,QQ频道下EDBWIUBIU这个频道,Onebot平台下79324792,3247892这两个群聊
68
- `-m 3247293,324389@,89874324.qq` 代表推送QQ下3247293,324389,89874324这三个群聊,其中群聊324389需要艾特全体成员
69
- 所有分隔符均为英文符号
70
-
71
- - 例如:
72
- - `bili sub 1194210119 ` 订阅UID为1194210119的UP主动态推送和直播间
73
- - `bili sub 1194210119 -d` 订阅UID为1194210119的UP主动态推送
74
- - `bili sub 1194210119 -l` 订阅UID为1194210119的UP主直播间
75
- - `bili sub 1194210119 -m 3247293,324389,89874324.qq;all.onebot;EHUIWDBUAWD.qqguild` 订阅UID为1194210119的UP主,向群号为3247293,324389,89874324的QQ群,所有onebot平台下的群聊,频道号为EHUIWDBUAWD的QQ频道平台进行推送
76
- - `bili sub 1194210119 -a` 订阅UID为1194210119的UP主动态推送和直播间并艾特全体成员
77
-
78
- 取消订阅UP主:取消订阅不需要推送的UP主
79
-
80
- - 使用指令 `bili unsub <uid>` 取消订阅不需要订阅的UP主
81
- - 参数说明:`uid` 为必填参数,为 `up主` 的 `uid`
82
- - 选项说明:`bili unsub <uid>` 有两个选项:-l 和 -d
83
- - `-l` 为取消订阅UP主直播间
84
- - `-d` 为取消订阅UP主动态
85
- - 例如:
86
- - `bili unsub 123456` 取消订阅UID为123456的UP主动态推送和直播间
87
- - `bili unsub 123456 -d` 取消订阅UID为123456的UP主动态推送
88
- - `bili unsub 123456 -dl` 取消订阅UID为123456的UP主动态推送和直播间
56
+ 在插件配置中配置需要订阅的UP主
89
57
 
90
58
  查看目前已订阅的UP主:
91
59
 
92
- - 使用指令 `bili show`
60
+ - 使用指令 `bili list`
93
61
 
94
62
  插件的启动、停止和重启
95
63
 
@@ -214,6 +182,24 @@
214
182
  - ver 3.0.0-alpha.0 重构:直播 新增:直播弹幕推送到群
215
183
  - ver 3.0.0-alpha.1 测试版本
216
184
  - ver 3.0.0-alpha.2 修复:只订阅直播也会将该UP主的动态进行推送、推送过的动态过一段时间又会再次推送
185
+ - ver 3.0.0-alpha.3 修复:未开启弹幕推送也不会推送直播通知卡片
186
+ - ver 3.0.0-alpha.4 修复:使用了手动订阅,数据库中的订阅不会加载
187
+ - ver 3.0.0-alpha.5 修复:订阅的直播开播后,未开启弹幕推送会一直报错、主播开播推送下播卡片,直播时长显示NaN; 新增:直播检测模式选项; 优化:下播卡片内容
188
+ - ver 3.0.0-alpha.6 修复:连续发送两次直播中通知卡片; 优化:下播通知卡片
189
+ - ver 3.0.0-alpha.7 修复:`ver 3.0.0-alpha.5` 未能解决的bug; 优化:ba代码结构
190
+ - ver 3.0.0-alpha.8 修复:开播通知连续发送两次,登录后不会加载手动订阅中的订阅; 优化:网络请求报错
191
+ - ver 3.0.0-alpha.9 优化:加强直播推送对获取直播信息的错误处理
192
+ - ver 3.0.0-alpha.10 修复:连续推送两次开播通知
193
+ - ver 3.0.0-alpha.11 新增:直播结束后推送弹幕词云,直播推送上舰消息; 修复:直播推送都是同一张画面; 移除:直播推送弹幕消息
194
+ - ver 3.0.0-alpha.12 修复:上一版本无法安装
195
+ - ver 3.0.0-alpha.13 优化:将ESLint替换为Biome; 修复:增加弹幕词云功能产生的bug; 禁用:弹幕词云功能并不能正常运作,暂时将该功能禁用
196
+ - ver 3.0.0-alpha.14 优化:移除不需要的服务
197
+ - ver 3.0.0-alpha.15 修复:启动插件提示发送群组消息失败、直播推送时间显示为负数(不用再特别设置系统时区为UTC+8)
198
+ - ver 3.0.0-alpha.16 重大更新:订阅不再依赖数据库,从指令订阅全面迁移到配置订阅; 修复:直播时长有误; 优化:`bili show` 指令更改为 `bili list`
199
+ - ver 3.0.0-alpha.17 新增:更多的提示语变量,开播,当前粉丝数。正在直播,累计观看人数。下播,粉丝数变化。选项,新增的提示语变量是否展示到推送卡片中
200
+ - ver 3.0.0-alpha.18 移除:直播检测API模式已被废弃; 优化:更多提示语数据显示优化
201
+ - ver 3.0.0-alpha.19 修复:开播提示语粉丝数单位错误; 优化:订阅配置中所有配置项改为必填项
202
+ - ver 3.0.0-alpha.20 优化:订阅配置中开关选项默认为关闭
217
203
 
218
204
  ## 交流群
219
205
 
@@ -221,7 +207,9 @@
221
207
 
222
208
  ## 感谢
223
209
 
224
- 感谢 [koishijs](https://github.com/koishijs/koishi) 官方提供的插件开发框架, 以及技术指导
210
+ [koishijs](https://github.com/koishijs/koishi) 感谢官方提供的插件开发框架, 以及技术指导
211
+ [blive-message-listener](https://github.com/ddiu8081/blive-message-listener) 感谢 `ddiu8081` 提供简单方便的B站直播监听依赖
212
+ [bilibili-API-collect](https://github.com/SocialSisterYi/bilibili-API-collect) 感谢 `SocialSisterYi` 提供B站API参考
225
213
 
226
214
  ## License
227
215