koishi-plugin-bilibili-notify 3.3.13-alpha.0 → 3.3.13-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.
Files changed (3) hide show
  1. package/lib/index.js +31 -12
  2. package/lib/index.mjs +31 -12
  3. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -5,11 +5,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
8
+ var __export = (all) => {
9
+ let target = {};
9
10
  for (var name$2 in all) __defProp(target, name$2, {
10
11
  get: all[name$2],
11
12
  enumerable: true
12
13
  });
14
+ return target;
13
15
  };
14
16
  var __copyProps = (to, from, except, desc) => {
15
17
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
@@ -508,13 +510,11 @@ var ComRegister = class {
508
510
  biliCom.subcommand(".ll").usage("展示当前正在直播的订阅对象").example("bili ll").action(async () => {
509
511
  const { data: { live_users } } = await ctx["bilibili-notify-api"].getTheUserWhoIsLiveStreaming();
510
512
  const subLiveUsers = [];
511
- for (const [uid, sub] of this.subManager) {
513
+ if (live_users?.items) for (const [uid, sub] of this.subManager) {
512
514
  let onLive = false;
513
- if (live_users.items) {
514
- for (const user of live_users.items) if (user.mid.toString() === uid && sub.live) {
515
- onLive = true;
516
- break;
517
- }
515
+ for (const user of live_users.items) if (user.mid.toString() === uid && sub.live) {
516
+ onLive = true;
517
+ break;
518
518
  }
519
519
  subLiveUsers.push({
520
520
  uid: Number.parseInt(uid),
@@ -1114,8 +1114,27 @@ var ComRegister = class {
1114
1114
  dUrl = bv ? bv[0] : "";
1115
1115
  } else dUrl = `${name$2}发布了新视频:https:${item.modules.module_dynamic.major.archive.jump_url}`;
1116
1116
  else dUrl = `${name$2}发布了一条动态:https://t.bilibili.com/${item.id_str}`;
1117
+ let aigc = "";
1118
+ if (this.config.ai.enable) {
1119
+ this.logger.info("正在生成AI动态推送内容...");
1120
+ if (item.type === "DYNAMIC_TYPE_AV") {
1121
+ const title = item.modules.module_dynamic.major.archive.title;
1122
+ const desc = item.modules.module_dynamic.major.archive.desc;
1123
+ aigc = (await this.ctx["bilibili-notify-api"].chatWithAI(`请你根据以下视频标题和简介,帮我写一份简短的动态播报,标题:${title},简介:${desc}`)).choices[0].message.content;
1124
+ }
1125
+ if (item.type === "DYNAMIC_TYPE_DRAW" || item.type === "DYNAMIC_TYPE_WORD") {
1126
+ const title = item.modules.module_dynamic.major.opus.title;
1127
+ const desc = item.modules.module_dynamic.major.opus.summary.text;
1128
+ aigc = (await this.ctx["bilibili-notify-api"].chatWithAI(`请你根据以下图文动态的标题和内容,帮我写一份简短的动态播报,标题:${title},内容:${desc}`)).choices[0].message.content;
1129
+ }
1130
+ this.logger.info("AI动态推送内容生成完毕!");
1131
+ }
1117
1132
  this.logger.info("推送动态中...");
1118
- await this.broadcastToTargets(uid, (0, koishi.h)("message", [koishi.h.image(buffer, "image/jpeg"), koishi.h.text(dUrl)]), PushType.Dynamic);
1133
+ await this.broadcastToTargets(uid, (0, koishi.h)("message", [
1134
+ koishi.h.image(buffer, "image/jpeg"),
1135
+ koishi.h.text(aigc),
1136
+ koishi.h.text(dUrl)
1137
+ ]), PushType.Dynamic);
1119
1138
  if (this.config.pushImgsInDynamic) {
1120
1139
  if (item.type === "DYNAMIC_TYPE_DRAW") {
1121
1140
  const pics = item.modules?.module_dynamic?.major?.opus?.pics;
@@ -1319,7 +1338,7 @@ var ComRegister = class {
1319
1338
  const buffer = await this.ctx["bilibili-notify-generate-img"].generateWordCloudImg(top90Words, masterInfo.username);
1320
1339
  return koishi.h.image(buffer, "image/jpeg");
1321
1340
  })();
1322
- const summary = (async () => {
1341
+ const summary = await (async () => {
1323
1342
  if (danmaker.length < 5) {
1324
1343
  this.logger.info("发言人数不足5位,本次弹幕词云放弃");
1325
1344
  return;
@@ -1340,7 +1359,8 @@ var ComRegister = class {
1340
1359
  liveStartTime: liveTime,
1341
1360
  liveEndTime: luxon.DateTime.now().toFormat("yyyy-MM-dd HH:mm:ss")
1342
1361
  };
1343
- const res = await this.ctx["bilibili-notify-api"].chatWithAI(`请你生成直播总结,用这样的风格,多使用emoji并且替换示例中的emoji,同时要对每个人进行个性化点评,一下是风格参考:
1362
+ const res = await this.ctx["bilibili-notify-api"].chatWithAI(`请你生成直播总结,用这样的风格,多使用emoji并且替换示例中的emoji,同时要对每个人进行个性化点评,以下是风格参考:
1363
+
1344
1364
  🔍【弹幕情报站】本场直播数据如下:
1345
1365
  🧍‍♂️ 总共 XX 位 (这里用medalName) 上线
1346
1366
  💬 共计 XXX 条弹幕飞驰而过
@@ -1972,8 +1992,7 @@ var command_register_default = ComRegister;
1972
1992
 
1973
1993
  //#endregion
1974
1994
  //#region src/database.ts
1975
- var database_exports = {};
1976
- __export(database_exports, {
1995
+ var database_exports = /* @__PURE__ */ __export({
1977
1996
  apply: () => apply$1,
1978
1997
  name: () => name$1
1979
1998
  });
package/lib/index.mjs CHANGED
@@ -22,11 +22,13 @@ import { startListen } from "blive-message-listener";
22
22
 
23
23
  //#region rolldown:runtime
24
24
  var __defProp = Object.defineProperty;
25
- var __export = (target, all) => {
25
+ var __export = (all) => {
26
+ let target = {};
26
27
  for (var name$2 in all) __defProp(target, name$2, {
27
28
  get: all[name$2],
28
29
  enumerable: true
29
30
  });
31
+ return target;
30
32
  };
31
33
 
32
34
  //#endregion
@@ -473,13 +475,11 @@ var ComRegister = class {
473
475
  biliCom.subcommand(".ll").usage("展示当前正在直播的订阅对象").example("bili ll").action(async () => {
474
476
  const { data: { live_users } } = await ctx["bilibili-notify-api"].getTheUserWhoIsLiveStreaming();
475
477
  const subLiveUsers = [];
476
- for (const [uid, sub] of this.subManager) {
478
+ if (live_users?.items) for (const [uid, sub] of this.subManager) {
477
479
  let onLive = false;
478
- if (live_users.items) {
479
- for (const user of live_users.items) if (user.mid.toString() === uid && sub.live) {
480
- onLive = true;
481
- break;
482
- }
480
+ for (const user of live_users.items) if (user.mid.toString() === uid && sub.live) {
481
+ onLive = true;
482
+ break;
483
483
  }
484
484
  subLiveUsers.push({
485
485
  uid: Number.parseInt(uid),
@@ -1079,8 +1079,27 @@ var ComRegister = class {
1079
1079
  dUrl = bv ? bv[0] : "";
1080
1080
  } else dUrl = `${name$2}发布了新视频:https:${item.modules.module_dynamic.major.archive.jump_url}`;
1081
1081
  else dUrl = `${name$2}发布了一条动态:https://t.bilibili.com/${item.id_str}`;
1082
+ let aigc = "";
1083
+ if (this.config.ai.enable) {
1084
+ this.logger.info("正在生成AI动态推送内容...");
1085
+ if (item.type === "DYNAMIC_TYPE_AV") {
1086
+ const title = item.modules.module_dynamic.major.archive.title;
1087
+ const desc = item.modules.module_dynamic.major.archive.desc;
1088
+ aigc = (await this.ctx["bilibili-notify-api"].chatWithAI(`请你根据以下视频标题和简介,帮我写一份简短的动态播报,标题:${title},简介:${desc}`)).choices[0].message.content;
1089
+ }
1090
+ if (item.type === "DYNAMIC_TYPE_DRAW" || item.type === "DYNAMIC_TYPE_WORD") {
1091
+ const title = item.modules.module_dynamic.major.opus.title;
1092
+ const desc = item.modules.module_dynamic.major.opus.summary.text;
1093
+ aigc = (await this.ctx["bilibili-notify-api"].chatWithAI(`请你根据以下图文动态的标题和内容,帮我写一份简短的动态播报,标题:${title},内容:${desc}`)).choices[0].message.content;
1094
+ }
1095
+ this.logger.info("AI动态推送内容生成完毕!");
1096
+ }
1082
1097
  this.logger.info("推送动态中...");
1083
- await this.broadcastToTargets(uid, h("message", [h.image(buffer, "image/jpeg"), h.text(dUrl)]), PushType.Dynamic);
1098
+ await this.broadcastToTargets(uid, h("message", [
1099
+ h.image(buffer, "image/jpeg"),
1100
+ h.text(aigc),
1101
+ h.text(dUrl)
1102
+ ]), PushType.Dynamic);
1084
1103
  if (this.config.pushImgsInDynamic) {
1085
1104
  if (item.type === "DYNAMIC_TYPE_DRAW") {
1086
1105
  const pics = item.modules?.module_dynamic?.major?.opus?.pics;
@@ -1284,7 +1303,7 @@ var ComRegister = class {
1284
1303
  const buffer = await this.ctx["bilibili-notify-generate-img"].generateWordCloudImg(top90Words, masterInfo.username);
1285
1304
  return h.image(buffer, "image/jpeg");
1286
1305
  })();
1287
- const summary = (async () => {
1306
+ const summary = await (async () => {
1288
1307
  if (danmaker.length < 5) {
1289
1308
  this.logger.info("发言人数不足5位,本次弹幕词云放弃");
1290
1309
  return;
@@ -1305,7 +1324,8 @@ var ComRegister = class {
1305
1324
  liveStartTime: liveTime,
1306
1325
  liveEndTime: DateTime.now().toFormat("yyyy-MM-dd HH:mm:ss")
1307
1326
  };
1308
- const res = await this.ctx["bilibili-notify-api"].chatWithAI(`请你生成直播总结,用这样的风格,多使用emoji并且替换示例中的emoji,同时要对每个人进行个性化点评,一下是风格参考:
1327
+ const res = await this.ctx["bilibili-notify-api"].chatWithAI(`请你生成直播总结,用这样的风格,多使用emoji并且替换示例中的emoji,同时要对每个人进行个性化点评,以下是风格参考:
1328
+
1309
1329
  🔍【弹幕情报站】本场直播数据如下:
1310
1330
  🧍‍♂️ 总共 XX 位 (这里用medalName) 上线
1311
1331
  💬 共计 XXX 条弹幕飞驰而过
@@ -1937,8 +1957,7 @@ var command_register_default = ComRegister;
1937
1957
 
1938
1958
  //#endregion
1939
1959
  //#region src/database.ts
1940
- var database_exports = {};
1941
- __export(database_exports, {
1960
+ var database_exports = /* @__PURE__ */ __export({
1942
1961
  apply: () => apply$1,
1943
1962
  name: () => name$1
1944
1963
  });
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.3.13-alpha.0",
4
+ "version": "3.3.13-alpha.2",
5
5
  "main": "./lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [