koishi-plugin-node-async-bot-all 2.29.0 → 2.30.0

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
@@ -60,16 +60,13 @@ export interface MonitorStatusResponse {
60
60
  heartbeatList: HeartbeatList;
61
61
  uptimeList: UptimeList;
62
62
  }
63
- export declare function getServer(ctx: Context, session: Session): Promise<Object>;
63
+ export declare function getServer(ctx: Context, session: Session): Promise<number>;
64
64
  export declare function getStatus(ctx: Context, session: Session): Promise<Object>;
65
65
  export declare function getRandom(ctx: Context, session: Session, min: number, max: number): Promise<Object>;
66
66
  export declare function getInfo(ctx: Context, session: Session): Promise<Object>;
67
67
  export declare function getRandomWord(ctx: Context, session: Session): Promise<Object>;
68
68
  export declare function getBlueArchive(ctx: Context, session: Session): Promise<Number>;
69
- export declare function centerServerTest(ctx: Context, session: Session): Promise<{
70
- success: string;
71
- data: object;
72
- }>;
69
+ export declare function centerServerTest(ctx: Context, session: Session): Promise<number>;
73
70
  export declare function getMeme(ctx: Context, session: Session, count: number): Promise<Number>;
74
71
  export declare function getCat(ctx: Context, session: Session): Promise<Number>;
75
72
  export declare function getQQInfo(ctx: Context, session: Session, qq: string): Promise<number>;
package/lib/fun.d.ts CHANGED
@@ -31,7 +31,11 @@ export declare function getSystemUsage(): Promise<{
31
31
  success: 1;
32
32
  }>;
33
33
  export declare function getHongKongTime(): string;
34
- export declare function readInfoFile(ctx: Context): Promise<string>;
34
+ export declare function readInfo(ctx: Context): Promise<{
35
+ version: string;
36
+ koishiVersion: string;
37
+ nodeVersion: string;
38
+ } | string>;
35
39
  export declare function formatTimestampDiff(start: number, end: number): string;
36
40
  export declare function getMsgCount(ctx: Context): Promise<Object>;
37
41
  export declare function random(type: number | undefined, data: number | number[], data2?: number): number;
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: "未知错误。", commands: { na: { description: "NodeAsync Bot" }, 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: "没有到主机的路由。", dns: "解析失败。" } }, 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}" } }, 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: "群友的怪话!", usage: "不带参数时随机查看\n带参数时为查看指定 meme", examples: "meme\nmeme 1145", messages: { msg: "{quote}{time}\n{image}\n{title}", failed: "{quote}{time}\n获取失败:{data}", forbidden: "{quote}{time}\n此指令不允许在本群使用。" } }, randomcat: { description: "随机猫猫图。", messages: { msg: "{quote}{image}", failed: "{quote}{time}\n获取失败:{data}" } }, 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}禁止套娃!" } }, slnews: { description: "抓取 NorthWood 的 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\n---\n\n{error}", 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: "解析失败。" } }, 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}" } }, 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" } }, 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}禁止套娃!" } }, slnews: { description: "抓取 NorthWood 的 Steam 最新新闻。" }, use: { description: "使用 TA !", usage: "use @用户", examples: "use @用户", messages: { command: "请 @ 一个用户。", msg: "{at} {desc}了 {at2} !" } } } };
38
38
  }
39
39
  });
40
40
 
@@ -136,22 +136,19 @@ function getHongKongTime() {
136
136
  return `${dateObj.year}-${dateObj.month}-${dateObj.day} ${dateObj.hour}:${dateObj.minute}:${dateObj.second}`;
137
137
  }
138
138
  __name(getHongKongTime, "getHongKongTime");
139
- async function readInfoFile(ctx) {
140
- let info;
139
+ async function readInfo(ctx) {
141
140
  try {
142
- const aPath = import_path.default.resolve(__dirname, "..") + import_path.default.sep + "res" + import_path.default.sep + "info.txt";
143
- info = await import_fs.default.promises.readFile(aPath, "utf8");
144
141
  const deps = await ctx.installer.getDeps();
145
- info = info.toString().replace(
146
- "&version;",
147
- (await ctx.database.get("botData", "version"))[0].data
148
- ).replace("&kVersion;", deps.koishi.resolved).replace("&nVersion;", process.versions.node);
142
+ return {
143
+ version: (await ctx.database.get("botData", "version"))[0].data,
144
+ koishiVersion: deps.koishi.resolved,
145
+ nodeVersion: process.versions.node
146
+ };
149
147
  } catch (error) {
150
- info = error.message;
148
+ return error?.message ?? "Unknown error";
151
149
  }
152
- return info;
153
150
  }
154
- __name(readInfoFile, "readInfoFile");
151
+ __name(readInfo, "readInfo");
155
152
  function formatTimestampDiff(start, end) {
156
153
  const diff = Math.abs(end - start);
157
154
  const hours = Math.floor(diff / 3600);
@@ -366,12 +363,15 @@ async function getServer(ctx, session) {
366
363
  if (server == void 0) {
367
364
  msg = {
368
365
  "time": time,
369
- "data": session.text("noApi"),
366
+ "error": "查询失败:" + session.text("noApi"),
370
367
  "success": 2
371
368
  };
372
369
  log.warn("Sent:");
373
370
  log.warn(msg);
374
- return msg;
371
+ await session?.send(session?.bot.adapterName == "qq" ? (0, import_koishi2.h)("qq:markdown", {
372
+ content: session?.text("failed-md", msg)
373
+ }) : session?.text("failed", msg));
374
+ return 1;
375
375
  }
376
376
  let count = 0;
377
377
  let list = "";
@@ -388,12 +388,14 @@ async function getServer(ctx, session) {
388
388
  "count": count,
389
389
  "players": info.players,
390
390
  "version": info.version,
391
- "bots": info.bots,
392
- "note": note ?? session.text("noop")
391
+ "list": info.bots,
392
+ "note": note ?? session.text("noop"),
393
+ "name": "A2S",
394
+ "ne": "机器人"
393
395
  };
394
396
  log.info(`Server ${count}:`);
395
397
  log.info(temp);
396
- list = list + "\n" + session.text(".listA2S", temp);
398
+ list = list + "\n" + session.text(session?.bot.adapterName == "qq" ? ".list-md" : ".list", temp);
397
399
  } else {
398
400
  let err;
399
401
  if (info.error.toString().includes("Timeout reached. Possible reasons: You are being rate limited; Timeout too short; Wrong server host configured")) {
@@ -404,11 +406,12 @@ async function getServer(ctx, session) {
404
406
  const temp = {
405
407
  "count": count,
406
408
  "data": err,
407
- "note": note
409
+ "note": note,
410
+ "name": "A2S"
408
411
  };
409
412
  log.error(`Server ${count}:`);
410
413
  log.error(temp);
411
- list = list + "\n" + session.text(".listFailedA2S", temp);
414
+ list = list + "\n" + session.text(session?.bot.adapterName == "qq" ? ".listFailed-md" : ".listFailed", temp);
412
415
  }
413
416
  } else {
414
417
  const host = api.split(":");
@@ -420,22 +423,27 @@ async function getServer(ctx, session) {
420
423
  "count": count,
421
424
  "players": serverInfo.data.players.online + "/" + serverInfo.data.players.max,
422
425
  "version": serverInfo.data.version.name,
423
- "note": note ?? session.text("noop")
426
+ "note": note ?? session.text("noop"),
427
+ "ne": "玩家列表",
428
+ "list": "[]",
429
+ "name": "MC"
424
430
  };
425
431
  log.info(`Server ${count}:`);
426
432
  log.info(temp);
427
- list = list + "\n" + session.text(".listNoPlayer", temp);
433
+ list = list + "\n" + session.text(session?.bot.adapterName == "qq" ? ".list-md" : ".list", temp);
428
434
  } else {
429
435
  const temp = {
430
436
  "count": count,
431
437
  "players": serverInfo.data.players.online + "/" + serverInfo.data.players.max,
432
438
  "version": serverInfo.data.version.name,
433
439
  "list": serverInfo.data.players.sample.map((item2) => item2.name).join(", "),
434
- "note": note ?? session.text("noop")
440
+ "note": note ?? session.text("noop"),
441
+ "ne": "玩家列表",
442
+ "name": "MC"
435
443
  };
436
444
  log.info(`Server ${count}:`);
437
445
  log.info(temp);
438
- list = list + "\n" + session.text(".list", temp);
446
+ list = list + "\n" + session.text(session?.bot.adapterName == "qq" ? ".list-md" : ".list", temp);
439
447
  }
440
448
  } else {
441
449
  let err = serverInfo.data;
@@ -455,11 +463,12 @@ async function getServer(ctx, session) {
455
463
  const temp = {
456
464
  "count": count,
457
465
  "data": err,
458
- "note": note
466
+ "note": note,
467
+ "name": "MC"
459
468
  };
460
469
  log.error(`Server ${count}:`);
461
470
  log.error(temp);
462
- list = list + "\n" + session.text(".listFailed", temp);
471
+ list = list + "\n" + session.text(session?.bot.adapterName == "qq" ? ".listFailed-md" : ".listFailed", temp);
463
472
  }
464
473
  }
465
474
  }
@@ -468,15 +477,23 @@ async function getServer(ctx, session) {
468
477
  "list": list,
469
478
  "success": 0
470
479
  };
480
+ await session?.send(session?.bot.adapterName == "qq" ? (0, import_koishi2.h)("qq:markdown", {
481
+ content: session?.text(".msg-md", msg)
482
+ }) : session?.text(".msg", msg));
483
+ return 0;
471
484
  } else {
472
485
  msg = {
473
486
  "time": time,
487
+ "error": "此指令不允许在本群使用。",
474
488
  "success": 1
475
489
  };
476
490
  log.info("Sent:");
477
491
  log.info(msg);
492
+ await session?.send(session?.bot.adapterName == "qq" ? (0, import_koishi2.h)("qq:markdown", {
493
+ content: session?.text("failed-md", msg)
494
+ }) : session?.text("failed", msg));
495
+ return 1;
478
496
  }
479
- return msg;
480
497
  }
481
498
  __name(getServer, "getServer");
482
499
  async function getStatus(ctx, session) {
@@ -490,6 +507,8 @@ async function getStatus(ctx, session) {
490
507
  msg = {
491
508
  "time": time,
492
509
  "data": vMsg["data"],
510
+ "error": "状态获取失败。",
511
+ "quote": import_koishi2.h.quote(session.messageId),
493
512
  "success": 1
494
513
  };
495
514
  } else {
@@ -541,19 +560,20 @@ async function getInfo(ctx, session) {
541
560
  log.debug(`Got: {"form":"${session.platform}:${session.event.guild?.id}","user":"${session.event.user?.id}","timestamp":${session.event.timestamp},"messageId":"${session.event.message?.id}"}`);
542
561
  const time = getHongKongTime();
543
562
  let msg;
544
- let data = await readInfoFile(ctx);
545
- if (!data.includes("&time;")) {
546
- log.error("Error: " + data);
563
+ let data = await readInfo(ctx);
564
+ if (typeof data == "string") {
565
+ log.error("Error:", data);
547
566
  msg = {
548
567
  "time": time,
549
568
  "data": data,
569
+ "error": "读取信息失败。",
570
+ "quote": import_koishi2.h.quote(session.messageId),
550
571
  "success": 1
551
572
  };
552
573
  } else {
553
- data = data.replace("&time;", time);
554
574
  msg = {
555
575
  "time": time,
556
- "data": data,
576
+ ...data,
557
577
  "success": 0
558
578
  };
559
579
  }
@@ -570,7 +590,8 @@ async function getRandomWord(ctx, session) {
570
590
  if (ctx.config.rwAPI == void 0) {
571
591
  msg = {
572
592
  "time": time,
573
- "data": session.text("noApi"),
593
+ "error": session.text("noApi"),
594
+ "quote": import_koishi2.h.quote(session.messageId),
574
595
  "success": 2
575
596
  };
576
597
  log.warn("Sent:");
@@ -582,7 +603,8 @@ async function getRandomWord(ctx, session) {
582
603
  log.debug(response.data);
583
604
  msg = {
584
605
  "time": time,
585
- "data": response.data.data,
606
+ "error": response.data.data,
607
+ "quote": import_koishi2.h.quote(session.messageId),
586
608
  "success": 0
587
609
  };
588
610
  log.debug("Sent:");
@@ -596,7 +618,8 @@ async function getRandomWord(ctx, session) {
596
618
  }
597
619
  msg = {
598
620
  "time": time,
599
- "data": err,
621
+ "error": err,
622
+ "quote": import_koishi2.h.quote(session.messageId),
600
623
  "success": 1
601
624
  };
602
625
  log.warn("Sent:");
@@ -608,7 +631,6 @@ __name(getRandomWord, "getRandomWord");
608
631
  async function getBlueArchive(ctx, session) {
609
632
  const log = ctx.logger("ba");
610
633
  log.debug(`Got: {"form":"${session.platform}:${session.event.guild?.id}","user":"${session.event.user?.id}","timestamp":${session.event.timestamp},"messageId":"${session.event.message?.id}"}`);
611
- const time = getHongKongTime();
612
634
  if (ctx.config.baAPI == void 0) {
613
635
  await session.send(session.text(".msg", { "quote": import_koishi2.h.quote(session.messageId), "image": session.text("noApi") }));
614
636
  return 1;
@@ -647,14 +669,14 @@ async function centerServerTest(ctx, session) {
647
669
  const uptime24 = (response.data.uptimeList[server.id + "_24"] * 100).toFixed(2) + "%";
648
670
  const status2 = lastTime?.status == 1 ? session.text(".statusLive") : session.text(".statusDie");
649
671
  const testTime = timeFormatter.format(/* @__PURE__ */ new Date(lastTime?.time.replace(" ", "T") + "Z"));
650
- list = list + "\n" + session.text(".list", {
672
+ list = list + "\n" + session.text(session?.bot.adapterName == "qq" ? ".list-md" : ".list", {
651
673
  "name": server.name,
652
674
  "status": status2,
653
675
  "uptime": uptime24,
654
676
  "time": testTime
655
677
  });
656
678
  } else {
657
- list = list + "\n" + session.text(".listFailed", {
679
+ list = list + "\n" + session.text(session?.bot.adapterName == "qq" ? ".listFailed-md" : ".listFailed", {
658
680
  "name": server.name,
659
681
  "data": session.text(".dataFail")
660
682
  });
@@ -664,8 +686,12 @@ async function centerServerTest(ctx, session) {
664
686
  "data": { "list": list, "time": time },
665
687
  "success": ".msg"
666
688
  };
689
+ await session?.send(session?.bot.adapterName == "qq" ? (0, import_koishi2.h)("qq:markdown", {
690
+ content: session?.text(".msg-md", msg.data)
691
+ }) : session?.text(".msg", msg.data));
667
692
  log.debug("Sent:");
668
693
  log.debug(msg);
694
+ return 0;
669
695
  } else {
670
696
  let err;
671
697
  if (response.code) {
@@ -674,13 +700,16 @@ async function centerServerTest(ctx, session) {
674
700
  err = response.error.message;
675
701
  }
676
702
  msg = {
677
- "data": { "data": err, "time": time },
703
+ "data": { "error": "查看失败:" + err, "time": time },
678
704
  "success": ".failed"
679
705
  };
706
+ await session?.send(session?.bot.adapterName == "qq" ? (0, import_koishi2.h)("qq:markdown", {
707
+ content: session?.text("failed-md", msg.data)
708
+ }) : session?.text("failed", msg.data));
680
709
  log.warn("Sent:");
681
710
  log.warn(msg);
711
+ return 1;
682
712
  }
683
- return msg;
684
713
  }
685
714
  __name(centerServerTest, "centerServerTest");
686
715
  async function getMeme(ctx, session, count) {
@@ -692,11 +721,13 @@ async function getMeme(ctx, session, count) {
692
721
  msg = {
693
722
  "time": time,
694
723
  "quote": import_koishi2.h.quote(session.messageId),
695
- "success": ".forbidden"
724
+ "error": "此指令不允许在本群使用。"
696
725
  };
697
726
  log.warn("Sent:");
698
727
  log.warn(msg);
699
- await session.send(session.text(msg["success"], msg));
728
+ await session?.send(session?.bot.adapterName == "qq" ? (0, import_koishi2.h)("qq:markdown", {
729
+ content: session?.text("failed-md", msg)
730
+ }) : session?.text("failed", msg));
700
731
  return 0;
701
732
  }
702
733
  const api = count ? ctx.config.memesAPI[`${session.event.guild?.id}`] + `&type=1&count=${count}` : ctx.config.memesAPI[`${session.event.guild?.id}`];
@@ -706,11 +737,12 @@ async function getMeme(ctx, session, count) {
706
737
  "time": time,
707
738
  "title": response.data.data.title,
708
739
  "image": import_koishi2.h.image(response.data.data.image),
709
- "quote": import_koishi2.h.quote(session.messageId),
710
- "success": ".msg"
740
+ "quote": import_koishi2.h.quote(session.messageId)
711
741
  };
712
742
  log.debug("Sent:");
713
743
  log.debug(msg);
744
+ await session?.send(session?.bot.adapterName == "qq" ? session?.text(".msg-qq", msg) : session?.text(".msg", msg));
745
+ return 0;
714
746
  } else {
715
747
  let err;
716
748
  if (response.code) {
@@ -720,16 +752,16 @@ async function getMeme(ctx, session, count) {
720
752
  }
721
753
  msg = {
722
754
  "time": time,
723
- "data": err,
724
- "quote": import_koishi2.h.quote(session.messageId),
725
- "success": ".failed"
755
+ "error": "获取失败:" + err,
756
+ "quote": import_koishi2.h.quote(session.messageId)
726
757
  };
727
758
  log.warn("Sent:");
728
759
  log.warn(msg);
760
+ await session?.send(session?.bot.adapterName == "qq" ? (0, import_koishi2.h)("qq:markdown", {
761
+ content: session?.text("failed-md", msg)
762
+ }) : session?.text("failed", msg));
763
+ return 0;
729
764
  }
730
- const status2 = await session.send(session.text(msg["success"], msg));
731
- if (!status2) await session.send(session.text(msg["success"], msg));
732
- return 0;
733
765
  }
734
766
  __name(getMeme, "getMeme");
735
767
  async function getCat(ctx, session) {
@@ -744,17 +776,27 @@ async function getCat(ctx, session) {
744
776
  const response = await request(ctx.config.catAPI, {}, ctx.config.timeout, log);
745
777
  if (response.success) {
746
778
  log.debug(response.data);
747
- const status2 = await session.send(session.text(".msg", { "quote": import_koishi2.h.quote(session.messageId), "image": import_koishi2.h.image(response.data[0].url) }));
748
- if (!status2) await session.send(session.text(".msg", { "quote": import_koishi2.h.quote(session.messageId), "image": import_koishi2.h.image(response.data[0].url) }));
779
+ const msg = { "quote": import_koishi2.h.quote(session.messageId), "image": import_koishi2.h.image(response.data[0].url) };
780
+ await session.send(session.text(".msg", msg));
749
781
  log.debug("Sent:");
750
782
  log.debug(response.data[0].url);
751
783
  } else {
752
784
  if (response.code) {
753
- await session.send(session.text(".failed", { "quote": import_koishi2.h.quote(session.messageId), "data": response.isJson ? response.error["error"] : response.error, "time": time }));
785
+ const msg = {
786
+ "quote": import_koishi2.h.quote(session.messageId),
787
+ "data": response.isJson ? "获取失败:" + response.error["error"] : "获取失败:" + response.error,
788
+ "time": time
789
+ };
790
+ await session?.send(session?.bot.adapterName == "qq" ? (0, import_koishi2.h)("qq:markdown", {
791
+ content: session?.text("failed-md", msg)
792
+ }) : session?.text("failed", msg));
754
793
  log.warn("Sent:");
755
794
  log.warn(response.error);
756
795
  } else {
757
- await session.send(session.text(".failed", { "quote": import_koishi2.h.quote(session.messageId), "data": response.error.message, "time": time }));
796
+ const msg = { "quote": import_koishi2.h.quote(session.messageId), "data": "获取失败:" + response.error.message, "time": time };
797
+ await session?.send(session?.bot.adapterName == "qq" ? (0, import_koishi2.h)("qq:markdown", {
798
+ content: session?.text("failed-md", msg)
799
+ }) : session?.text("failed", msg));
758
800
  log.warn("Sent:");
759
801
  log.warn(response.error);
760
802
  }
@@ -939,7 +981,7 @@ async function getUse(ctx, session, qq, desc) {
939
981
  __name(getUse, "getUse");
940
982
 
941
983
  // package.json
942
- var version = "2.29.0";
984
+ var version = "2.30.0";
943
985
 
944
986
  // src/index.ts
945
987
  var inject = ["database", "installer", "puppeteer", "cron"];
@@ -998,17 +1040,17 @@ var Config = import_koishi3.Schema.intersect([
998
1040
  }).description("测试中心服务器")
999
1041
  ]).description("基础设置");
1000
1042
  async function startReaction(session) {
1001
- await session.bot.createReaction(session.channelId, session.messageId, `face|424`);
1043
+ if (session.bot.createReaction) await session.bot.createReaction(session.channelId, session.messageId, `face|424`);
1002
1044
  }
1003
1045
  __name(startReaction, "startReaction");
1004
1046
  async function endReaction(session) {
1005
- await session.bot.deleteReaction(session.channelId, session.messageId, `face|424`);
1006
- await session.bot.createReaction(session.channelId, session.messageId, `face|144`);
1047
+ if (session.bot.deleteReaction) await session.bot.deleteReaction(session.channelId, session.messageId, `face|424`);
1048
+ if (session.bot.createReaction) await session.bot.createReaction(session.channelId, session.messageId, `face|144`);
1007
1049
  }
1008
1050
  __name(endReaction, "endReaction");
1009
1051
  async function endReactionFailed(session) {
1010
- await session.bot.deleteReaction(session.channelId, session.messageId, `face|424`);
1011
- await session.bot.createReaction(session.channelId, session.messageId, `face|41`);
1052
+ if (session.bot.deleteReaction) await session.bot.deleteReaction(session.channelId, session.messageId, `face|424`);
1053
+ if (session.bot.createReaction) await session.bot.createReaction(session.channelId, session.messageId, `face|38`);
1012
1054
  }
1013
1055
  __name(endReactionFailed, "endReactionFailed");
1014
1056
  function apply(ctx) {
@@ -1063,14 +1105,9 @@ ${import_koishi3.h.image(outMsg.data, "image/png")}`);
1063
1105
  na.subcommand("cxGame").action(async ({ session }) => {
1064
1106
  await startReaction(session);
1065
1107
  const cx = await getServer(ctx, session);
1066
- if (cx["success"] == 0) {
1067
- await session?.send(session?.text(".msg", cx));
1108
+ if (cx == 0) {
1068
1109
  await endReaction(session);
1069
- } else if (cx["success"] == 1) {
1070
- await session?.send(session?.text(".forbidden", cx));
1071
- await endReactionFailed(session);
1072
- } else if (cx["success"] == 2) {
1073
- await session?.send(session?.text(".failed", cx));
1110
+ } else {
1074
1111
  await endReactionFailed(session);
1075
1112
  }
1076
1113
  });
@@ -1078,27 +1115,37 @@ ${import_koishi3.h.image(outMsg.data, "image/png")}`);
1078
1115
  await startReaction(session);
1079
1116
  const status2 = await getStatus(ctx, session);
1080
1117
  if (status2["success"] == 0) {
1081
- await session?.send(session?.text(".msg", status2));
1118
+ await session?.send(session?.bot.adapterName == "qq" ? (0, import_koishi3.h)("qq:markdown", {
1119
+ content: session?.text(".msg-md", status2)
1120
+ }) : session?.text(".msg", status2));
1082
1121
  await endReaction(session);
1083
1122
  } else {
1084
- await session?.send(session?.text(".failed", status2));
1123
+ await session?.send(session?.bot.adapterName == "qq" ? (0, import_koishi3.h)("qq:markdown", {
1124
+ content: session?.text("failed-md", status2)
1125
+ }) : session?.text("failed", status2));
1085
1126
  await endReactionFailed(session);
1086
1127
  }
1087
1128
  });
1088
1129
  na.subcommand("random [最小数:number] [最大数:number]").alias("随机数").action(async ({ session }, min, max) => {
1089
1130
  await startReaction(session);
1090
1131
  const random2 = await getRandom(ctx, session, min, max);
1091
- await session?.send(session?.text(".msg", random2));
1132
+ await session?.send(session?.bot.adapterName == "qq" ? (0, import_koishi3.h)("qq:markdown", {
1133
+ content: session?.text(".msg-md", random2)
1134
+ }) : session?.text(".msg", random2));
1092
1135
  await endReaction(session);
1093
1136
  });
1094
1137
  na.subcommand("info").action(async ({ session }) => {
1095
1138
  await startReaction(session);
1096
1139
  const info = await getInfo(ctx, session);
1097
1140
  if (info["success"] == 0) {
1098
- await session?.send(session?.text(".msg", info));
1141
+ await session?.send(session?.bot.adapterName == "qq" ? (0, import_koishi3.h)("qq:markdown", {
1142
+ content: session?.text(".msg-md", info)
1143
+ }) : session?.text(".msg", info));
1099
1144
  await endReaction(session);
1100
1145
  } else {
1101
- await session?.send(session?.text(".failed", info));
1146
+ await session?.send(session?.bot.adapterName == "qq" ? (0, import_koishi3.h)("qq:markdown", {
1147
+ content: session?.text("failed-md", info)
1148
+ }) : session?.text("failed", info));
1102
1149
  await endReactionFailed(session);
1103
1150
  }
1104
1151
  });
@@ -1106,10 +1153,14 @@ ${import_koishi3.h.image(outMsg.data, "image/png")}`);
1106
1153
  await startReaction(session);
1107
1154
  const rw = await getRandomWord(ctx, session);
1108
1155
  if (rw["success"] == 0) {
1109
- await session?.send(session?.text(".msg", rw));
1156
+ await session?.send(session?.bot.adapterName == "qq" ? (0, import_koishi3.h)("qq:markdown", {
1157
+ content: session?.text("failed-md", rw)
1158
+ }) : session?.text("failed", rw));
1110
1159
  await endReaction(session);
1111
1160
  } else {
1112
- await session?.send(session?.text(".failed", rw));
1161
+ await session?.send(session?.bot.adapterName == "qq" ? (0, import_koishi3.h)("qq:markdown", {
1162
+ content: session?.text("failed-md", rw)
1163
+ }) : session?.text("failed", rw));
1113
1164
  await endReactionFailed(session);
1114
1165
  }
1115
1166
  });
@@ -1120,9 +1171,12 @@ ${import_koishi3.h.image(outMsg.data, "image/png")}`);
1120
1171
  });
1121
1172
  na.subcommand("centerServerTest").alias("测测中心服务器").action(async ({ session }) => {
1122
1173
  await startReaction(session);
1123
- const msg = await centerServerTest(ctx, session);
1124
- await session?.send(session?.text(msg.success, msg.data));
1125
- await endReaction(session);
1174
+ const ct = await centerServerTest(ctx, session);
1175
+ if (ct == 0) {
1176
+ await endReaction(session);
1177
+ } else {
1178
+ await endReactionFailed(session);
1179
+ }
1126
1180
  });
1127
1181
  na.subcommand("meme [序号:posint]").alias("memes").action(async ({ session }, count) => {
1128
1182
  await startReaction(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.29.0",
4
+ "version": "2.30.0",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [
package/res/info.txt DELETED
@@ -1,10 +0,0 @@
1
- &time;
2
- --- NodeAsync &version; ---
3
- 私有机器人,服务器专用。
4
- --- 开发者 ---
5
- 德二吹风机(3112836258)
6
- --- 其他 ---
7
- Node.js 版本:&nVersion;
8
- Koishi 版本:&kVersion;
9
- 开源地址:https://github.com/ccd2s/node-async-bot-all
10
- 官网:https://www.tasaed.top