koishi-plugin-node-async-bot-all 2.24.2 → 2.24.4
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.d.ts +1 -0
- package/lib/index.js +16 -6
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -854,14 +854,23 @@ async function getMsg(ctx, session) {
|
|
|
854
854
|
__name(getMsg, "getMsg");
|
|
855
855
|
async function getNewsMsg(ctx, type) {
|
|
856
856
|
const log = ctx.logger("getNewsMsg");
|
|
857
|
-
const response = await request(
|
|
857
|
+
const response = await request(ctx.config.newsAPI, {}, ctx.config.timeout, log);
|
|
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
861
|
return { success: false, msg: "无可用新闻" };
|
|
862
862
|
}
|
|
863
|
-
const
|
|
864
|
-
|
|
863
|
+
const db = await ctx.database.get("botData", response.data.appnews.newsitems[0].gid);
|
|
864
|
+
let html = [];
|
|
865
|
+
if (db[0]) {
|
|
866
|
+
html[0] = db[0].data;
|
|
867
|
+
} else {
|
|
868
|
+
html = await readNewsFile(response.data, log);
|
|
869
|
+
if (html[1]) return { success: false, msg: `渲染图片失败` };
|
|
870
|
+
await ctx.database.upsert("botData", [
|
|
871
|
+
{ id: response.data.appnews.newsitems[0].gid, data: html[0] }
|
|
872
|
+
]);
|
|
873
|
+
}
|
|
865
874
|
const page = await ctx.puppeteer.page();
|
|
866
875
|
try {
|
|
867
876
|
await page.setViewport({
|
|
@@ -898,7 +907,7 @@ async function getNewsMsg(ctx, type) {
|
|
|
898
907
|
__name(getNewsMsg, "getNewsMsg");
|
|
899
908
|
|
|
900
909
|
// package.json
|
|
901
|
-
var version = "2.24.
|
|
910
|
+
var version = "2.24.4";
|
|
902
911
|
|
|
903
912
|
// src/index.ts
|
|
904
913
|
var inject = ["database", "installer", "puppeteer", "cron"];
|
|
@@ -941,7 +950,8 @@ var Config = import_koishi3.Schema.intersect([
|
|
|
941
950
|
qqAPI: import_koishi3.Schema.string().default("https://uapis.cn/api/v1/social/qq/userinfo").description("获取 QQ 信息 API")
|
|
942
951
|
}).description("获取 QQ 信息"),
|
|
943
952
|
import_koishi3.Schema.object({
|
|
944
|
-
slNews: import_koishi3.Schema.array(String).default([""]).description("{platform}:{channelId}")
|
|
953
|
+
slNews: import_koishi3.Schema.array(String).default([""]).description("{platform}:{channelId}"),
|
|
954
|
+
newsAPI: import_koishi3.Schema.string().default("https://api.steampowered.com/ISteamNews/GetNewsForApp/v2/?appid=700330&count=1").description("新闻 API")
|
|
945
955
|
}).description("SL新闻列表"),
|
|
946
956
|
import_koishi3.Schema.object({
|
|
947
957
|
slTest: import_koishi3.Schema.array(import_koishi3.Schema.object({
|
|
@@ -987,7 +997,7 @@ ${import_koishi3.h.image(outMsg.data, "image/png")}`;
|
|
|
987
997
|
await ctx.broadcast(ctx.config.slNews, `${outMsg.msg}
|
|
988
998
|
${import_koishi3.h.image(outMsg.data, "image/png")}`);
|
|
989
999
|
} else {
|
|
990
|
-
if (outMsg.msg == "") return;
|
|
1000
|
+
if (outMsg.msg == "无可用新闻") return;
|
|
991
1001
|
await ctx.broadcast(ctx.config.slNews, outMsg.msg);
|
|
992
1002
|
}
|
|
993
1003
|
});
|