koishi-plugin-node-async-bot-all 2.5.1 → 2.6.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
@@ -4,3 +4,4 @@ export declare function getStatus(ctx: Context, session: Session): Promise<Objec
4
4
  export declare function getRandom(ctx: Context, session: Session, min: number, max: number): Promise<Object>;
5
5
  export declare function getInfo(ctx: Context, session: Session): Promise<Object>;
6
6
  export declare function getRW(ctx: Context, session: Session): Promise<Object>;
7
+ export declare function getBA(ctx: Context, session: Session): Promise<Number>;
package/lib/index.d.ts CHANGED
@@ -19,6 +19,7 @@ export interface Config {
19
19
  cxV2: Array<ConfigCxV2>;
20
20
  rwAPI: string;
21
21
  timeout: number;
22
+ baAPI: string[];
22
23
  }
23
24
  export declare const Config: Schema<Config>;
24
25
  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: { cx: { description: "查询服务器当前人数。", messages: { msg: "{time}{list}\n进服指南请在群公告中查看。", list: "【MC 服务器 {count}】\n➣ {version}:{players}\n➣ 玩家列表:{list}\n➣ 协议版本:{protocol}", listNoPlayer: "【MC 服务器 {count}】\n➣ {version}:{players}\n➣ 协议版本:{protocol}", listFailed: "【MC 服务器 {count}】\n➣ 查询失败:{data}\n➣ 请稍后重试。", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\n查询失败:{data}", timeout: "请求超时。", timeout2: "响应超时。", fewData: "服务端返回的数据过少。", close: "服务器已关闭。", error: "执行错误。", unknown: "未知错误。", 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}", failed1: "{time}\n获取失败(1)。", failed2: "{time}\n获取失败(2)。" } } } };
37
+ module2.exports = { commands: { cx: { description: "查询服务器当前人数。", messages: { msg: "{time}{list}\n进服指南请在群公告中查看。", list: "【MC 服务器 {count}】\n➣ {version}:{players}\n➣ 玩家列表:{list}\n➣ 协议版本:{protocol}", listNoPlayer: "【MC 服务器 {count}】\n➣ {version}:{players}\n➣ 协议版本:{protocol}", listFailed: "【MC 服务器 {count}】\n➣ 查询失败:{data}\n➣ 请稍后重试。", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\n查询失败:{data}", timeout: "请求超时。", timeout2: "响应超时。", fewData: "服务端返回的数据过少。", close: "服务器已关闭。", error: "执行错误。", unknown: "未知错误。", 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}", failed1: "{time}\n获取失败(1)。", failed2: "{time}\n获取失败(2)。" } }, randomba: { description: "随机BA图。", messages: { wait: "{time}\n请等待图片上传(可能较慢)。" } } } };
38
38
  }
39
39
  });
40
40
 
@@ -412,9 +412,24 @@ async function getRW(ctx, session) {
412
412
  return msg;
413
413
  }
414
414
  __name(getRW, "getRW");
415
+ async function getBA(ctx, session) {
416
+ const log = ctx.logger("ba");
417
+ log.info(`Got: {"form":"${session.event.guild?.id}","user":"${session.event.user?.id}","timestamp":${session.event.timestamp},"messageId":"${session.event.message?.id}"}`);
418
+ const random = new import_koishi.Random(() => Math.random());
419
+ const time = getHongKongTime();
420
+ const vid = await session.send(session.text(".wait", { "time": time }));
421
+ const ms = random.int(0, 1500);
422
+ const link = random.pick(ctx.config.baAPI) + `?cacheBuster=${random.real(1, 2147483647)}`;
423
+ log.info(`Link: ${link}`);
424
+ await (0, import_koishi.sleep)(ms);
425
+ await session.send(import_koishi.h.image(link));
426
+ await session.bot.deleteMessage(session.event.guild?.id, vid[0]);
427
+ return 0;
428
+ }
429
+ __name(getBA, "getBA");
415
430
 
416
431
  // package.json
417
- var version = "2.5.1";
432
+ var version = "2.6.0";
418
433
 
419
434
  // src/index.ts
420
435
  var inject = ["database"];
@@ -434,7 +449,10 @@ var Config = import_koishi2.Schema.intersect([
434
449
  }).description("查询"),
435
450
  import_koishi2.Schema.object({
436
451
  rwAPI: import_koishi2.Schema.string().default("https://api.tasaed.top/rw/").description("随机文本 API")
437
- }).description("随机文本")
452
+ }).description("随机文本"),
453
+ import_koishi2.Schema.object({
454
+ baAPI: import_koishi2.Schema.array(String).default(["https://rba.kanostar.top/portrait"]).description("随机BA图 API")
455
+ }).description("随机BA图")
438
456
  ]).description("基础设置");
439
457
  function apply(ctx) {
440
458
  ctx.i18n.define("zh-CN", require_zh_CN());
@@ -490,6 +508,9 @@ function apply(ctx) {
490
508
  return session?.text(".failed2", rw);
491
509
  }
492
510
  });
511
+ ctx.command("randomBA").action(async ({ session }) => {
512
+ await getBA(ctx, session);
513
+ });
493
514
  }
494
515
  __name(apply, "apply");
495
516
  // Annotate the CommonJS export names for ESM import in node:
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.5.1",
4
+ "version": "2.6.0",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "repository": {
27
27
  "type": "git",
28
- "url": "https://github.com/ccd2s/node-async-bot-all"
28
+ "url": "git+https://github.com/ccd2s/node-async-bot-all.git"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@koishijs/client": "^5.30.4"