@bilibili-notify/live 0.0.1-alpha.0 → 0.0.1-alpha.1
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/index.cjs +7 -13
- package/lib/index.d.cts +18 -28
- package/lib/index.d.mts +18 -28
- package/lib/index.mjs +7 -13
- package/package.json +4 -4
package/lib/index.cjs
CHANGED
|
@@ -725,7 +725,7 @@ var RoomSessionBase = class {
|
|
|
725
725
|
watched,
|
|
726
726
|
roomLink
|
|
727
727
|
});
|
|
728
|
-
if (this.sub.restartPush
|
|
728
|
+
if (this.sub.restartPush) await this.ctx.sendLiveNotifyCard({
|
|
729
729
|
liveType: 2,
|
|
730
730
|
liveData: this.liveData,
|
|
731
731
|
liveRoomInfo: this.liveRoomInfo,
|
|
@@ -771,9 +771,9 @@ var RoomSessionBase = class {
|
|
|
771
771
|
this.armPeriodicTimer();
|
|
772
772
|
}
|
|
773
773
|
armPeriodicTimer() {
|
|
774
|
-
const
|
|
775
|
-
if (
|
|
776
|
-
this.pushAtTimeTimer = this.ctx.serviceCtx.setInterval(() => this.tickPushAtTime(),
|
|
774
|
+
const pushTime = this.sub.pushTime;
|
|
775
|
+
if (pushTime === 0 || this.pushAtTimeTimer) return;
|
|
776
|
+
this.pushAtTimeTimer = this.ctx.serviceCtx.setInterval(() => this.tickPushAtTime(), pushTime * 1e3 * 60 * 60);
|
|
777
777
|
this.ctx.livePushTimerManager.set(this.sub.roomId, () => this.pushAtTimeTimer?.dispose());
|
|
778
778
|
this.ctx.logSideEffectState(`timer:created room=${this.sub.roomId}`);
|
|
779
779
|
}
|
|
@@ -1060,8 +1060,7 @@ var RoomSession = class extends RoomSessionBase {
|
|
|
1060
1060
|
if (!collectsDanmaku && !pushesSC) return;
|
|
1061
1061
|
if (collectsDanmaku) this.ctx.danmakuCollector.recordDanmaku(this.sub.roomId, body.content, body.user.uname);
|
|
1062
1062
|
if (!pushesSC) return;
|
|
1063
|
-
|
|
1064
|
-
if (body.price < effMinScPrice) return;
|
|
1063
|
+
if (body.price < this.sub.minScPrice) return;
|
|
1065
1064
|
const data = await this.ctx.api.getUserInfoInLive(body.user.uid.toString(), this.sub.uid);
|
|
1066
1065
|
if (data.code !== 0) {
|
|
1067
1066
|
const text = `【${this.masterInfo?.username ?? ""}的直播间】${body.user.uname}的SC:${body.content}(${body.price}元)`;
|
|
@@ -1091,8 +1090,7 @@ var RoomSession = class extends RoomSessionBase {
|
|
|
1091
1090
|
}
|
|
1092
1091
|
async onGuardBuy(body) {
|
|
1093
1092
|
if (!this.ctx.isSubscribed(this.sub, "liveGuardBuy")) return;
|
|
1094
|
-
|
|
1095
|
-
if (body.guard_level > effMinGuardLevel) return;
|
|
1093
|
+
if (body.guard_level > this.sub.minGuardLevel) return;
|
|
1096
1094
|
const guardImg = GUARD_LEVEL_IMG[body.guard_level];
|
|
1097
1095
|
const effectiveGuardBuy = this.sub.customGuardBuy.enable ? this.sub.customGuardBuy : this.ctx.config.customGuardBuy;
|
|
1098
1096
|
if (effectiveGuardBuy.enable) {
|
|
@@ -1714,7 +1712,7 @@ var LiveEngine = class {
|
|
|
1714
1712
|
let nextPushTime = prevPushTime;
|
|
1715
1713
|
for (const change of liveChanges) {
|
|
1716
1714
|
const { scope: _scope, ...fields } = change;
|
|
1717
|
-
if (
|
|
1715
|
+
if (fields.pushTime !== void 0) nextPushTime = fields.pushTime;
|
|
1718
1716
|
Object.assign(existing, fields);
|
|
1719
1717
|
}
|
|
1720
1718
|
for (const change of targetChanges) existing.target = change.target;
|
|
@@ -1768,10 +1766,6 @@ var LiveEngine = class {
|
|
|
1768
1766
|
};
|
|
1769
1767
|
function toListenerConfig(c) {
|
|
1770
1768
|
return {
|
|
1771
|
-
pushTime: c.pushTime,
|
|
1772
|
-
restartPush: c.restartPush,
|
|
1773
|
-
minScPrice: c.minScPrice,
|
|
1774
|
-
minGuardLevel: c.minGuardLevel,
|
|
1775
1769
|
customGuardBuy: c.customGuardBuy,
|
|
1776
1770
|
customLiveMsg: c.customLiveMsg,
|
|
1777
1771
|
liveSummaryDefault: c.liveSummaryDefault,
|
package/lib/index.d.cts
CHANGED
|
@@ -181,18 +181,16 @@ interface SubItemView {
|
|
|
181
181
|
customSpecialDanmakuUsers: CustomSpecialDanmakuUsersLike;
|
|
182
182
|
customSpecialUsersEnterTheRoom: CustomSpecialUsersEnterTheRoomLike;
|
|
183
183
|
/**
|
|
184
|
-
* Per-UP
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
pushTime?: number;
|
|
195
|
-
restartPush?: boolean;
|
|
184
|
+
* Per-UP 阈值 / 调度。adapter build SubItemView 时已一次性折算好
|
|
185
|
+
* (`sub.overrides.X ?? 全局 config.X`),引擎 / 监听层直接消费,无二次回退。
|
|
186
|
+
* 随 LiveScopedChange 增量推送给 LiveEngine.applyOps;pushTime 变更时
|
|
187
|
+
* engine 额外 rearm 定时器(setInterval 句柄 ms 不可变)。
|
|
188
|
+
*/
|
|
189
|
+
minScPrice: number;
|
|
190
|
+
minGuardLevel: 1 | 2 | 3;
|
|
191
|
+
pushTime: number;
|
|
192
|
+
restartPush: boolean;
|
|
193
|
+
/** undefined = 该 UP 无 per-UP AI 覆盖,直播总结走 AI 引擎自身配置。 */
|
|
196
194
|
aiOverride?: CommentaryCallOverride;
|
|
197
195
|
}
|
|
198
196
|
type SubscriptionsView = Record<string, SubItemView>;
|
|
@@ -461,15 +459,12 @@ declare class WordcloudGenerator {
|
|
|
461
459
|
//#endregion
|
|
462
460
|
//#region src/room-context.d.ts
|
|
463
461
|
/**
|
|
464
|
-
*
|
|
465
|
-
*
|
|
466
|
-
* `
|
|
462
|
+
* 模板 / 渲染层全局配置,listener-manager + room-session 共用。
|
|
463
|
+
*
|
|
464
|
+
* 不含 `pushTime` / `restartPush` / `minScPrice` / `minGuardLevel` —— 那些是
|
|
465
|
+
* per-UP 字段,adapter build SubItemView 时已折算好,引擎直接读 `SubItemView.X`。
|
|
467
466
|
*/
|
|
468
467
|
interface ListenerManagerConfig {
|
|
469
|
-
pushTime: number;
|
|
470
|
-
restartPush: boolean;
|
|
471
|
-
minScPrice: number;
|
|
472
|
-
minGuardLevel: 1 | 2 | 3;
|
|
473
468
|
customGuardBuy: {
|
|
474
469
|
enable: boolean;
|
|
475
470
|
guardBuyMsg?: string;
|
|
@@ -884,17 +879,12 @@ interface LiveEngineConfig {
|
|
|
884
879
|
* Chinese-stop-word list before tokenisation.
|
|
885
880
|
*/
|
|
886
881
|
wordcloudStopWords?: string;
|
|
887
|
-
/** Hours between periodic "正在直播" pushes; `0` disables. */
|
|
888
|
-
pushTime: number;
|
|
889
|
-
/** Whether to push a "正在直播" card immediately on engine start when a sub is live. */
|
|
890
|
-
restartPush: boolean;
|
|
891
|
-
/** SC minimum-price gate (yuan); SC under this value is dropped. */
|
|
892
|
-
minScPrice: number;
|
|
893
882
|
/**
|
|
894
|
-
*
|
|
895
|
-
*
|
|
883
|
+
* 引擎级全局 `pushTime`(小时;`0` 关闭)。仅用于 `updateConfig` 检测全局
|
|
884
|
+
* pushTime 变更后重排所有定时器;每个 UP 的实际复推间隔在
|
|
885
|
+
* `SubItemView.pushTime` 上(adapter 已折算 `per-UP ?? 全局`)。
|
|
896
886
|
*/
|
|
897
|
-
|
|
887
|
+
pushTime: number;
|
|
898
888
|
/** Default global "弹幕总结" template (single string; adapter joins lines if needed). */
|
|
899
889
|
liveSummaryDefault: string;
|
|
900
890
|
customGuardBuy: ListenerManagerConfig["customGuardBuy"];
|
package/lib/index.d.mts
CHANGED
|
@@ -181,18 +181,16 @@ interface SubItemView {
|
|
|
181
181
|
customSpecialDanmakuUsers: CustomSpecialDanmakuUsersLike;
|
|
182
182
|
customSpecialUsersEnterTheRoom: CustomSpecialUsersEnterTheRoomLike;
|
|
183
183
|
/**
|
|
184
|
-
* Per-UP
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
pushTime?: number;
|
|
195
|
-
restartPush?: boolean;
|
|
184
|
+
* Per-UP 阈值 / 调度。adapter build SubItemView 时已一次性折算好
|
|
185
|
+
* (`sub.overrides.X ?? 全局 config.X`),引擎 / 监听层直接消费,无二次回退。
|
|
186
|
+
* 随 LiveScopedChange 增量推送给 LiveEngine.applyOps;pushTime 变更时
|
|
187
|
+
* engine 额外 rearm 定时器(setInterval 句柄 ms 不可变)。
|
|
188
|
+
*/
|
|
189
|
+
minScPrice: number;
|
|
190
|
+
minGuardLevel: 1 | 2 | 3;
|
|
191
|
+
pushTime: number;
|
|
192
|
+
restartPush: boolean;
|
|
193
|
+
/** undefined = 该 UP 无 per-UP AI 覆盖,直播总结走 AI 引擎自身配置。 */
|
|
196
194
|
aiOverride?: CommentaryCallOverride;
|
|
197
195
|
}
|
|
198
196
|
type SubscriptionsView = Record<string, SubItemView>;
|
|
@@ -461,15 +459,12 @@ declare class WordcloudGenerator {
|
|
|
461
459
|
//#endregion
|
|
462
460
|
//#region src/room-context.d.ts
|
|
463
461
|
/**
|
|
464
|
-
*
|
|
465
|
-
*
|
|
466
|
-
* `
|
|
462
|
+
* 模板 / 渲染层全局配置,listener-manager + room-session 共用。
|
|
463
|
+
*
|
|
464
|
+
* 不含 `pushTime` / `restartPush` / `minScPrice` / `minGuardLevel` —— 那些是
|
|
465
|
+
* per-UP 字段,adapter build SubItemView 时已折算好,引擎直接读 `SubItemView.X`。
|
|
467
466
|
*/
|
|
468
467
|
interface ListenerManagerConfig {
|
|
469
|
-
pushTime: number;
|
|
470
|
-
restartPush: boolean;
|
|
471
|
-
minScPrice: number;
|
|
472
|
-
minGuardLevel: 1 | 2 | 3;
|
|
473
468
|
customGuardBuy: {
|
|
474
469
|
enable: boolean;
|
|
475
470
|
guardBuyMsg?: string;
|
|
@@ -884,17 +879,12 @@ interface LiveEngineConfig {
|
|
|
884
879
|
* Chinese-stop-word list before tokenisation.
|
|
885
880
|
*/
|
|
886
881
|
wordcloudStopWords?: string;
|
|
887
|
-
/** Hours between periodic "正在直播" pushes; `0` disables. */
|
|
888
|
-
pushTime: number;
|
|
889
|
-
/** Whether to push a "正在直播" card immediately on engine start when a sub is live. */
|
|
890
|
-
restartPush: boolean;
|
|
891
|
-
/** SC minimum-price gate (yuan); SC under this value is dropped. */
|
|
892
|
-
minScPrice: number;
|
|
893
882
|
/**
|
|
894
|
-
*
|
|
895
|
-
*
|
|
883
|
+
* 引擎级全局 `pushTime`(小时;`0` 关闭)。仅用于 `updateConfig` 检测全局
|
|
884
|
+
* pushTime 变更后重排所有定时器;每个 UP 的实际复推间隔在
|
|
885
|
+
* `SubItemView.pushTime` 上(adapter 已折算 `per-UP ?? 全局`)。
|
|
896
886
|
*/
|
|
897
|
-
|
|
887
|
+
pushTime: number;
|
|
898
888
|
/** Default global "弹幕总结" template (single string; adapter joins lines if needed). */
|
|
899
889
|
liveSummaryDefault: string;
|
|
900
890
|
customGuardBuy: ListenerManagerConfig["customGuardBuy"];
|
package/lib/index.mjs
CHANGED
|
@@ -701,7 +701,7 @@ var RoomSessionBase = class {
|
|
|
701
701
|
watched,
|
|
702
702
|
roomLink
|
|
703
703
|
});
|
|
704
|
-
if (this.sub.restartPush
|
|
704
|
+
if (this.sub.restartPush) await this.ctx.sendLiveNotifyCard({
|
|
705
705
|
liveType: 2,
|
|
706
706
|
liveData: this.liveData,
|
|
707
707
|
liveRoomInfo: this.liveRoomInfo,
|
|
@@ -747,9 +747,9 @@ var RoomSessionBase = class {
|
|
|
747
747
|
this.armPeriodicTimer();
|
|
748
748
|
}
|
|
749
749
|
armPeriodicTimer() {
|
|
750
|
-
const
|
|
751
|
-
if (
|
|
752
|
-
this.pushAtTimeTimer = this.ctx.serviceCtx.setInterval(() => this.tickPushAtTime(),
|
|
750
|
+
const pushTime = this.sub.pushTime;
|
|
751
|
+
if (pushTime === 0 || this.pushAtTimeTimer) return;
|
|
752
|
+
this.pushAtTimeTimer = this.ctx.serviceCtx.setInterval(() => this.tickPushAtTime(), pushTime * 1e3 * 60 * 60);
|
|
753
753
|
this.ctx.livePushTimerManager.set(this.sub.roomId, () => this.pushAtTimeTimer?.dispose());
|
|
754
754
|
this.ctx.logSideEffectState(`timer:created room=${this.sub.roomId}`);
|
|
755
755
|
}
|
|
@@ -1036,8 +1036,7 @@ var RoomSession = class extends RoomSessionBase {
|
|
|
1036
1036
|
if (!collectsDanmaku && !pushesSC) return;
|
|
1037
1037
|
if (collectsDanmaku) this.ctx.danmakuCollector.recordDanmaku(this.sub.roomId, body.content, body.user.uname);
|
|
1038
1038
|
if (!pushesSC) return;
|
|
1039
|
-
|
|
1040
|
-
if (body.price < effMinScPrice) return;
|
|
1039
|
+
if (body.price < this.sub.minScPrice) return;
|
|
1041
1040
|
const data = await this.ctx.api.getUserInfoInLive(body.user.uid.toString(), this.sub.uid);
|
|
1042
1041
|
if (data.code !== 0) {
|
|
1043
1042
|
const text = `【${this.masterInfo?.username ?? ""}的直播间】${body.user.uname}的SC:${body.content}(${body.price}元)`;
|
|
@@ -1067,8 +1066,7 @@ var RoomSession = class extends RoomSessionBase {
|
|
|
1067
1066
|
}
|
|
1068
1067
|
async onGuardBuy(body) {
|
|
1069
1068
|
if (!this.ctx.isSubscribed(this.sub, "liveGuardBuy")) return;
|
|
1070
|
-
|
|
1071
|
-
if (body.guard_level > effMinGuardLevel) return;
|
|
1069
|
+
if (body.guard_level > this.sub.minGuardLevel) return;
|
|
1072
1070
|
const guardImg = GUARD_LEVEL_IMG[body.guard_level];
|
|
1073
1071
|
const effectiveGuardBuy = this.sub.customGuardBuy.enable ? this.sub.customGuardBuy : this.ctx.config.customGuardBuy;
|
|
1074
1072
|
if (effectiveGuardBuy.enable) {
|
|
@@ -1690,7 +1688,7 @@ var LiveEngine = class {
|
|
|
1690
1688
|
let nextPushTime = prevPushTime;
|
|
1691
1689
|
for (const change of liveChanges) {
|
|
1692
1690
|
const { scope: _scope, ...fields } = change;
|
|
1693
|
-
if (
|
|
1691
|
+
if (fields.pushTime !== void 0) nextPushTime = fields.pushTime;
|
|
1694
1692
|
Object.assign(existing, fields);
|
|
1695
1693
|
}
|
|
1696
1694
|
for (const change of targetChanges) existing.target = change.target;
|
|
@@ -1744,10 +1742,6 @@ var LiveEngine = class {
|
|
|
1744
1742
|
};
|
|
1745
1743
|
function toListenerConfig(c) {
|
|
1746
1744
|
return {
|
|
1747
|
-
pushTime: c.pushTime,
|
|
1748
|
-
restartPush: c.restartPush,
|
|
1749
|
-
minScPrice: c.minScPrice,
|
|
1750
|
-
minGuardLevel: c.minGuardLevel,
|
|
1751
1745
|
customGuardBuy: c.customGuardBuy,
|
|
1752
1746
|
customLiveMsg: c.customLiveMsg,
|
|
1753
1747
|
liveSummaryDefault: c.liveSummaryDefault,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bilibili-notify/live",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/Akokk0/bilibili-notify"
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"jieba-wasm": "^2.4.0",
|
|
31
31
|
"luxon": "^3.5.0",
|
|
32
32
|
"protobufjs": "^7.4.0",
|
|
33
|
+
"@bilibili-notify/api": "^0.2.0-alpha.1",
|
|
34
|
+
"@bilibili-notify/internal": "^0.1.0-alpha.1",
|
|
33
35
|
"@bilibili-notify/ai": "^0.0.1-alpha.0",
|
|
34
|
-
"@bilibili-notify/
|
|
35
|
-
"@bilibili-notify/internal": "^0.1.0-alpha.0",
|
|
36
|
-
"@bilibili-notify/image": "^0.0.1-alpha.0"
|
|
36
|
+
"@bilibili-notify/image": "^0.0.1-alpha.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/luxon": "^3.4.2",
|