koishi-plugin-node-async-bot-all 2.16.0 → 2.17.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
@@ -14,3 +14,4 @@ export declare function getBA(ctx: Context, session: Session): Promise<Number>;
14
14
  export declare function serverTest(ctx: Context, session: Session): Promise<Object>;
15
15
  export declare function getSteam(ctx: Context, session: Session, id: number): Promise<Object>;
16
16
  export declare function getMeme(ctx: Context, session: Session, count: number): Promise<Number>;
17
+ export declare function getCat(ctx: Context, session: Session): Promise<Number>;
package/lib/index.d.ts CHANGED
@@ -24,6 +24,7 @@ export interface Config {
24
24
  serverPing: Dict<string>;
25
25
  steamAPI: string;
26
26
  memesAPI: Dict<string>;
27
+ catAPI: string;
27
28
  }
28
29
  export declare const Config: Schema<Config>;
29
30
  export declare function apply(ctx: Context): void;
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➣ 请稍后重试。", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\n查询失败:{data}", timeout: "请求超时。", timeout2: "响应超时。", 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: "执行错误。", failed1: "{time}\n获取失败(1)。", failed2: "{time}\n获取失败({data})。" } }, randomba: { description: "随机BA图。", messages: { msg: "{quote}{image}", wait: "{quote}{time}\n请等待图片上传(可能较慢)。" } }, servertest: { description: "Ping服务器。", messages: { msg: "{time}\n== Ping {host} ==\n状态:{alive}\n丢包率:{packetLoss}\n返回IP:{ip}", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\nPing 失败:{data}" } }, steamid: { description: "将 Steam 好友码(SteamID 3)转为 SteamID 64。", messages: { msg: "{time}\n转换结果:{data}", failed: "{time}\n转换失败:{data}", null: "参数 Steam 好友码(SteamID 3) 不得为空。", command: "执行错误。" } }, meme: { description: "群友的怪话!", messages: { msg: "{quote}{time}\n{image}\n{title}", failed: "{quote}{time}\n获取失败:{data}", forbidden: "{quote}{time}\n此指令不允许在本群使用。", error: "执行错误。", e: "未能发送消息。" } } } };
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➣ 请稍后重试。", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\n查询失败:{data}", timeout: "请求超时。", timeout2: "响应超时。", 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: "执行错误。", failed1: "{time}\n获取失败(1)。", failed2: "{time}\n获取失败({data})。" } }, randomba: { description: "随机BA图。", messages: { msg: "{quote}{image}", wait: "{quote}{time}\n请等待图片上传(可能较慢)。" } }, servertest: { description: "Ping服务器。", messages: { msg: "{time}\n== Ping {host} ==\n状态:{alive}\n丢包率:{packetLoss}\n返回IP:{ip}", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\nPing 失败:{data}" } }, steamid: { description: "将 Steam 好友码(SteamID 3)转为 SteamID 64。", messages: { msg: "{time}\n转换结果:{data}", failed: "{time}\n转换失败:{data}", null: "参数 Steam 好友码(SteamID 3) 不得为空。", command: "执行错误。" } }, 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}", error: "执行错误。", wait: "{quote}{time}\n请等待图片上传(可能较慢)。", failed: "{quote}{time}\n获取失败:{data}" } } } };
38
38
  }
39
39
  });
40
40
 
@@ -500,7 +500,7 @@ async function getBA(ctx, session) {
500
500
  const log = ctx.logger("ba");
501
501
  log.info(`Got: {"form":"${session.event.guild?.id}","user":"${session.event.user?.id}","timestamp":${session.event.timestamp},"messageId":"${session.event.message?.id}"}`);
502
502
  const time = getHongKongTime();
503
- if (ctx.config.rwAPI == void 0) {
503
+ if (ctx.config.baAPI == void 0) {
504
504
  await session.send(session.text(".msg", { "quote": import_koishi2.h.quote(session.messageId), "image": "未指定 API" }));
505
505
  return 1;
506
506
  }
@@ -648,9 +648,42 @@ async function getMeme(ctx, session, count) {
648
648
  return 0;
649
649
  }
650
650
  __name(getMeme, "getMeme");
651
+ async function getCat(ctx, session) {
652
+ const log = ctx.logger("cat");
653
+ log.info(`Got: {"form":"${session.event.guild?.id}","user":"${session.event.user?.id}","timestamp":${session.event.timestamp},"messageId":"${session.event.message?.id}"}`);
654
+ const time = getHongKongTime();
655
+ if (ctx.config.catAPI == void 0) {
656
+ await session.send(session.text(".failed", { "quote": import_koishi2.h.quote(session.messageId), "data": "未指定 API", "time": time }));
657
+ return 1;
658
+ }
659
+ const vid = await session.send(session.text(".wait", { "quote": import_koishi2.h.quote(session.messageId), "time": time }));
660
+ const response = await getHttp(log, ctx.config.catAPI, ctx.config.timeout);
661
+ if (response.success) {
662
+ const data = response.data;
663
+ log.info(data[0]["url"]);
664
+ await session.send(session.text(".msg", { "quote": import_koishi2.h.quote(session.messageId), "image": import_koishi2.h.image(data[0]["url"]) }));
665
+ log.info("Sent:");
666
+ log.info(data[0]["url"]);
667
+ } else {
668
+ if (response.error) {
669
+ const data = response.data;
670
+ await session.send(session.text(".failed", { "quote": import_koishi2.h.quote(session.messageId), "data": data["name"] === "AbortError" ? session.text(".error") : data["message"], "time": time }));
671
+ log.info("Sent:");
672
+ log.info(data["message"]);
673
+ } else {
674
+ const data = response.data;
675
+ await session.send(session.text(".failed", { "quote": import_koishi2.h.quote(session.messageId), "data": data["data"], "time": time }));
676
+ log.info("Sent:");
677
+ log.info(data["data"]);
678
+ }
679
+ }
680
+ await session.bot.deleteMessage(session.event.guild?.id, vid[0]);
681
+ return 0;
682
+ }
683
+ __name(getCat, "getCat");
651
684
 
652
685
  // package.json
653
- var version = "2.16.0";
686
+ var version = "2.17.0";
654
687
 
655
688
  // src/index.ts
656
689
  var inject = ["database", "installer"];
@@ -683,7 +716,10 @@ var Config = import_koishi3.Schema.intersect([
683
716
  }).description("转换 Steam ID"),
684
717
  import_koishi3.Schema.object({
685
718
  memesAPI: import_koishi3.Schema.dict(String).role("table").description("群友 meme API")
686
- }).description("群友 meme")
719
+ }).description("群友 meme"),
720
+ import_koishi3.Schema.object({
721
+ catAPI: import_koishi3.Schema.string().default("https://api.thecatapi.com/v1/images/search").description("随机猫猫图 API")
722
+ }).description("随机猫猫图")
687
723
  ]).description("基础设置");
688
724
  function apply(ctx) {
689
725
  ctx.i18n.define("zh-CN", require_zh_CN());
@@ -709,7 +745,7 @@ function apply(ctx) {
709
745
  return session?.text(".failed", cx);
710
746
  }
711
747
  });
712
- ctx.command("status").action(async ({ session }) => {
748
+ ctx.command("status").alias("stats").alias("状态").action(async ({ session }) => {
713
749
  const status = await getStatus(ctx, session);
714
750
  if (status["success"] == 0) {
715
751
  return session?.text(".msg", status);
@@ -764,11 +800,10 @@ function apply(ctx) {
764
800
  }
765
801
  });
766
802
  ctx.command("meme [序号:posint]").alias("memes").action(async ({ session }, count) => {
767
- try {
768
- await getMeme(ctx, session, count);
769
- } catch (e) {
770
- await session?.send(session?.text(".e"));
771
- }
803
+ await getMeme(ctx, session, count);
804
+ });
805
+ ctx.command("randomCat").alias("随机猫猫图").alias("随机猫猫").action(async ({ session }) => {
806
+ await getCat(ctx, session);
772
807
  });
773
808
  }
774
809
  __name(apply, "apply");
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.16.0",
4
+ "version": "2.17.0",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [