koishi-plugin-node-async-bot-all 2.24.0 → 2.24.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/commands.d.ts CHANGED
@@ -76,7 +76,7 @@ export declare function getQQInfo(ctx: Context, session: Session, qq: string): P
76
76
  export declare function getMsg(ctx: Context, session: Session): Promise<number>;
77
77
  export declare function getNewsMsg(ctx: Context, type: number): Promise<{
78
78
  success: boolean;
79
- data: string;
80
- msg?: string;
79
+ data?: Buffer;
80
+ msg: string;
81
81
  }>;
82
82
  export {};
package/lib/index.js CHANGED
@@ -34,7 +34,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
34
34
  // src/locales/zh-CN.yml
35
35
  var require_zh_CN = __commonJS({
36
36
  "src/locales/zh-CN.yml"(exports2, module2) {
37
- module2.exports = { commands: { cxgame: { description: "查询服务器当前人数。", messages: { msg: "{time}{list}\n进服指南请在群公告中查看。", list: "【MC 服务器 {count}】\n➣ {version}:{players}\n➣ 玩家列表:{list}\n➣ 备注:{note}", listNoPlayer: "【MC 服务器 {count}】\n➣ {version}:{players}\n➣ 备注:{note}", listFailed: "【MC 服务器 {count}】\n➣ 查询失败:{data}\n➣ 请稍后重试。\n➣ 备注:{note}", listA2S: "【A2S 服务器 {count}】\n➣ {version}:{players}\n➣ 机器人:{bots}\n➣ 备注:{note}", listFailedA2S: "【A2S 服务器 {count}】\n➣ 查询失败:{data}\n➣ 请稍后重试。\n➣ 备注:{note}", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\n查询失败:{data}", timeout: "请求超时。", fewData: "服务端返回的数据过少。", close: "服务器已关闭。", error: "执行错误。", host: "没有到主机的路由。" } }, status: { description: "查询机器人状态。", messages: { msg: "{time}\n--- 系统状态 ---\n系统名称:{name}\nCPU使用率:{cpu}\n内存使用率:{memory}\n--- 机器人状态 ---\n昨日收/发消息数量:{msgCount}\n机器人版本:{version}\n运行时间:{online}", failed: "{time}\n状态获取失败。" } }, random: { description: "随机数生成器。", usage: "缺少参数时默认生成 0-10000 的随机数。\n使用示例:", examples: "random 1 128 生成1到128范围的随机数", messages: { msg: "{time}\n生成的随机数:{data}" } }, info: { description: "查询机器人信息。", messages: { msg: "{data}", failed: "{time}\n读取信息失败。" } }, rw: { description: "随机名言名句。", messages: { msg: "{time}\n{data}", error: "执行错误。", failed: "{time}\n获取失败({data})。" } }, randomba: { description: "随机BA图。", messages: { msg: "{quote}{image}", wait: "{quote}{time}\n请等待图片上传(可能较慢)。" } }, centerservertest: { description: "查看中心服务器状态。", messages: { msg: "{time}{list}", list: "== {name} ==\n状态:{status}\n存活率:{uptime}\n检测时间:{time}", listFailed: "== {name} ==\n查看失败:{data}", failed: "{time}\n查看失败:{data}" } }, meme: { description: "群友的怪话!", messages: { msg: "{quote}{time}\n{image}\n{title}", failed: "{quote}{time}\n获取失败:{data}", forbidden: "{quote}{time}\n此指令不允许在本群使用。", error: "执行错误。" } }, randomcat: { description: "随机猫猫图。", messages: { msg: "{quote}{image}", wait: "{quote}{time}\n请等待图片上传(可能较慢)。", failed: "{quote}{time}\n获取失败:{data}" } }, getqqinfo: { description: "获取 QQ 号的信息。", messages: { msg: "{quote}{image}", failed: "{quote}{time}\n获取失败:{data}", command: "QQ 号不正确。" } }, msg2img: { description: "引用一个消息并使用此指令,即可将消息转图。", messages: { msg: "{quote}{image}", failed: "{quote}{time}\n获取失败:{data}", null: "未引用任何消息。", matroska: "{quote}禁止套娃!" } }, slnews: { description: "抓取 NorthWood 的 Steam 最新新闻。" } } };
37
+ module2.exports = { noApi: "未指定 API", noop: "无", unknownError: "未知错误。", commands: { cxgame: { description: "查询服务器当前人数。", messages: { msg: "{time}{list}\n进服指南请在群公告中查看。", list: "【MC 服务器 {count}】\n➣ {version}:{players}\n➣ 玩家列表:{list}\n➣ 备注:{note}", listNoPlayer: "【MC 服务器 {count}】\n➣ {version}:{players}\n➣ 备注:{note}", listFailed: "【MC 服务器 {count}】\n➣ 查询失败:{data}\n➣ 请稍后重试。\n➣ 备注:{note}", listA2S: "【A2S 服务器 {count}】\n➣ {version}:{players}\n➣ 机器人:{bots}\n➣ 备注:{note}", listFailedA2S: "【A2S 服务器 {count}】\n➣ 查询失败:{data}\n➣ 请稍后重试。\n➣ 备注:{note}", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\n查询失败:{data}", timeout: "请求超时。", fewData: "服务端返回的数据过少。", close: "服务器已关闭。", host: "没有到主机的路由。" } }, status: { description: "查询机器人状态。", messages: { msg: "{time}\n--- 系统状态 ---\n系统名称:{name}\nCPU使用率:{cpu}\n内存使用率:{memory}\n--- 机器人状态 ---\n昨日收/发消息数量:{msgCount}\n机器人版本:{version}\n运行时间:{online}", failed: "{time}\n状态获取失败。" } }, random: { description: "随机数生成器。", usage: "缺少参数时默认生成 0-10000 的随机数。\n使用示例:", examples: "random 1 128 生成1到128范围的随机数", messages: { msg: "{time}\n生成的随机数:{data}" } }, info: { description: "查询机器人信息。", messages: { msg: "{data}", failed: "{time}\n读取信息失败。" } }, rw: { description: "随机名言名句。", messages: { msg: "{time}\n{data}", failed: "{time}\n获取失败({data})。" } }, randomba: { description: "随机BA图。", messages: { msg: "{quote}{image}", wait: "{quote}{time}\n请等待图片上传(可能较慢)。" } }, centerservertest: { description: "查看中心服务器状态。", messages: { msg: "{time}{list}", list: "== {name} ==\n状态:{status}\n存活率:{uptime}\n检测时间:{time}", listFailed: "== {name} ==\n查看失败:{data}", failed: "{time}\n查看失败:{data}", statusLive: "✅ 正常", statusDie: "❌ 故障", dataFail: "未能获取到此服务器的状态信息。" } }, meme: { description: "群友的怪话!", messages: { msg: "{quote}{time}\n{image}\n{title}", failed: "{quote}{time}\n获取失败:{data}", forbidden: "{quote}{time}\n此指令不允许在本群使用。" } }, randomcat: { description: "随机猫猫图。", messages: { msg: "{quote}{image}", wait: "{quote}{time}\n请等待图片上传(可能较慢)。", failed: "{quote}{time}\n获取失败:{data}" } }, getqqinfo: { description: "获取 QQ 号的信息。", messages: { msg: "{quote}{image}", failed: "{quote}{time}\n获取失败:{data}", command: "QQ 号不正确。" } }, msg2img: { description: "引用一个消息并使用此指令,即可将消息转图。", messages: { msg: "{quote}{image}", failed: "{quote}{time}\n获取失败:{data}", null: "未引用任何消息。", matroska: "{quote}禁止套娃!" } }, slnews: { description: "抓取 NorthWood 的 Steam 最新新闻。" } } };
38
38
  }
39
39
  });
40
40
 
@@ -353,7 +353,7 @@ async function getServer(ctx, session) {
353
353
  if (server == void 0) {
354
354
  msg = {
355
355
  "time": time,
356
- "data": "未指定查询 服务器",
356
+ "data": session.text("noApi"),
357
357
  "success": 2
358
358
  };
359
359
  log.warn("Sent:");
@@ -375,7 +375,7 @@ async function getServer(ctx, session) {
375
375
  "players": info.players,
376
376
  "version": info.version,
377
377
  "bots": info.bots,
378
- "note": note ?? ""
378
+ "note": note ?? session.text("noop")
379
379
  };
380
380
  log.info(`Server ${count}:`);
381
381
  log.info(temp);
@@ -383,9 +383,9 @@ async function getServer(ctx, session) {
383
383
  } else {
384
384
  let err;
385
385
  if (info.error.toString().includes("Timeout reached. Possible reasons: You are being rate limited; Timeout too short; Wrong server host configured")) {
386
- err = "请求超时。";
386
+ err = session.text(".timeout");
387
387
  } else {
388
- err = "未知错误。";
388
+ err = session.text("unknown");
389
389
  }
390
390
  const temp = {
391
391
  "count": count,
@@ -405,7 +405,7 @@ async function getServer(ctx, session) {
405
405
  "count": count,
406
406
  "players": serverInfo.data.players.online + "/" + serverInfo.data.players.max,
407
407
  "version": serverInfo.data.version.name,
408
- "note": note ?? ""
408
+ "note": note ?? session.text("noop")
409
409
  };
410
410
  log.info(`Server ${count}:`);
411
411
  log.info(temp);
@@ -416,7 +416,7 @@ async function getServer(ctx, session) {
416
416
  "players": serverInfo.data.players.online + "/" + serverInfo.data.players.max,
417
417
  "version": serverInfo.data.version.name,
418
418
  "list": serverInfo.data.players.sample.map((item2) => item2.name).join(", "),
419
- "note": note ?? ""
419
+ "note": note ?? session.text("noop")
420
420
  };
421
421
  log.info(`Server ${count}:`);
422
422
  log.info(temp);
@@ -553,7 +553,7 @@ async function getRandomWord(ctx, session) {
553
553
  if (ctx.config.rwAPI == void 0) {
554
554
  msg = {
555
555
  "time": time,
556
- "data": "未指定 API",
556
+ "data": session.text("noApi"),
557
557
  "success": 2
558
558
  };
559
559
  log.warn("Sent:");
@@ -592,7 +592,7 @@ async function getBlueArchive(ctx, session) {
592
592
  log.debug(`Got: {"form":"${session.platform}:${session.event.guild?.id}","user":"${session.event.user?.id}","timestamp":${session.event.timestamp},"messageId":"${session.event.message?.id}"}`);
593
593
  const time = getHongKongTime();
594
594
  if (ctx.config.baAPI == void 0) {
595
- await session.send(session.text(".msg", { "quote": import_koishi2.h.quote(session.messageId), "image": "未指定 API" }));
595
+ await session.send(session.text(".msg", { "quote": import_koishi2.h.quote(session.messageId), "image": session.text("noApi") }));
596
596
  return 1;
597
597
  }
598
598
  const vid = await session.send(session.text(".wait", { "quote": import_koishi2.h.quote(session.messageId), "time": time }));
@@ -628,7 +628,7 @@ async function centerServerTest(ctx, session) {
628
628
  const lastTime = response.data.heartbeatList[server.id].at(-1);
629
629
  if (lastTime) {
630
630
  const uptime24 = (response.data.uptimeList[server.id + "_24"] * 100).toFixed(2) + "%";
631
- const status2 = lastTime?.status == 1 ? "正常" : "故障";
631
+ const status2 = lastTime?.status == 1 ? session.text(".statusLive") : session.text(".statusDie");
632
632
  const testTime = timeFormatter.format(/* @__PURE__ */ new Date(lastTime?.time.replace(" ", "T") + "Z"));
633
633
  list = list + "\n" + session.text(".list", {
634
634
  "name": server.name,
@@ -639,7 +639,7 @@ async function centerServerTest(ctx, session) {
639
639
  } else {
640
640
  list = list + "\n" + session.text(".listFailed", {
641
641
  "name": server.name,
642
- "data": "未能获取到此服务器的状态信息。"
642
+ "data": session.text(".dataFail")
643
643
  });
644
644
  }
645
645
  }
@@ -858,10 +858,10 @@ async function getNewsMsg(ctx, type) {
858
858
  if (response.success) {
859
859
  if ((await ctx.database.get("botData", "newsId"))[0]?.data == response.data.appnews.newsitems[0].gid && type != 1) {
860
860
  log.debug("无新闻");
861
- return { success: false, data: "" };
861
+ return { success: false, msg: "无可用新闻" };
862
862
  }
863
863
  const html = await readNewsFile(response.data, log);
864
- if (html[1]) return { success: false, data: `渲染图片失败` };
864
+ if (html[1]) return { success: false, msg: `渲染图片失败` };
865
865
  const page = await ctx.puppeteer.page();
866
866
  try {
867
867
  await page.setViewport({
@@ -884,21 +884,21 @@ async function getNewsMsg(ctx, type) {
884
884
  if (type == 0) await ctx.database.upsert("botData", [
885
885
  { id: "newsId", data: response.data.appnews.newsitems[0].gid }
886
886
  ]);
887
- return { success: true, data: Buffer.from(image).toString("base64"), msg: "NorthWood 发布了一个新闻(原文+机翻):" + response.data.appnews.newsitems[0].title };
887
+ return { success: true, data: image, msg: "NorthWood 发布了一个新闻(原文+机翻):" + response.data.appnews.newsitems[0].title };
888
888
  } catch (err) {
889
889
  log.error("图片渲染失败:", err);
890
- return { success: false, data: "图片渲染失败" };
890
+ return { success: false, msg: "图片渲染失败" };
891
891
  } finally {
892
892
  if (page && !page.isClosed()) await page.close();
893
893
  }
894
894
  } else {
895
- return { success: false, data: "请求 Steam API 失败" };
895
+ return { success: false, msg: "请求 Steam API 失败" };
896
896
  }
897
897
  }
898
898
  __name(getNewsMsg, "getNewsMsg");
899
899
 
900
900
  // package.json
901
- var version = "2.24.0";
901
+ var version = "2.24.2";
902
902
 
903
903
  // src/index.ts
904
904
  var inject = ["database", "installer", "puppeteer", "cron"];
@@ -967,13 +967,12 @@ function apply(ctx) {
967
967
  ctx.command("slnews").action(async () => {
968
968
  const log = ctx.logger("slnews");
969
969
  const outMsg = await getNewsMsg(ctx, 1);
970
- if (outMsg.success) {
970
+ if (outMsg.data) {
971
971
  return `${outMsg.msg}
972
- ${(0, import_koishi3.h)("image", { url: `data:image/jpg;base64,${outMsg.data}` })}`;
972
+ ${import_koishi3.h.image(outMsg.data, "image/png")}`;
973
973
  } else {
974
974
  log.warn(outMsg);
975
- if (outMsg.data == "") return "无可用新闻";
976
- return outMsg.data;
975
+ return outMsg.msg;
977
976
  }
978
977
  });
979
978
  ctx.cron("0 * * * *", async () => {
@@ -984,12 +983,12 @@ ${(0, import_koishi3.h)("image", { url: `data:image/jpg;base64,${outMsg.data}` }
984
983
  });
985
984
  ctx.on("node-async/news", async () => {
986
985
  const outMsg = await getNewsMsg(ctx, 0);
987
- if (outMsg.success) {
986
+ if (outMsg.data) {
988
987
  await ctx.broadcast(ctx.config.slNews, `${outMsg.msg}
989
- ${(0, import_koishi3.h)("image", { url: `data:image/jpg;base64,${outMsg.data}` })}`);
988
+ ${import_koishi3.h.image(outMsg.data, "image/png")}`);
990
989
  } else {
991
- if (outMsg.data == "") return;
992
- await ctx.broadcast(ctx.config.slNews, outMsg.data);
990
+ if (outMsg.msg == "") return;
991
+ await ctx.broadcast(ctx.config.slNews, outMsg.msg);
993
992
  }
994
993
  });
995
994
  ctx.command("cxGame").action(async ({ session }) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-node-async-bot-all",
3
3
  "description": "NodeAsync Bot插件(自用)",
4
- "version": "2.24.0",
4
+ "version": "2.24.2",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [