koishi-plugin-node-async-bot-all 3.1.0 → 3.1.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
@@ -36,7 +36,7 @@ export declare class CommandHandler {
36
36
  server(): Promise<number>;
37
37
  status(botData: botDataType): Promise<object>;
38
38
  random(min: number, max: number): Promise<object>;
39
- info(): Promise<object>;
39
+ info(botData: botDataType): Promise<object>;
40
40
  randomWord(): Promise<object>;
41
41
  blueArchive(): Promise<number>;
42
42
  centerServerTest(): Promise<number>;
package/lib/fun.d.ts CHANGED
@@ -45,7 +45,6 @@ export declare function getSystemUsage(): Promise<{
45
45
  }>;
46
46
  export declare function getHongKongTime(): string;
47
47
  export declare function readInfo(ctx: Context): Promise<{
48
- version: string;
49
48
  koishiVersion: string;
50
49
  nodeVersion: string;
51
50
  } | string>;
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 = { noApi: "未指定 API", noop: "无", unknownError: "未知错误。", failed: "{quote}{time}\n{error}", "failed-md": "**{time}**\n{error}", cat: "{name}Cat 信息\n版本: {version}\n平台: {platform}\n运行时间: {time}", commands: { na: { description: "NodeAsync Bot" }, cxgame: { description: "查询服务器当前人数。", messages: { msg: "{time}{list}\n进服指南请在群公告中查看。", "msg-md": "*{time}*\n\n---\n{list}\n\n---\n\n进服指南请在群公告中查看。", list: "【{name} 服务器 {count}】\n➣ {version}:{players}\n➣ {ne}:{list}\n➣ 备注:{note}", "list-md": "## {name} 服务器 {count}\n\n- {version}:{players}\n- {ne}:{list}\n- 备注:{note}", listFailed: "【{name} 服务器 {count}】\n➣ 查询失败:{data}\n➣ 请稍后重试。\n➣ 备注:{note}", "listFailed-md": "## {name} 服务器 {count}\n\n- 查询失败:{data}\n- 请稍后重试。\n- 备注:{note}", timeout: "请求超时。", fewData: "服务端返回的数据过少。", close: "服务器已关闭。", host: "没有到主机的路由。", dns: "解析失败。", "ne-a2s": "机器人", "ne-mc": "玩家列表", forbidden: "此指令不允许在本群使用。", failed: "查询失败:" } }, status: { description: "查询机器人状态。", messages: { msg: "{time}\n--- 系统状态 ---\n系统名称:{name}\nCPU使用率:{cpu}\n内存使用率:{memory}\n--- 机器人状态 ---\n昨日收/发消息数量:{msgCount}\n机器人版本:{version}\n运行时间:{online}", "msg-md": "*{time}*\n\n---\n\n## 系统状态\n\n- 系统名称:{name}\n- CPU使用率:{cpu}\n- 内存使用率:{memory}\n\n## 机器人状态\n\n- 昨日收/发消息数量:{msgCount}\n- 机器人版本:{version}\n- 运行时间:{online}", error: "状态获取失败。" } }, random: { description: "随机数生成器。", usage: "缺少参数时默认生成 0-10000 的随机数。\n使用示例:", examples: "random 1 128 生成1到128范围的随机数", messages: { msg: "{time}\n生成了一个随机数:{data}", "msg-md": "*{time}*\n\n---\n\n生成了一个随机数:{data}" } }, info: { description: "查询机器人信息。", messages: { msg: "{time}\n--- NodeAsync {version} ---\n私有机器人,服务器专用。\n--- 开发者 ---\n德二吹风机(3112836258)\n--- 其他 ---\nNode.js 版本:{nodeVersion}\nKoishi 版本:{koishiVersion}\n开源地址:https://github.com/ccd2s/node-async-bot-all\n官网:https://www.tasaed.top", "msg-md": "*{time}*\n\n---\n\n## NodeAsync {version}\n\n私有机器人,服务器专用。\n\n## 开发者\n\n- 德二吹风机(3112836258)\n\n## 其他\n\n- Node.js 版本:{nodeVersion}\n- Koishi 版本:{koishiVersion}\n- 开源地址:https://github.com/ccd2s/node-async-bot-all\n- 官网:https://www.tasaed.top", error: "读取信息失败。" } }, rw: { description: "随机名言名句。", messages: null }, randomba: { description: "随机BA图。", messages: { msg: "{quote}{image}" } }, centerservertest: { description: "查看中心服务器状态。", messages: { msg: "{time}{list}", "msg-md": "*{time}*\n\n---\n{list}", list: "== {name} ==\n状态:{status}\n存活率:{uptime}\n检测时间:{time}", "list-md": "## {name}\n\n- 状态:{status}\n- 存活率:{uptime}\n- 检测时间:{time}", listFailed: "== {name} ==\n查看失败:{data}", "listFailed-md": "## {name}\n\n查看失败:{data}", statusLive: "✅ 正常", statusDie: "❌ 故障", dataFail: "未能获取到此服务器的状态信息。" } }, meme: { description: "群友的怪话!", usage: "不带参数时随机查看\n带参数时为查看指定 meme", examples: "meme\nmeme 1145", messages: { msg: "{quote}{time}\n{image}\n{title}", "msg-qq": "{quote}{image}\n{time}\n{title}" } }, randomcat: { description: "随机猫猫图。", messages: { msg: "{quote}{image}" } }, getqqinfo: { description: "获取 QQ 号的信息。", usage: "获取 QQ 号的信息。", examples: "getqqinfo 10001", messages: { msg: "{quote}{image}", failed: "{quote}{time}\n获取失败:{data}", command: "QQ 号不正确。" } }, msg2img: { description: "引用一个消息并使用此指令,即可将消息转图。", usage: "引用一条消息,/m。(不要带@)", messages: { msg: "{quote}{image}", failed: "{quote}{time}\n获取失败:{data}", null: "未引用任何消息。", matroska: "{quote}禁止套娃!" } }, steamnews: { description: "抓取 Steam 游戏的最新新闻。" }, use: { description: "使用 TA !", usage: "use @用户", examples: "use @用户", messages: { command: "请 @ 一个用户。", msg: "{at} {desc}了 {at2} !" } } } };
37
+ module2.exports = { noApi: "未指定 API", noop: "无", unknownError: "未知错误。", failed: "{quote}{time}\n{error}", "failed-md": "**{time}**\n{error}", cat: "{name}Cat 信息\n版本: {version}\n平台: {platform}\nKoishi 版本:{koishiVersion}\n运行时间: {time}", commands: { na: { description: "NodeAsync Bot" }, cxgame: { description: "查询服务器当前人数。", messages: { msg: "{time}{list}\n进服指南请在群公告中查看。", "msg-md": "*{time}*\n\n---\n{list}\n\n---\n\n进服指南请在群公告中查看。", list: "【{name} 服务器 {count}】\n➣ {version}:{players}\n➣ {ne}:{list}\n➣ 备注:{note}", "list-md": "## {name} 服务器 {count}\n\n- {version}:{players}\n- {ne}:{list}\n- 备注:{note}", listFailed: "【{name} 服务器 {count}】\n➣ 查询失败:{data}\n➣ 请稍后重试。\n➣ 备注:{note}", "listFailed-md": "## {name} 服务器 {count}\n\n- 查询失败:{data}\n- 请稍后重试。\n- 备注:{note}", timeout: "请求超时。", fewData: "服务端返回的数据过少。", close: "服务器已关闭。", host: "没有到主机的路由。", dns: "解析失败。", "ne-a2s": "机器人", "ne-mc": "玩家列表", forbidden: "此指令不允许在本群使用。", failed: "查询失败:" } }, status: { description: "查询机器人状态。", messages: { msg: "{time}\n--- 系统状态 ---\n系统名称:{name}\nCPU使用率:{cpu}\n内存使用率:{memory}\n--- 机器人状态 ---\n昨日收/发消息数量:{msgCount}\n机器人版本:{version}\n运行时间:{online}", "msg-md": "*{time}*\n\n---\n\n## 系统状态\n\n- 系统名称:{name}\n- CPU使用率:{cpu}\n- 内存使用率:{memory}\n\n## 机器人状态\n\n- 昨日收/发消息数量:{msgCount}\n- 机器人版本:{version}\n- 运行时间:{online}", error: "状态获取失败。" } }, random: { description: "随机数生成器。", usage: "缺少参数时默认生成 0-10000 的随机数。\n使用示例:", examples: "random 1 128 生成1到128范围的随机数", messages: { msg: "{time}\n生成了一个随机数:{data}", "msg-md": "*{time}*\n\n---\n\n生成了一个随机数:{data}" } }, info: { description: "查询机器人信息。", messages: { msg: "{time}\n--- NodeAsync {version} ---\n私有机器人,服务器专用。\n--- 开发者 ---\n德二吹风机(3112836258)\n--- 其他 ---\nNode.js 版本:{nodeVersion}\nKoishi 版本:{koishiVersion}\n开源地址:https://github.com/ccd2s/node-async-bot-all\n官网:https://www.tasaed.top", "msg-md": "*{time}*\n\n---\n\n## NodeAsync {version}\n\n私有机器人,服务器专用。\n\n## 开发者\n\n- 德二吹风机(3112836258)\n\n## 其他\n\n- Node.js 版本:{nodeVersion}\n- Koishi 版本:{koishiVersion}\n- 开源地址:https://github.com/ccd2s/node-async-bot-all\n- 官网:https://www.tasaed.top", error: "读取信息失败。" } }, rw: { description: "随机名言名句。", messages: null }, randomba: { description: "随机BA图。", messages: { msg: "{quote}{image}" } }, centerservertest: { description: "查看中心服务器状态。", messages: { msg: "{time}{list}", "msg-md": "*{time}*\n\n---\n{list}", list: "== {name} ==\n状态:{status}\n存活率:{uptime}\n检测时间:{time}", "list-md": "## {name}\n\n- 状态:{status}\n- 存活率:{uptime}\n- 检测时间:{time}", listFailed: "== {name} ==\n查看失败:{data}", "listFailed-md": "## {name}\n\n查看失败:{data}", statusLive: "✅ 正常", statusDie: "❌ 故障", dataFail: "未能获取到此服务器的状态信息。" } }, meme: { description: "群友的怪话!", usage: "不带参数时随机查看\n带参数时为查看指定 meme", examples: "meme\nmeme 1145", messages: { msg: "{quote}{time}\n{image}\n{title}", "msg-qq": "{quote}{image}\n{time}\n{title}" } }, randomcat: { description: "随机猫猫图。", messages: { msg: "{quote}{image}" } }, getqqinfo: { description: "获取 QQ 号的信息。", usage: "获取 QQ 号的信息。", examples: "getqqinfo 10001", messages: { msg: "{quote}{image}", failed: "{quote}{time}\n获取失败:{data}", command: "QQ 号不正确。" } }, msg2img: { description: "引用一个消息并使用此指令,即可将消息转图。", usage: "引用一条消息,/m。(不要带@)", messages: { msg: "{quote}{image}", failed: "{quote}{time}\n获取失败:{data}", null: "未引用任何消息。", matroska: "{quote}禁止套娃!" } }, steamnews: { description: "抓取 Steam 游戏的最新新闻。" }, use: { description: "使用 TA !", usage: "use @用户", examples: "use @用户", messages: { command: "请 @ 一个用户。", msg: "{at} {desc}了 {at2} !" } } } };
38
38
  }
39
39
  });
40
40
 
@@ -63,7 +63,7 @@ var import_steam_server_query = require("steam-server-query");
63
63
  var import_feedsmith = require("feedsmith");
64
64
  var import_minecraft_server_util = require("minecraft-server-util");
65
65
  function getSystemName() {
66
- return import_os.default.type() + " " + import_os.default.release();
66
+ return import_os.default.type() + " " + import_os.default.release() + " (" + import_os.default.arch() + ")";
67
67
  }
68
68
  __name(getSystemName, "getSystemName");
69
69
  function getMemoryUsage() {
@@ -139,7 +139,6 @@ async function readInfo(ctx) {
139
139
  try {
140
140
  const deps = await ctx.installer.getDeps();
141
141
  return {
142
- version: (await ctx.database.get("botData", "version"))[0].data,
143
142
  koishiVersion: deps.koishi.resolved,
144
143
  nodeVersion: process.versions.node
145
144
  };
@@ -491,7 +490,7 @@ var CommandHandler = class {
491
490
  cpu: vMsg.cpu,
492
491
  memory: vMsg.memory,
493
492
  online: formatTimestampDiff(
494
- Number(botData.uptime),
493
+ Number((await ctx.database.get("botData", "uptime"))[0].data),
495
494
  Number(session.event.timestamp.toString().substring(0, 10))
496
495
  ),
497
496
  msgCount: `${msgCount.receive}/${msgCount.send}`,
@@ -525,7 +524,7 @@ var CommandHandler = class {
525
524
  return msg;
526
525
  }
527
526
  // 指令 Info
528
- async info() {
527
+ async info(botData) {
529
528
  const { ctx, session, log, time } = this;
530
529
  let msg;
531
530
  let data = await readInfo(ctx);
@@ -542,6 +541,7 @@ var CommandHandler = class {
542
541
  msg = {
543
542
  time,
544
543
  ...data,
544
+ version: botData.version,
545
545
  success: 0
546
546
  };
547
547
  }
@@ -820,7 +820,7 @@ var CommandHandler = class {
820
820
  };
821
821
 
822
822
  // package.json
823
- var version = "3.1.0";
823
+ var version = "3.1.2";
824
824
 
825
825
  // src/config.ts
826
826
  var import_koishi3 = require("koishi");
@@ -915,8 +915,7 @@ var NodeAsyncBot = class {
915
915
  }
916
916
  async init(ct) {
917
917
  this.ctx = ct;
918
- const vUptime = (await this.ctx.database.get("botData", "uptime"))[0];
919
- const date = vUptime ? vUptime.data : (/* @__PURE__ */ new Date()).getTime().toString().substring(0, 10);
918
+ const date = (/* @__PURE__ */ new Date()).getTime().toString().substring(0, 10);
920
919
  this.botData = {
921
920
  version,
922
921
  uptime: date
@@ -1021,15 +1020,19 @@ ${import_koishi4.h.image(outMsg.data, "image/png")}`
1021
1020
  const match = session.content.match(/^#([a-zA-Z0-9]+)cat$/);
1022
1021
  if (match) {
1023
1022
  const system = await getSystemUsage();
1024
- await session.send(session.text("cat", {
1025
- name: match[1].charAt(0).toUpperCase() + match[1].slice(1),
1026
- time: formatTimestampDiff(
1027
- Number(this.botData.uptime),
1028
- Number(session.event.timestamp.toString().substring(0, 10))
1029
- ),
1030
- version: this.botData.version,
1031
- platform: system.success == 1 ? "未知" : system.name
1032
- }));
1023
+ const info = await readInfo(this.ctx);
1024
+ await session.send(
1025
+ session.text("cat", {
1026
+ name: match[1].charAt(0).toUpperCase() + match[1].slice(1),
1027
+ time: formatTimestampDiff(
1028
+ Number((await this.ctx.database.get("botData", "uptime"))[0].data),
1029
+ Number(session.event.timestamp.toString().substring(0, 10))
1030
+ ),
1031
+ version: this.botData.version,
1032
+ platform: system.success == 1 ? "未知" : system.name,
1033
+ koishiVersion: typeof info === "string" ? "未知" : info.koishiVersion
1034
+ })
1035
+ );
1033
1036
  }
1034
1037
  if (session.bot.createReaction) {
1035
1038
  for (const content of this.ctx.config.specialMsg) {
@@ -1073,7 +1076,7 @@ ${import_koishi4.h.image(outMsg.data, "image/png")}`
1073
1076
  });
1074
1077
  this.na.subcommand("info").action(async ({ session }) => {
1075
1078
  await this.execCommand(session, "info", async (handler) => {
1076
- const info = await handler.info();
1079
+ const info = await handler.info(this.botData);
1077
1080
  await session?.send(
1078
1081
  session?.bot.adapterName == "qq" ? (0, import_koishi4.h)("qq:markdown", {
1079
1082
  content: session?.text(info["success"] == 0 ? ".msg-md" : "failed-md", info)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-node-async-bot-all",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "NodeAsync Bot插件(自用)",
5
5
  "keywords": [
6
6
  "chatbot",