@bilibili-notify/live 0.0.1-alpha.0 → 0.0.1-alpha.2

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 CHANGED
@@ -725,7 +725,7 @@ var RoomSessionBase = class {
725
725
  watched,
726
726
  roomLink
727
727
  });
728
- if (this.sub.restartPush ?? this.ctx.config.restartPush) await this.ctx.sendLiveNotifyCard({
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 effPushTime = this.sub.pushTime ?? this.ctx.config.pushTime;
775
- if (effPushTime === 0 || this.pushAtTimeTimer) return;
776
- this.pushAtTimeTimer = this.ctx.serviceCtx.setInterval(() => this.tickPushAtTime(), effPushTime * 1e3 * 60 * 60);
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
- const effMinScPrice = this.sub.minScPrice ?? this.ctx.config.minScPrice;
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
- const effMinGuardLevel = this.sub.minGuardLevel ?? this.ctx.config.minGuardLevel;
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 ("pushTime" in fields) nextPushTime = fields.pushTime;
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 覆盖项。adapter 已通过 `resolve(sub, defaults)` 折叠 globals + overrides,
185
- * 这里只保留实际跟全局可能不同的字段;undefined 表示「按全局走」。room-session /
186
- * room-session-base / live-summary-requester 在用值前一律 `?? ctx.config.X` 回退。
187
- *
188
- * 这些字段也会随 LiveScopedChange 增量推送给 LiveEngine.applyOps,Object.assign
189
- * 合进活跃 sub 后,SC / 上舰 / restartPush / liveSummary 调用点会读到新值;pushTime
190
- * setInterval 句柄 ms 不可变,engine 在 update 时检测变化后会单独 rearm。
191
- */
192
- minScPrice?: number;
193
- minGuardLevel?: 1 | 2 | 3;
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
- * Configuration that listener-manager + room-session both consume.
465
- * Mirrors the koishi `BilibiliNotifyLiveConfig` minus the `logLevel` /
466
- * `wordcloudStopWords` fields (those are owned at the LiveEngine level).
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
- * Lowest allowed guard tier to push (1 = governor, 2 = supervisor,
895
- * 3 = captain — preserves Bilibili semantics).
883
+ * 引擎级全局 `pushTime`(小时;`0` 关闭)。仅用于 `updateConfig` 检测全局
884
+ * pushTime 变更后重排所有定时器;每个 UP 的实际复推间隔在
885
+ * `SubItemView.pushTime` 上(adapter 已折算 `per-UP ?? 全局`)。
896
886
  */
897
- minGuardLevel: 1 | 2 | 3;
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 覆盖项。adapter 已通过 `resolve(sub, defaults)` 折叠 globals + overrides,
185
- * 这里只保留实际跟全局可能不同的字段;undefined 表示「按全局走」。room-session /
186
- * room-session-base / live-summary-requester 在用值前一律 `?? ctx.config.X` 回退。
187
- *
188
- * 这些字段也会随 LiveScopedChange 增量推送给 LiveEngine.applyOps,Object.assign
189
- * 合进活跃 sub 后,SC / 上舰 / restartPush / liveSummary 调用点会读到新值;pushTime
190
- * setInterval 句柄 ms 不可变,engine 在 update 时检测变化后会单独 rearm。
191
- */
192
- minScPrice?: number;
193
- minGuardLevel?: 1 | 2 | 3;
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
- * Configuration that listener-manager + room-session both consume.
465
- * Mirrors the koishi `BilibiliNotifyLiveConfig` minus the `logLevel` /
466
- * `wordcloudStopWords` fields (those are owned at the LiveEngine level).
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
- * Lowest allowed guard tier to push (1 = governor, 2 = supervisor,
895
- * 3 = captain — preserves Bilibili semantics).
883
+ * 引擎级全局 `pushTime`(小时;`0` 关闭)。仅用于 `updateConfig` 检测全局
884
+ * pushTime 变更后重排所有定时器;每个 UP 的实际复推间隔在
885
+ * `SubItemView.pushTime` 上(adapter 已折算 `per-UP ?? 全局`)。
896
886
  */
897
- minGuardLevel: 1 | 2 | 3;
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 ?? this.ctx.config.restartPush) await this.ctx.sendLiveNotifyCard({
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 effPushTime = this.sub.pushTime ?? this.ctx.config.pushTime;
751
- if (effPushTime === 0 || this.pushAtTimeTimer) return;
752
- this.pushAtTimeTimer = this.ctx.serviceCtx.setInterval(() => this.tickPushAtTime(), effPushTime * 1e3 * 60 * 60);
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
- const effMinScPrice = this.sub.minScPrice ?? this.ctx.config.minScPrice;
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
- const effMinGuardLevel = this.sub.minGuardLevel ?? this.ctx.config.minGuardLevel;
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 ("pushTime" in fields) nextPushTime = fields.pushTime;
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.0",
3
+ "version": "0.0.1-alpha.2",
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/ai": "^0.0.1-alpha.0",
34
- "@bilibili-notify/api": "^0.2.0-alpha.0",
35
- "@bilibili-notify/internal": "^0.1.0-alpha.0",
36
- "@bilibili-notify/image": "^0.0.1-alpha.0"
33
+ "@bilibili-notify/api": "^0.2.0-alpha.2",
34
+ "@bilibili-notify/ai": "^0.0.1-alpha.1",
35
+ "@bilibili-notify/image": "^0.0.1-alpha.2",
36
+ "@bilibili-notify/internal": "^0.1.0-alpha.2"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/luxon": "^3.4.2",