koishi-plugin-node-async-bot-all 2.24.1 → 2.24.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
@@ -76,7 +76,7 @@ export declare function getQQInfo(ctx: Context, session: Session, qq: string): P
76
76
  export declare function getMsg(ctx: Context, session: Session): Promise<number>;
77
77
  export declare function getNewsMsg(ctx: Context, type: number): Promise<{
78
78
  success: boolean;
79
- data: string;
80
- msg?: string;
79
+ data?: Buffer;
80
+ msg: string;
81
81
  }>;
82
82
  export {};
package/lib/index.js CHANGED
@@ -858,10 +858,10 @@ async function getNewsMsg(ctx, type) {
858
858
  if (response.success) {
859
859
  if ((await ctx.database.get("botData", "newsId"))[0]?.data == response.data.appnews.newsitems[0].gid && type != 1) {
860
860
  log.debug("无新闻");
861
- return { success: false, data: "" };
861
+ return { success: false, msg: "无可用新闻" };
862
862
  }
863
863
  const html = await readNewsFile(response.data, log);
864
- if (html[1]) return { success: false, data: `渲染图片失败` };
864
+ if (html[1]) return { success: false, msg: `渲染图片失败` };
865
865
  const page = await ctx.puppeteer.page();
866
866
  try {
867
867
  await page.setViewport({
@@ -884,21 +884,21 @@ async function getNewsMsg(ctx, type) {
884
884
  if (type == 0) await ctx.database.upsert("botData", [
885
885
  { id: "newsId", data: response.data.appnews.newsitems[0].gid }
886
886
  ]);
887
- return { success: true, data: Buffer.from(image).toString("base64"), msg: "NorthWood 发布了一个新闻(原文+机翻):" + response.data.appnews.newsitems[0].title };
887
+ return { success: true, data: image, msg: "NorthWood 发布了一个新闻(原文+机翻):" + response.data.appnews.newsitems[0].title };
888
888
  } catch (err) {
889
889
  log.error("图片渲染失败:", err);
890
- return { success: false, data: "图片渲染失败" };
890
+ return { success: false, msg: "图片渲染失败" };
891
891
  } finally {
892
892
  if (page && !page.isClosed()) await page.close();
893
893
  }
894
894
  } else {
895
- return { success: false, data: "请求 Steam API 失败" };
895
+ return { success: false, msg: "请求 Steam API 失败" };
896
896
  }
897
897
  }
898
898
  __name(getNewsMsg, "getNewsMsg");
899
899
 
900
900
  // package.json
901
- var version = "2.24.1";
901
+ var version = "2.24.2";
902
902
 
903
903
  // src/index.ts
904
904
  var inject = ["database", "installer", "puppeteer", "cron"];
@@ -967,13 +967,12 @@ function apply(ctx) {
967
967
  ctx.command("slnews").action(async () => {
968
968
  const log = ctx.logger("slnews");
969
969
  const outMsg = await getNewsMsg(ctx, 1);
970
- if (outMsg.success) {
970
+ if (outMsg.data) {
971
971
  return `${outMsg.msg}
972
- ${(0, import_koishi3.h)("image", { url: `data:image/jpg;base64,${outMsg.data}` })}`;
972
+ ${import_koishi3.h.image(outMsg.data, "image/png")}`;
973
973
  } else {
974
974
  log.warn(outMsg);
975
- if (outMsg.data == "") return "无可用新闻";
976
- return outMsg.data;
975
+ return outMsg.msg;
977
976
  }
978
977
  });
979
978
  ctx.cron("0 * * * *", async () => {
@@ -984,12 +983,12 @@ ${(0, import_koishi3.h)("image", { url: `data:image/jpg;base64,${outMsg.data}` }
984
983
  });
985
984
  ctx.on("node-async/news", async () => {
986
985
  const outMsg = await getNewsMsg(ctx, 0);
987
- if (outMsg.success) {
986
+ if (outMsg.data) {
988
987
  await ctx.broadcast(ctx.config.slNews, `${outMsg.msg}
989
- ${(0, import_koishi3.h)("image", { url: `data:image/jpg;base64,${outMsg.data}` })}`);
988
+ ${import_koishi3.h.image(outMsg.data, "image/png")}`);
990
989
  } else {
991
- if (outMsg.data == "") return;
992
- await ctx.broadcast(ctx.config.slNews, outMsg.data);
990
+ if (outMsg.msg == "") return;
991
+ await ctx.broadcast(ctx.config.slNews, outMsg.msg);
993
992
  }
994
993
  });
995
994
  ctx.command("cxGame").action(async ({ 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.24.1",
4
+ "version": "2.24.2",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [