koishi-plugin-node-async-bot-all 2.22.0 → 2.22.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/index.js +8 -9
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -816,7 +816,7 @@ async function getNewsMsg(ctx, type) {
|
|
|
816
816
|
const log = ctx.logger("getNewsMsg");
|
|
817
817
|
const response = await request("https://api.steampowered.com/ISteamNews/GetNewsForApp/v2/?appid=700330&count=1", {}, ctx.config.timeout, log);
|
|
818
818
|
if (response.success) {
|
|
819
|
-
if ((await ctx.database.get("botData", "newsId"))[0]?.data == response.data.appnews.newsitems[0].gid) {
|
|
819
|
+
if ((await ctx.database.get("botData", "newsId"))[0]?.data == response.data.appnews.newsitems[0].gid && type != 1) {
|
|
820
820
|
log.debug("无新闻");
|
|
821
821
|
return { success: false, data: "" };
|
|
822
822
|
}
|
|
@@ -843,7 +843,7 @@ async function getNewsMsg(ctx, type) {
|
|
|
843
843
|
if (type == 0) await ctx.database.upsert("botData", [
|
|
844
844
|
{ id: "newsId", data: response.data.appnews.newsitems[0].gid }
|
|
845
845
|
]);
|
|
846
|
-
return { success: true, data: Buffer.from(image).toString("base64"), msg: "
|
|
846
|
+
return { success: true, data: Buffer.from(image).toString("base64"), msg: "NorthWood 发布了一个新闻(原文英语):" + response.data.appnews.newsitems[0].title };
|
|
847
847
|
} catch (err) {
|
|
848
848
|
log.error("图片渲染失败:", err);
|
|
849
849
|
return { success: false, data: "图片渲染失败" };
|
|
@@ -857,7 +857,7 @@ async function getNewsMsg(ctx, type) {
|
|
|
857
857
|
__name(getNewsMsg, "getNewsMsg");
|
|
858
858
|
|
|
859
859
|
// package.json
|
|
860
|
-
var version = "2.22.
|
|
860
|
+
var version = "2.22.2";
|
|
861
861
|
|
|
862
862
|
// src/index.ts
|
|
863
863
|
var inject = ["database", "installer", "puppeteer", "cron"];
|
|
@@ -923,8 +923,8 @@ function apply(ctx) {
|
|
|
923
923
|
ctx.command("slnews", "手动触发slnews发送到当前会话").action(async ({ session }) => {
|
|
924
924
|
const outMsg = await getNewsMsg(ctx, 1);
|
|
925
925
|
if (outMsg.success) {
|
|
926
|
-
|
|
927
|
-
|
|
926
|
+
return `${outMsg.msg}
|
|
927
|
+
${(0, import_koishi3.h)("image", { url: `data:image/jpg;base64,${outMsg.data}` })}`;
|
|
928
928
|
} else {
|
|
929
929
|
if (outMsg.data == "") return "无可用新闻";
|
|
930
930
|
return outMsg.data;
|
|
@@ -933,15 +933,14 @@ function apply(ctx) {
|
|
|
933
933
|
ctx.cron("0 * * * *", async () => {
|
|
934
934
|
ctx.emit("node-async/news");
|
|
935
935
|
});
|
|
936
|
-
ctx.cron("
|
|
936
|
+
ctx.cron("18 * * * *", async () => {
|
|
937
937
|
ctx.emit("node-async/news");
|
|
938
938
|
});
|
|
939
939
|
ctx.on("node-async/news", async () => {
|
|
940
940
|
const outMsg = await getNewsMsg(ctx, 0);
|
|
941
941
|
if (outMsg.success) {
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
await ctx.broadcast(ctx.config.slNews, (0, import_koishi3.h)("image", { url: `data:image/jpg;base64,${outMsg.data}` }));
|
|
942
|
+
await ctx.broadcast(ctx.config.slNews, `${outMsg.msg}
|
|
943
|
+
${(0, import_koishi3.h)("image", { url: `data:image/jpg;base64,${outMsg.data}` })}`);
|
|
945
944
|
} else {
|
|
946
945
|
if (outMsg.data == "") return;
|
|
947
946
|
await ctx.broadcast(ctx.config.slNews, outMsg.data);
|