koishi-plugin-node-async-bot-all 2.24.8 → 2.24.10

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
@@ -73,7 +73,7 @@ export declare function centerServerTest(ctx: Context, session: Session): Promis
73
73
  export declare function getMeme(ctx: Context, session: Session, count: number): Promise<Number>;
74
74
  export declare function getCat(ctx: Context, session: Session): Promise<Number>;
75
75
  export declare function getQQInfo(ctx: Context, session: Session, qq: string): Promise<number>;
76
- export declare function getMsg(ctx: Context, session: Session): Promise<number>;
76
+ export declare function getMsg(ctx: Context, session: Session, inversion: boolean | undefined): Promise<number>;
77
77
  export declare function getNewsMsg(ctx: Context, type: number): Promise<{
78
78
  success: boolean;
79
79
  data?: Buffer;
package/lib/fun.d.ts CHANGED
@@ -37,7 +37,7 @@ export declare function getMsgCount(ctx: Context): Promise<Object>;
37
37
  export declare function random(type: number | undefined, data: any, data2?: any): number;
38
38
  export declare function request<T = any>(url: string, options?: RequestInit, timeout?: number, log?: any): Promise<HttpResponse<T>>;
39
39
  export declare function readUserCardFile(userInfo: APIUserInfo): Promise<string>;
40
- export declare function readUserMsgFile(userName: string, userAvatar: string, msg: string): Promise<string>;
40
+ export declare function readUserMsgFile(userName: string, userAvatar: string, msg: string, inversion: boolean | undefined): Promise<string>;
41
41
  export declare function queryA2S(host: string, log: any): Promise<serverInfo>;
42
42
  export declare function readNewsFile(info: APINews, log: any): Promise<string[]>;
43
43
  export declare function translateAPI(log: any, text: string): Promise<string>;
package/lib/index.js CHANGED
@@ -253,12 +253,19 @@ async function readUserCardFile(userInfo) {
253
253
  return card;
254
254
  }
255
255
  __name(readUserCardFile, "readUserCardFile");
256
- async function readUserMsgFile(userName, userAvatar, msg) {
256
+ async function readUserMsgFile(userName, userAvatar, msg, inversion) {
257
257
  let html;
258
258
  try {
259
259
  const aPath = import_path.default.resolve(__dirname, "..") + import_path.default.sep + "res" + import_path.default.sep + "userMsg.html";
260
260
  html = await import_fs.default.promises.readFile(aPath, "utf8");
261
- html = html.toString().replace("{userData.avatarUrl}", userAvatar).replace("{userData.username}", userName).replace("{userData.message}", msg);
261
+ html = html.toString().replace("{userData.avatarUrl}", userAvatar).replace("{userData.username}", userName).replace("{userData.message}", msg).replace(
262
+ /<at\s+(?:id=["']([^"']*)["']\s+name=["']([^"']*)["']|name=["']([^"']*)["']\s+id=["']([^"']*)["'])\s*\/?>/g,
263
+ (match, id1, name1, name2, id2) => {
264
+ const name3 = name1 || name2 || id1 || id2 || match;
265
+ return `@${name3}`;
266
+ }
267
+ );
268
+ if (inversion) html.replace("//// ", "");
262
269
  } catch (error) {
263
270
  html = error.message;
264
271
  }
@@ -372,6 +379,7 @@ async function getServer(ctx, session) {
372
379
  if (type == "a2s") {
373
380
  const info = await queryA2S(api, log);
374
381
  if (info.success) {
382
+ log.debug(info);
375
383
  const temp = {
376
384
  "count": count,
377
385
  "players": info.players,
@@ -402,6 +410,7 @@ async function getServer(ctx, session) {
402
410
  const host = api.split(":");
403
411
  const serverInfo = await slpInfo(log, host[0], Number(host[1]), ctx.config.timeout);
404
412
  if (serverInfo.success) {
413
+ log.debug(serverInfo);
405
414
  if (serverInfo.data.players.sample == null) {
406
415
  const temp = {
407
416
  "count": count,
@@ -566,6 +575,7 @@ async function getRandomWord(ctx, session) {
566
575
  }
567
576
  const response = await request(ctx.config.rwAPI + "?format=json", {}, ctx.config.timeout, log);
568
577
  if (response.success) {
578
+ log.debug(response.data);
569
579
  msg = {
570
580
  "time": time,
571
581
  "data": response.data.data,
@@ -602,7 +612,7 @@ async function getBlueArchive(ctx, session) {
602
612
  const vid = await session.send(session.text(".wait", { "quote": import_koishi2.h.quote(session.messageId), "time": time }));
603
613
  const ms = random(0, 0, 1500);
604
614
  const link = random(2, ctx.config.baAPI) + `?cacheBuster=${random(1, 1, 2147483647)}`;
605
- log.info(`Link: ${link}`);
615
+ log.debug(`Link: ${link}`);
606
616
  await (0, import_koishi2.sleep)(ms);
607
617
  const status2 = await session.send(session.text(".msg", { "quote": import_koishi2.h.quote(session.messageId), "image": import_koishi2.h.image(link) }));
608
618
  if (!status2) await session.send(session.text(".msg", { "quote": import_koishi2.h.quote(session.messageId), "image": import_koishi2.h.image(link) }));
@@ -628,6 +638,7 @@ async function centerServerTest(ctx, session) {
628
638
  });
629
639
  const response = await request("https://status.scpslgame.com/api/status-page/heartbeat/nw", {}, ctx.config.timeout, log);
630
640
  if (response.success) {
641
+ log.debug(response.data);
631
642
  for (const server of ctx.config.slTest) {
632
643
  const lastTime = response.data.heartbeatList[server.id].at(-1);
633
644
  if (lastTime) {
@@ -725,6 +736,7 @@ async function getCat(ctx, session) {
725
736
  const time = getHongKongTime();
726
737
  if (ctx.config.catAPI == void 0) {
727
738
  await session.send(session.text(".failed", { "quote": import_koishi2.h.quote(session.messageId), "data": "未指定 API", "time": time }));
739
+ log.warn("未指定 API");
728
740
  return 1;
729
741
  }
730
742
  const vid = await session.send(session.text(".wait", { "quote": import_koishi2.h.quote(session.messageId), "time": time }));
@@ -756,11 +768,13 @@ async function getQQInfo(ctx, session, qq) {
756
768
  const time = getHongKongTime();
757
769
  if (ctx.config.qqAPI == void 0) {
758
770
  await session.send(session.text(".failed", { "quote": import_koishi2.h.quote(session.messageId), "data": "未指定 API", "time": time }));
771
+ log.warn("未指定 API");
759
772
  return 1;
760
773
  }
761
774
  const response = await request(ctx.config.qqAPI + `?qq=${qq}`, {}, ctx.config.timeout, log);
762
775
  if (response.success) {
763
776
  const fullHtml = await readUserCardFile(response.data);
777
+ log.debug(fullHtml);
764
778
  const page = await ctx.puppeteer.page();
765
779
  try {
766
780
  await page.setViewport({
@@ -798,8 +812,8 @@ async function getQQInfo(ctx, session, qq) {
798
812
  return 0;
799
813
  }
800
814
  __name(getQQInfo, "getQQInfo");
801
- async function getMsg(ctx, session) {
802
- const log = ctx.logger("getQQInfo");
815
+ async function getMsg(ctx, session, inversion) {
816
+ const log = ctx.logger("getMsg");
803
817
  log.debug(`Got: {"form":"${session.platform}:${session.event.guild?.id}","user":"${session.event.user?.id}","timestamp":${session.event.timestamp},"messageId":"${session.event.message?.id}"}`);
804
818
  const time = getHongKongTime();
805
819
  if (!session.quote || !session.quote.user) {
@@ -809,6 +823,7 @@ async function getMsg(ctx, session) {
809
823
  }
810
824
  if (session.quote.user.id == session.event.selfId) {
811
825
  await session.send(session.text(".matroska", { "quote": import_koishi2.h.quote(session.messageId) }));
826
+ log.debug("套娃");
812
827
  return 1;
813
828
  }
814
829
  const user = await session.bot.getUser(session.quote.user.id, session.channelId);
@@ -820,7 +835,8 @@ async function getMsg(ctx, session) {
820
835
  return 1;
821
836
  }
822
837
  const page = await ctx.puppeteer.page();
823
- const html = await readUserMsgFile(user.name, user.avatar, msg.replace(/<at id=\{([^}]+)}\/>/g, "@{$1}"));
838
+ const html = await readUserMsgFile(user.name, user.avatar, msg, inversion);
839
+ log.debug(html);
824
840
  try {
825
841
  await page.setViewport({
826
842
  width: 450,
@@ -876,6 +892,7 @@ async function getNewsMsg(ctx, type) {
876
892
  { id: response.data.appnews.newsitems[0].gid, data: html[0] }
877
893
  ]);
878
894
  }
895
+ log.debug(html);
879
896
  const page = await ctx.puppeteer.page();
880
897
  try {
881
898
  await page.setViewport({
@@ -912,7 +929,7 @@ async function getNewsMsg(ctx, type) {
912
929
  __name(getNewsMsg, "getNewsMsg");
913
930
 
914
931
  // package.json
915
- var version = "2.24.8";
932
+ var version = "2.24.10";
916
933
 
917
934
  // src/index.ts
918
935
  var inject = ["database", "installer", "puppeteer", "cron"];
@@ -1061,8 +1078,8 @@ ${import_koishi3.h.image(outMsg.data, "image/png")}`);
1061
1078
  if (qq == void 0 || isNaN(Number(qq))) return session?.text(".command");
1062
1079
  await getQQInfo(ctx, session, qq);
1063
1080
  });
1064
- ctx.command("msg2img").alias("消息转图").alias("m").action(async ({ session }) => {
1065
- await getMsg(ctx, session);
1081
+ ctx.command("msg2img").option("inversion", "-i").alias("消息转图").alias("m").action(async ({ session, options }) => {
1082
+ await getMsg(ctx, session, options?.inversion);
1066
1083
  });
1067
1084
  }
1068
1085
  __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.24.8",
4
+ "version": "2.24.10",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [
@@ -28,7 +28,7 @@
28
28
  "url": "git+https://github.com/ccd2s/node-async-bot-all.git"
29
29
  },
30
30
  "devDependencies": {
31
- "@koishijs/client": "^5.30.4"
31
+ "@koishijs/client": "^5.30.11"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@koishijs/plugin-database-sqlite": "^4.6.0",
package/res/userMsg.html CHANGED
@@ -10,6 +10,7 @@
10
10
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
11
11
  background: transparent;
12
12
  padding: 20px; /* 给截图留一点边缘留白 */
13
+ //// transform: rotate(180deg); /* 顺时针旋转180° */
13
14
  }
14
15
 
15
16
  /* 核心容器 */