koishi-plugin-node-async-bot-all 2.30.0 → 2.31.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 +0 -20
- package/lib/fun.d.ts +1 -3
- package/lib/index.d.ts +1 -9
- package/lib/index.js +2 -340
- package/package.json +1 -1
- package/res/userCard.html +0 -242
- package/res/userMsg.html +0 -110
package/lib/commands.d.ts
CHANGED
|
@@ -7,22 +7,6 @@ declare module 'koishi' {
|
|
|
7
7
|
puppeteer: Puppeteer;
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
export interface APIUserInfo {
|
|
11
|
-
qq: string;
|
|
12
|
-
nickname: string;
|
|
13
|
-
long_nick: string;
|
|
14
|
-
avatar_url: string;
|
|
15
|
-
age: number;
|
|
16
|
-
sex: string;
|
|
17
|
-
qid: string;
|
|
18
|
-
qq_level: number;
|
|
19
|
-
location: string;
|
|
20
|
-
email: string;
|
|
21
|
-
is_vip: boolean;
|
|
22
|
-
vip_level: number;
|
|
23
|
-
reg_time: string;
|
|
24
|
-
last_updated: string;
|
|
25
|
-
}
|
|
26
10
|
export interface APINews {
|
|
27
11
|
appnews: AppNews;
|
|
28
12
|
}
|
|
@@ -67,14 +51,10 @@ export declare function getInfo(ctx: Context, session: Session): Promise<Object>
|
|
|
67
51
|
export declare function getRandomWord(ctx: Context, session: Session): Promise<Object>;
|
|
68
52
|
export declare function getBlueArchive(ctx: Context, session: Session): Promise<Number>;
|
|
69
53
|
export declare function centerServerTest(ctx: Context, session: Session): Promise<number>;
|
|
70
|
-
export declare function getMeme(ctx: Context, session: Session, count: number): Promise<Number>;
|
|
71
54
|
export declare function getCat(ctx: Context, session: Session): Promise<Number>;
|
|
72
|
-
export declare function getQQInfo(ctx: Context, session: Session, qq: string): Promise<number>;
|
|
73
|
-
export declare function getMsg(ctx: Context, session: Session, inversion: boolean | undefined): Promise<number>;
|
|
74
55
|
export declare function getNewsMsg(ctx: Context, type: number): Promise<{
|
|
75
56
|
success: boolean;
|
|
76
57
|
data?: Buffer;
|
|
77
58
|
msg: string;
|
|
78
59
|
}>;
|
|
79
|
-
export declare function getUse(ctx: Context, session: Session, qq: string, desc: string | undefined): Promise<number>;
|
|
80
60
|
export {};
|
package/lib/fun.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context } from "koishi";
|
|
2
|
-
import { APINews
|
|
2
|
+
import { APINews } from "./commands.ts";
|
|
3
3
|
import { JavaStatusResponse } from 'minecraft-server-util';
|
|
4
4
|
export type HttpResponse<T> = {
|
|
5
5
|
success: true;
|
|
@@ -40,8 +40,6 @@ export declare function formatTimestampDiff(start: number, end: number): string;
|
|
|
40
40
|
export declare function getMsgCount(ctx: Context): Promise<Object>;
|
|
41
41
|
export declare function random(type: number | undefined, data: number | number[], data2?: number): number;
|
|
42
42
|
export declare function request<T = any>(url: string, options?: RequestInit, timeout?: number, log?: any): Promise<HttpResponse<T>>;
|
|
43
|
-
export declare function readUserCardFile(userInfo: APIUserInfo): Promise<string>;
|
|
44
|
-
export declare function readUserMsgFile(userName: string, userAvatar: string, msg: string, inversion: boolean | undefined, replyUserName: string | undefined, replyMsg: string | undefined): Promise<string>;
|
|
45
43
|
export declare function queryA2S(host: string, log: any): Promise<serverInfo>;
|
|
46
44
|
export declare function readNewsFile(info: APINews, log: any): Promise<string[]>;
|
|
47
45
|
export declare function translateAPI(log: any, text: string): Promise<string>;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context,
|
|
1
|
+
import { Context, Schema } from 'koishi';
|
|
2
2
|
export declare const inject: string[];
|
|
3
3
|
declare module 'koishi' {
|
|
4
4
|
interface Tables {
|
|
@@ -26,22 +26,14 @@ interface ConfigV3Server {
|
|
|
26
26
|
note: string;
|
|
27
27
|
type: "mc" | "a2s" | null | undefined;
|
|
28
28
|
}
|
|
29
|
-
interface CenterServerConfig {
|
|
30
|
-
id: string;
|
|
31
|
-
name: string;
|
|
32
|
-
}
|
|
33
29
|
export interface Config {
|
|
34
30
|
cxV3: Array<ConfigCxV3>;
|
|
35
31
|
rwAPI: string;
|
|
36
32
|
htmlTimeout: number;
|
|
37
33
|
timeout: number;
|
|
38
34
|
baAPI: string[];
|
|
39
|
-
slTest: CenterServerConfig[];
|
|
40
|
-
steamAPI: string;
|
|
41
35
|
newsAPI: string;
|
|
42
|
-
memesAPI: Dict<string>;
|
|
43
36
|
catAPI: string;
|
|
44
|
-
qqAPI: string;
|
|
45
37
|
slNews: string[];
|
|
46
38
|
specialMsg: string[];
|
|
47
39
|
reactionId: number[];
|
package/lib/index.js
CHANGED
|
@@ -229,50 +229,6 @@ async function request(url, options = {}, timeout = 8e3, log) {
|
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
__name(request, "request");
|
|
232
|
-
async function readUserCardFile(userInfo) {
|
|
233
|
-
let card;
|
|
234
|
-
try {
|
|
235
|
-
const aPath = import_path.default.resolve(__dirname, "..") + import_path.default.sep + "res" + import_path.default.sep + "userCard.html";
|
|
236
|
-
card = await import_fs.default.promises.readFile(aPath, "utf8");
|
|
237
|
-
let sex_so;
|
|
238
|
-
let sex;
|
|
239
|
-
if (userInfo.sex == "male") {
|
|
240
|
-
sex = "♂";
|
|
241
|
-
sex_so = "sex-male";
|
|
242
|
-
} else if (userInfo.sex == "female") {
|
|
243
|
-
sex = "♀";
|
|
244
|
-
sex_so = "sex-female";
|
|
245
|
-
} else {
|
|
246
|
-
sex = "猫娘";
|
|
247
|
-
sex_so = "sex-unknown";
|
|
248
|
-
}
|
|
249
|
-
card = card.toString().replace("{avatarUrl}", userInfo.avatar_url).replace("{nickname}", userInfo.nickname).replace("{sex}", sex).replace("{sex-so}", sex_so).replace("{age}", String(userInfo.age)).replace("{longNick}", userInfo.long_nick == "" ? "<无>" : `“ ${userInfo.long_nick} ”`).replace("{qq}", userInfo.qq).replace("{qqLevel}", String(userInfo.qq_level)).replace("{qid}", userInfo.qid == "" ? "<无>" : userInfo.qid).replace("{location}", userInfo.location == "" ? "<无>" : userInfo.location).replace("{email}", userInfo.email == "" ? "<无>" : userInfo.email).replace("{regTime}", userInfo.reg_time).replace("{lastUpdated}", userInfo.last_updated);
|
|
250
|
-
} catch (error) {
|
|
251
|
-
card = error.message;
|
|
252
|
-
}
|
|
253
|
-
return card;
|
|
254
|
-
}
|
|
255
|
-
__name(readUserCardFile, "readUserCardFile");
|
|
256
|
-
async function readUserMsgFile(userName, userAvatar, msg, inversion, replyUserName, replyMsg) {
|
|
257
|
-
let html;
|
|
258
|
-
try {
|
|
259
|
-
const aPath = import_path.default.resolve(__dirname, "..") + import_path.default.sep + "res" + import_path.default.sep + "userMsg.html";
|
|
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).replace("{replyData.username}", replyUserName).replace("{replyData.message}", replyMsg).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
|
-
).replace('<at type="all"/>', "@全体成员");
|
|
268
|
-
if (inversion) html = html.replace("//// ", "");
|
|
269
|
-
if (replyUserName != void 0) html = html.replace("/**/", "//// ");
|
|
270
|
-
} catch (error) {
|
|
271
|
-
html = error.message;
|
|
272
|
-
}
|
|
273
|
-
return html;
|
|
274
|
-
}
|
|
275
|
-
__name(readUserMsgFile, "readUserMsgFile");
|
|
276
232
|
async function queryA2S(host, log) {
|
|
277
233
|
try {
|
|
278
234
|
const playerResponse = await (0, import_steam_server_query.queryGameServerInfo)(host);
|
|
@@ -644,126 +600,6 @@ async function getBlueArchive(ctx, session) {
|
|
|
644
600
|
return 0;
|
|
645
601
|
}
|
|
646
602
|
__name(getBlueArchive, "getBlueArchive");
|
|
647
|
-
async function centerServerTest(ctx, session) {
|
|
648
|
-
const log = ctx.logger("centerServerTest");
|
|
649
|
-
log.debug(`Got: {"form":"${session.platform}:${session.event.guild?.id}","user":"${session.event.user?.id}","timestamp":${session.event.timestamp},"messageId":"${session.event.message?.id}"}`);
|
|
650
|
-
const time = getHongKongTime();
|
|
651
|
-
let msg;
|
|
652
|
-
let list = "";
|
|
653
|
-
const timeFormatter = new Intl.DateTimeFormat("zh-CN", {
|
|
654
|
-
timeZone: "Asia/Shanghai",
|
|
655
|
-
year: "numeric",
|
|
656
|
-
month: "2-digit",
|
|
657
|
-
day: "2-digit",
|
|
658
|
-
hour: "2-digit",
|
|
659
|
-
minute: "2-digit",
|
|
660
|
-
second: "2-digit",
|
|
661
|
-
hour12: false
|
|
662
|
-
});
|
|
663
|
-
const response = await request("https://status.scpslgame.com/api/status-page/heartbeat/nw", {}, ctx.config.timeout, log);
|
|
664
|
-
if (response.success) {
|
|
665
|
-
log.debug(response.data);
|
|
666
|
-
for (const server of ctx.config.slTest) {
|
|
667
|
-
const lastTime = response.data.heartbeatList[server.id].at(-1);
|
|
668
|
-
if (lastTime) {
|
|
669
|
-
const uptime24 = (response.data.uptimeList[server.id + "_24"] * 100).toFixed(2) + "%";
|
|
670
|
-
const status2 = lastTime?.status == 1 ? session.text(".statusLive") : session.text(".statusDie");
|
|
671
|
-
const testTime = timeFormatter.format(/* @__PURE__ */ new Date(lastTime?.time.replace(" ", "T") + "Z"));
|
|
672
|
-
list = list + "\n" + session.text(session?.bot.adapterName == "qq" ? ".list-md" : ".list", {
|
|
673
|
-
"name": server.name,
|
|
674
|
-
"status": status2,
|
|
675
|
-
"uptime": uptime24,
|
|
676
|
-
"time": testTime
|
|
677
|
-
});
|
|
678
|
-
} else {
|
|
679
|
-
list = list + "\n" + session.text(session?.bot.adapterName == "qq" ? ".listFailed-md" : ".listFailed", {
|
|
680
|
-
"name": server.name,
|
|
681
|
-
"data": session.text(".dataFail")
|
|
682
|
-
});
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
msg = {
|
|
686
|
-
"data": { "list": list, "time": time },
|
|
687
|
-
"success": ".msg"
|
|
688
|
-
};
|
|
689
|
-
await session?.send(session?.bot.adapterName == "qq" ? (0, import_koishi2.h)("qq:markdown", {
|
|
690
|
-
content: session?.text(".msg-md", msg.data)
|
|
691
|
-
}) : session?.text(".msg", msg.data));
|
|
692
|
-
log.debug("Sent:");
|
|
693
|
-
log.debug(msg);
|
|
694
|
-
return 0;
|
|
695
|
-
} else {
|
|
696
|
-
let err;
|
|
697
|
-
if (response.code) {
|
|
698
|
-
err = response.isJson ? response.error["data"] : response.error;
|
|
699
|
-
} else {
|
|
700
|
-
err = response.error.message;
|
|
701
|
-
}
|
|
702
|
-
msg = {
|
|
703
|
-
"data": { "error": "查看失败:" + err, "time": time },
|
|
704
|
-
"success": ".failed"
|
|
705
|
-
};
|
|
706
|
-
await session?.send(session?.bot.adapterName == "qq" ? (0, import_koishi2.h)("qq:markdown", {
|
|
707
|
-
content: session?.text("failed-md", msg.data)
|
|
708
|
-
}) : session?.text("failed", msg.data));
|
|
709
|
-
log.warn("Sent:");
|
|
710
|
-
log.warn(msg);
|
|
711
|
-
return 1;
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
__name(centerServerTest, "centerServerTest");
|
|
715
|
-
async function getMeme(ctx, session, count) {
|
|
716
|
-
const log = ctx.logger("getMeme");
|
|
717
|
-
log.debug(`Got: {"form":"${session.platform}:${session.event.guild?.id}","user":"${session.event.user?.id}","timestamp":${session.event.timestamp},"messageId":"${session.event.message?.id}"}`);
|
|
718
|
-
let msg;
|
|
719
|
-
const time = getHongKongTime();
|
|
720
|
-
if (ctx.config.memesAPI[`${session.event.guild?.id}`] == void 0) {
|
|
721
|
-
msg = {
|
|
722
|
-
"time": time,
|
|
723
|
-
"quote": import_koishi2.h.quote(session.messageId),
|
|
724
|
-
"error": "此指令不允许在本群使用。"
|
|
725
|
-
};
|
|
726
|
-
log.warn("Sent:");
|
|
727
|
-
log.warn(msg);
|
|
728
|
-
await session?.send(session?.bot.adapterName == "qq" ? (0, import_koishi2.h)("qq:markdown", {
|
|
729
|
-
content: session?.text("failed-md", msg)
|
|
730
|
-
}) : session?.text("failed", msg));
|
|
731
|
-
return 0;
|
|
732
|
-
}
|
|
733
|
-
const api = count ? ctx.config.memesAPI[`${session.event.guild?.id}`] + `&type=1&count=${count}` : ctx.config.memesAPI[`${session.event.guild?.id}`];
|
|
734
|
-
const response = await request(api, {}, ctx.config.timeout, log);
|
|
735
|
-
if (response.success) {
|
|
736
|
-
msg = {
|
|
737
|
-
"time": time,
|
|
738
|
-
"title": response.data.data.title,
|
|
739
|
-
"image": import_koishi2.h.image(response.data.data.image),
|
|
740
|
-
"quote": import_koishi2.h.quote(session.messageId)
|
|
741
|
-
};
|
|
742
|
-
log.debug("Sent:");
|
|
743
|
-
log.debug(msg);
|
|
744
|
-
await session?.send(session?.bot.adapterName == "qq" ? session?.text(".msg-qq", msg) : session?.text(".msg", msg));
|
|
745
|
-
return 0;
|
|
746
|
-
} else {
|
|
747
|
-
let err;
|
|
748
|
-
if (response.code) {
|
|
749
|
-
err = response.isJson ? response.error["data"] : response.error;
|
|
750
|
-
} else {
|
|
751
|
-
err = response.error.message;
|
|
752
|
-
}
|
|
753
|
-
msg = {
|
|
754
|
-
"time": time,
|
|
755
|
-
"error": "获取失败:" + err,
|
|
756
|
-
"quote": import_koishi2.h.quote(session.messageId)
|
|
757
|
-
};
|
|
758
|
-
log.warn("Sent:");
|
|
759
|
-
log.warn(msg);
|
|
760
|
-
await session?.send(session?.bot.adapterName == "qq" ? (0, import_koishi2.h)("qq:markdown", {
|
|
761
|
-
content: session?.text("failed-md", msg)
|
|
762
|
-
}) : session?.text("failed", msg));
|
|
763
|
-
return 0;
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
__name(getMeme, "getMeme");
|
|
767
603
|
async function getCat(ctx, session) {
|
|
768
604
|
const log = ctx.logger("cat");
|
|
769
605
|
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,120 +640,6 @@ async function getCat(ctx, session) {
|
|
|
804
640
|
return 0;
|
|
805
641
|
}
|
|
806
642
|
__name(getCat, "getCat");
|
|
807
|
-
async function getQQInfo(ctx, session, qq) {
|
|
808
|
-
const log = ctx.logger("getQQInfo");
|
|
809
|
-
log.debug(`Got: {"form":"${session.platform}:${session.event.guild?.id}","user":"${session.event.user?.id}","timestamp":${session.event.timestamp},"messageId":"${session.event.message?.id}"}`);
|
|
810
|
-
const time = getHongKongTime();
|
|
811
|
-
if (ctx.config.qqAPI == void 0) {
|
|
812
|
-
await session.send(session.text(".failed", { "quote": import_koishi2.h.quote(session.messageId), "data": "未指定 API", "time": time }));
|
|
813
|
-
log.warn("未指定 API");
|
|
814
|
-
return 1;
|
|
815
|
-
}
|
|
816
|
-
const response = await request(ctx.config.qqAPI + `?qq=${qq}`, {}, ctx.config.timeout, log);
|
|
817
|
-
if (response.success) {
|
|
818
|
-
const fullHtml = await readUserCardFile(response.data);
|
|
819
|
-
log.debug(fullHtml);
|
|
820
|
-
const page = await ctx.puppeteer.page();
|
|
821
|
-
try {
|
|
822
|
-
await page.setViewport({
|
|
823
|
-
width: 450,
|
|
824
|
-
height: 650,
|
|
825
|
-
deviceScaleFactor: 2
|
|
826
|
-
});
|
|
827
|
-
await page.setContent(fullHtml, { timeout: ctx.config.htmlTimeout, waitUntil: "networkidle0" });
|
|
828
|
-
const { width, height } = await page.evaluate(() => ({
|
|
829
|
-
width: document.body.scrollWidth,
|
|
830
|
-
height: document.body.scrollHeight
|
|
831
|
-
}));
|
|
832
|
-
await page.setViewport({ width, height, deviceScaleFactor: 2 });
|
|
833
|
-
const image = await page.screenshot({ type: "png", omitBackground: true });
|
|
834
|
-
await session.send(session.text(".msg", { "quote": import_koishi2.h.quote(session.messageId), "image": import_koishi2.h.image(image, "image/png") }));
|
|
835
|
-
} catch (err) {
|
|
836
|
-
await session.send(session.text(".failed", { "quote": import_koishi2.h.quote(session.messageId), "time": time, "data": "图片渲染失败" }));
|
|
837
|
-
log.error("图片渲染失败:", err);
|
|
838
|
-
return 1;
|
|
839
|
-
} finally {
|
|
840
|
-
if (page && !page.isClosed()) await page.close();
|
|
841
|
-
}
|
|
842
|
-
log.debug("Sent: Image");
|
|
843
|
-
} else {
|
|
844
|
-
if (response.code) {
|
|
845
|
-
await session.send(session.text(".failed", { "quote": import_koishi2.h.quote(session.messageId), "data": response.isJson ? response.error["error"] : response.error, "time": time }));
|
|
846
|
-
log.warn("Sent:");
|
|
847
|
-
log.warn(response.error);
|
|
848
|
-
} else {
|
|
849
|
-
await session.send(session.text(".failed", { "quote": import_koishi2.h.quote(session.messageId), "data": response.error.message, "time": time }));
|
|
850
|
-
log.warn("Sent:");
|
|
851
|
-
log.warn(response.error);
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
return 0;
|
|
855
|
-
}
|
|
856
|
-
__name(getQQInfo, "getQQInfo");
|
|
857
|
-
async function getMsg(ctx, session, inversion) {
|
|
858
|
-
const log = ctx.logger("getMsg");
|
|
859
|
-
log.debug(`Got: {"form":"${session.platform}:${session.event.guild?.id}","user":"${session.event.user?.id}","timestamp":${session.event.timestamp},"messageId":"${session.event.message?.id}"}`);
|
|
860
|
-
log.debug(`inversion: ${inversion}`);
|
|
861
|
-
const time = getHongKongTime();
|
|
862
|
-
if (!session.quote || !session.quote.user) {
|
|
863
|
-
await session.send(session.text(".null"));
|
|
864
|
-
log.warn("未引用任何信息");
|
|
865
|
-
return 1;
|
|
866
|
-
}
|
|
867
|
-
if (session.quote.user.id == session.event.selfId) {
|
|
868
|
-
await session.send(session.text(".matroska", { "quote": import_koishi2.h.quote(session.messageId) }));
|
|
869
|
-
log.debug("套娃");
|
|
870
|
-
return 1;
|
|
871
|
-
}
|
|
872
|
-
const user = await session.bot.getUser(session.quote.user.id, session.channelId);
|
|
873
|
-
const msg = session.quote.content;
|
|
874
|
-
const quoteMsg = session.quote.quote?.content;
|
|
875
|
-
const quoteUser = session.quote.quote?.user?.name;
|
|
876
|
-
log.debug(msg);
|
|
877
|
-
if (!user.name || !user.avatar) {
|
|
878
|
-
await session.send(session.text(".failed", { "quote": import_koishi2.h.quote(session.messageId), "time": time, "data": "获取用户信息失败。" }));
|
|
879
|
-
log.error("获取用户信息失败");
|
|
880
|
-
return 1;
|
|
881
|
-
}
|
|
882
|
-
const page = await ctx.puppeteer.page();
|
|
883
|
-
const html = await readUserMsgFile(user.name, user.avatar, msg, inversion, quoteUser, quoteMsg);
|
|
884
|
-
log.debug(html);
|
|
885
|
-
try {
|
|
886
|
-
await page.setViewport({
|
|
887
|
-
width: 450,
|
|
888
|
-
height: 1,
|
|
889
|
-
deviceScaleFactor: 2
|
|
890
|
-
});
|
|
891
|
-
await page.setContent(html, { timeout: ctx.config.htmlTimeout, waitUntil: "networkidle0" });
|
|
892
|
-
const { width, height } = await page.evaluate(() => ({
|
|
893
|
-
width: document.body.scrollWidth + 50,
|
|
894
|
-
height: document.body.scrollHeight
|
|
895
|
-
}));
|
|
896
|
-
await page.setViewport({ width, height, deviceScaleFactor: 2 });
|
|
897
|
-
const element = await page.$("#target-element");
|
|
898
|
-
if (element) {
|
|
899
|
-
const image = await element.screenshot({
|
|
900
|
-
type: "png",
|
|
901
|
-
omitBackground: true
|
|
902
|
-
// 使得 CSS 中未定义的背景部分透明
|
|
903
|
-
});
|
|
904
|
-
await session.send(session.text(".msg", { "quote": import_koishi2.h.quote(session.messageId), "image": import_koishi2.h.image(image, "image/png") }));
|
|
905
|
-
log.debug("Sent: Image");
|
|
906
|
-
} else {
|
|
907
|
-
await session.send(session.text(".failed", { "quote": import_koishi2.h.quote(session.messageId), "time": time, "data": "未找到目标元素。" }));
|
|
908
|
-
log.error("未找到目标元素");
|
|
909
|
-
return 1;
|
|
910
|
-
}
|
|
911
|
-
} catch (err) {
|
|
912
|
-
await session.send(session.text(".failed", { "quote": import_koishi2.h.quote(session.messageId), "time": time, "data": "图片渲染失败" }));
|
|
913
|
-
log.error("图片渲染失败:", err);
|
|
914
|
-
return 1;
|
|
915
|
-
} finally {
|
|
916
|
-
if (page && !page.isClosed()) await page.close();
|
|
917
|
-
}
|
|
918
|
-
return 0;
|
|
919
|
-
}
|
|
920
|
-
__name(getMsg, "getMsg");
|
|
921
643
|
async function getNewsMsg(ctx, type) {
|
|
922
644
|
const log = ctx.logger("getNewsMsg");
|
|
923
645
|
const response = await request(ctx.config.newsAPI, {}, ctx.config.timeout, log);
|
|
@@ -972,16 +694,9 @@ async function getNewsMsg(ctx, type) {
|
|
|
972
694
|
}
|
|
973
695
|
}
|
|
974
696
|
__name(getNewsMsg, "getNewsMsg");
|
|
975
|
-
async function getUse(ctx, session, qq, desc) {
|
|
976
|
-
const log = ctx.logger("getUse");
|
|
977
|
-
log.debug(`Got: {"form":"${session.platform}:${session.event.guild?.id}","user":"${session.event.user?.id}","timestamp":${session.event.timestamp},"messageId":"${session.event.message?.id}"}`);
|
|
978
|
-
await session.send(session.text(".msg", { "at": import_koishi2.h.at(session.event.user?.id), "at2": import_koishi2.h.at(qq), "desc": desc ?? "使用" }));
|
|
979
|
-
return 0;
|
|
980
|
-
}
|
|
981
|
-
__name(getUse, "getUse");
|
|
982
697
|
|
|
983
698
|
// package.json
|
|
984
|
-
var version = "2.
|
|
699
|
+
var version = "2.31.0";
|
|
985
700
|
|
|
986
701
|
// src/index.ts
|
|
987
702
|
var inject = ["database", "installer", "puppeteer", "cron"];
|
|
@@ -1012,18 +727,9 @@ var Config = import_koishi3.Schema.intersect([
|
|
|
1012
727
|
import_koishi3.Schema.object({
|
|
1013
728
|
baAPI: import_koishi3.Schema.array(String).default(["https://rba.kanostar.top/portrait"]).description("随机BA图 API")
|
|
1014
729
|
}).description("随机BA图"),
|
|
1015
|
-
import_koishi3.Schema.object({
|
|
1016
|
-
steamAPI: import_koishi3.Schema.string().default("https://api.tasaed.top/get/steamid/").description("转换 Steam ID API")
|
|
1017
|
-
}).description("转换 Steam ID"),
|
|
1018
|
-
import_koishi3.Schema.object({
|
|
1019
|
-
memesAPI: import_koishi3.Schema.dict(String).role("table").description("群友 meme API")
|
|
1020
|
-
}).description("群友 meme"),
|
|
1021
730
|
import_koishi3.Schema.object({
|
|
1022
731
|
catAPI: import_koishi3.Schema.string().default("https://api.thecatapi.com/v1/images/search").description("随机猫猫图 API")
|
|
1023
732
|
}).description("随机猫猫图"),
|
|
1024
|
-
import_koishi3.Schema.object({
|
|
1025
|
-
qqAPI: import_koishi3.Schema.string().default("https://uapis.cn/api/v1/social/qq/userinfo").description("获取 QQ 信息 API")
|
|
1026
|
-
}).description("获取 QQ 信息"),
|
|
1027
733
|
import_koishi3.Schema.object({
|
|
1028
734
|
slNews: import_koishi3.Schema.array(String).default([""]).description("{platform}:{channelId}"),
|
|
1029
735
|
newsAPI: import_koishi3.Schema.string().default("https://api.steampowered.com/ISteamNews/GetNewsForApp/v2/?appid=700330&count=1").description("新闻 API")
|
|
@@ -1031,13 +737,7 @@ var Config = import_koishi3.Schema.intersect([
|
|
|
1031
737
|
import_koishi3.Schema.object({
|
|
1032
738
|
specialMsg: import_koishi3.Schema.array(String).default([]).description("特殊消息"),
|
|
1033
739
|
reactionId: import_koishi3.Schema.array(Number).default([]).description("回应表情 ID")
|
|
1034
|
-
}).description("特殊消息回应")
|
|
1035
|
-
import_koishi3.Schema.object({
|
|
1036
|
-
slTest: import_koishi3.Schema.array(import_koishi3.Schema.object({
|
|
1037
|
-
id: import_koishi3.Schema.string().description("服务器 ID"),
|
|
1038
|
-
name: import_koishi3.Schema.string().description("服务器 名称")
|
|
1039
|
-
})).default([{ "id": "1", "name": "中心 鲁贝 1" }, { "id": "19", "name": "中心 斯特拉斯堡 1" }, { "id": "3", "name": "Steam 认证 API" }]).description("测试中心服务器")
|
|
1040
|
-
}).description("测试中心服务器")
|
|
740
|
+
}).description("特殊消息回应")
|
|
1041
741
|
]).description("基础设置");
|
|
1042
742
|
async function startReaction(session) {
|
|
1043
743
|
if (session.bot.createReaction) await session.bot.createReaction(session.channelId, session.messageId, `face|424`);
|
|
@@ -1169,49 +869,11 @@ ${import_koishi3.h.image(outMsg.data, "image/png")}`);
|
|
|
1169
869
|
await getBlueArchive(ctx, session);
|
|
1170
870
|
await endReaction(session);
|
|
1171
871
|
});
|
|
1172
|
-
na.subcommand("centerServerTest").alias("测测中心服务器").action(async ({ session }) => {
|
|
1173
|
-
await startReaction(session);
|
|
1174
|
-
const ct = await centerServerTest(ctx, session);
|
|
1175
|
-
if (ct == 0) {
|
|
1176
|
-
await endReaction(session);
|
|
1177
|
-
} else {
|
|
1178
|
-
await endReactionFailed(session);
|
|
1179
|
-
}
|
|
1180
|
-
});
|
|
1181
|
-
na.subcommand("meme [序号:posint]").alias("memes").action(async ({ session }, count) => {
|
|
1182
|
-
await startReaction(session);
|
|
1183
|
-
await getMeme(ctx, session, count);
|
|
1184
|
-
await endReaction(session);
|
|
1185
|
-
});
|
|
1186
872
|
na.subcommand("randomCat").alias("随机猫猫图").alias("随机猫猫").action(async ({ session }) => {
|
|
1187
873
|
await startReaction(session);
|
|
1188
874
|
await getCat(ctx, session);
|
|
1189
875
|
await endReaction(session);
|
|
1190
876
|
});
|
|
1191
|
-
na.subcommand("getQQInfo <QQ号:string>").alias("获取QQ信息").action(async ({ session }, qq) => {
|
|
1192
|
-
await startReaction(session);
|
|
1193
|
-
if (qq == void 0 || isNaN(Number(qq))) {
|
|
1194
|
-
await endReactionFailed(session);
|
|
1195
|
-
return session?.text(".command");
|
|
1196
|
-
}
|
|
1197
|
-
await getQQInfo(ctx, session, qq);
|
|
1198
|
-
await endReaction(session);
|
|
1199
|
-
});
|
|
1200
|
-
na.subcommand("msg2img").option("inversion", "-i").alias("消息转图").alias("m").action(async ({ session, options }) => {
|
|
1201
|
-
await startReaction(session);
|
|
1202
|
-
await getMsg(ctx, session, options?.inversion);
|
|
1203
|
-
await endReaction(session);
|
|
1204
|
-
});
|
|
1205
|
-
na.subcommand("use <user:user> [方法:string]").alias("u").action(async ({ session }, user, desc) => {
|
|
1206
|
-
await startReaction(session);
|
|
1207
|
-
const qq = user?.split(":")?.[1];
|
|
1208
|
-
if (qq == void 0 || isNaN(Number(qq))) {
|
|
1209
|
-
await endReactionFailed(session);
|
|
1210
|
-
return session?.text(".command");
|
|
1211
|
-
}
|
|
1212
|
-
await getUse(ctx, session, qq, desc);
|
|
1213
|
-
await endReaction(session);
|
|
1214
|
-
});
|
|
1215
877
|
}
|
|
1216
878
|
__name(apply, "apply");
|
|
1217
879
|
// Annotate the CommonJS export names for ESM import in node:
|
package/package.json
CHANGED
package/res/userCard.html
DELETED
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="zh-CN">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>UserCard</title>
|
|
7
|
-
<style>
|
|
8
|
-
/* 全局重置 */
|
|
9
|
-
* {
|
|
10
|
-
box-sizing: border-box;
|
|
11
|
-
margin: 0;
|
|
12
|
-
padding: 0;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
body {
|
|
16
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
17
|
-
background-color: #f0f2f5;
|
|
18
|
-
display: flex;
|
|
19
|
-
justify-content: center;
|
|
20
|
-
align-items: flex-start; /* 顶部对齐 */
|
|
21
|
-
min-height: 100vh;
|
|
22
|
-
padding: 20px;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/* 卡片容器 */
|
|
26
|
-
.card {
|
|
27
|
-
width: 400px; /* 固定宽度,配合 puppeteer 视口 */
|
|
28
|
-
background: #ffffff;
|
|
29
|
-
border-radius: 16px;
|
|
30
|
-
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
|
|
31
|
-
overflow: hidden;
|
|
32
|
-
position: relative;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/* 顶部背景图/颜色 */
|
|
36
|
-
.card-header-bg {
|
|
37
|
-
height: 120px;
|
|
38
|
-
background: linear-gradient(135deg, #00C6FF 0%, #0072FF 100%);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/* 个人信息主要区域 */
|
|
42
|
-
.profile-main {
|
|
43
|
-
padding: 0 24px;
|
|
44
|
-
margin-top: -50px; /* 让头像上浮 */
|
|
45
|
-
text-align: center;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/* 头像容器 */
|
|
49
|
-
.avatar-container {
|
|
50
|
-
position: relative;
|
|
51
|
-
display: inline-block;
|
|
52
|
-
padding: 4px;
|
|
53
|
-
background: #fff;
|
|
54
|
-
border-radius: 50%;
|
|
55
|
-
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.avatar {
|
|
59
|
-
width: 90px;
|
|
60
|
-
height: 90px;
|
|
61
|
-
border-radius: 50%;
|
|
62
|
-
object-fit: cover;
|
|
63
|
-
display: block;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/* VIP 徽章 */
|
|
67
|
-
.vip-badge {
|
|
68
|
-
position: absolute;
|
|
69
|
-
bottom: 5px;
|
|
70
|
-
right: 5px;
|
|
71
|
-
background: #FFD700;
|
|
72
|
-
color: #d63031;
|
|
73
|
-
font-size: 10px;
|
|
74
|
-
font-weight: bold;
|
|
75
|
-
padding: 2px 6px;
|
|
76
|
-
border-radius: 8px;
|
|
77
|
-
border: 2px solid #fff;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.nickname-row {
|
|
81
|
-
margin-top: 12px;
|
|
82
|
-
display: flex;
|
|
83
|
-
align-items: center;
|
|
84
|
-
justify-content: center;
|
|
85
|
-
gap: 8px;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.nickname {
|
|
89
|
-
font-size: 22px;
|
|
90
|
-
font-weight: 700;
|
|
91
|
-
color: #333;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/* 性别图标 */
|
|
95
|
-
.sex-icon {
|
|
96
|
-
font-size: 14px;
|
|
97
|
-
padding: 2px 6px;
|
|
98
|
-
border-radius: 4px;
|
|
99
|
-
color: white;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
.sex-male {
|
|
103
|
-
background-color: #007bff;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.sex-female {
|
|
107
|
-
background-color: #ff6b81;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.sex-unknown {
|
|
111
|
-
background-color: #ff6be1;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
.long-nick {
|
|
115
|
-
margin-top: 8px;
|
|
116
|
-
color: #666;
|
|
117
|
-
font-size: 14px;
|
|
118
|
-
font-style: italic;
|
|
119
|
-
margin-bottom: 24px;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/* 详细信息列表 */
|
|
123
|
-
.info-list {
|
|
124
|
-
padding: 0 24px 24px 24px;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.info-item {
|
|
128
|
-
display: flex;
|
|
129
|
-
justify-content: space-between;
|
|
130
|
-
padding: 12px 0;
|
|
131
|
-
border-bottom: 1px solid #f0f0f0;
|
|
132
|
-
font-size: 14px;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
.info-item:last-child {
|
|
136
|
-
border-bottom: none;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
.label {
|
|
140
|
-
color: #888;
|
|
141
|
-
font-weight: 500;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.value {
|
|
145
|
-
color: #333;
|
|
146
|
-
font-weight: 600;
|
|
147
|
-
text-align: right;
|
|
148
|
-
max-width: 220px;
|
|
149
|
-
white-space: nowrap;
|
|
150
|
-
overflow: hidden;
|
|
151
|
-
text-overflow: ellipsis;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/* 标签样式 (如 VIP 等级) */
|
|
155
|
-
.tag {
|
|
156
|
-
display: inline-block;
|
|
157
|
-
padding: 2px 8px;
|
|
158
|
-
border-radius: 12px;
|
|
159
|
-
font-size: 12px;
|
|
160
|
-
margin-left: 5px;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
.tag-vip {
|
|
164
|
-
background-color: #fff3cd;
|
|
165
|
-
color: #856404;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
.tag-level {
|
|
169
|
-
background-color: #e2e3e5;
|
|
170
|
-
color: #383d41;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/* 底部时间戳 */
|
|
174
|
-
.footer {
|
|
175
|
-
background-color: #f8f9fa;
|
|
176
|
-
padding: 12px 24px;
|
|
177
|
-
font-size: 12px;
|
|
178
|
-
color: #adb5bd;
|
|
179
|
-
text-align: center;
|
|
180
|
-
border-top: 1px solid #eee;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
</style>
|
|
184
|
-
</head>
|
|
185
|
-
<body>
|
|
186
|
-
|
|
187
|
-
<div class="card" id="card-element">
|
|
188
|
-
<!-- 顶部背景 -->
|
|
189
|
-
<div class="card-header-bg"></div>
|
|
190
|
-
|
|
191
|
-
<!-- 主要信息 -->
|
|
192
|
-
<div class="profile-main">
|
|
193
|
-
<div class="avatar-container">
|
|
194
|
-
<img src="{avatarUrl}" alt="Avatar" class="avatar">
|
|
195
|
-
</div>
|
|
196
|
-
|
|
197
|
-
<div class="nickname-row">
|
|
198
|
-
<span class="nickname">{nickname}</span>
|
|
199
|
-
<!-- 性别: 男 -->
|
|
200
|
-
<span class="sex-icon {sex-so}">{sex} | {age} 岁</span>
|
|
201
|
-
</div>
|
|
202
|
-
|
|
203
|
-
<div class="long-nick">{longNick}</div>
|
|
204
|
-
</div>
|
|
205
|
-
|
|
206
|
-
<!-- 详细数据列表 -->
|
|
207
|
-
<div class="info-list">
|
|
208
|
-
<div class="info-item">
|
|
209
|
-
<span class="label">QQ账号</span>
|
|
210
|
-
<span class="value">{qq}</span>
|
|
211
|
-
</div>
|
|
212
|
-
<div class="info-item">
|
|
213
|
-
<span class="label">QQ等级</span>
|
|
214
|
-
<span class="value">
|
|
215
|
-
<span class="tag tag-level">LV {qqLevel}</span>
|
|
216
|
-
</span>
|
|
217
|
-
</div>
|
|
218
|
-
<div class="info-item">
|
|
219
|
-
<span class="label">个性域名 (QID)</span>
|
|
220
|
-
<span class="value">{qid}</span>
|
|
221
|
-
</div>
|
|
222
|
-
<div class="info-item">
|
|
223
|
-
<span class="label">所在地</span>
|
|
224
|
-
<span class="value">{location}</span>
|
|
225
|
-
</div>
|
|
226
|
-
<div class="info-item">
|
|
227
|
-
<span class="label">电子邮箱</span>
|
|
228
|
-
<span class="value">{email}</span>
|
|
229
|
-
</div>
|
|
230
|
-
<div class="info-item">
|
|
231
|
-
<span class="label">注册时间</span>
|
|
232
|
-
<span class="value">{regTime}</span>
|
|
233
|
-
</div>
|
|
234
|
-
</div>
|
|
235
|
-
|
|
236
|
-
<div class="footer">
|
|
237
|
-
数据更新于: {lastUpdated}
|
|
238
|
-
</div>
|
|
239
|
-
</div>
|
|
240
|
-
|
|
241
|
-
</body>
|
|
242
|
-
</html>
|
package/res/userMsg.html
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<title>UserMsg</title>
|
|
6
|
-
<style>
|
|
7
|
-
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
8
|
-
|
|
9
|
-
body {
|
|
10
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
|
11
|
-
background: transparent;
|
|
12
|
-
padding: 20px;
|
|
13
|
-
//// transform: rotate(180deg);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.message-card {
|
|
17
|
-
display: flex;
|
|
18
|
-
flex-direction: row;
|
|
19
|
-
align-items: flex-start;
|
|
20
|
-
width: 100%;
|
|
21
|
-
background: #ffffff;
|
|
22
|
-
padding: 15px;
|
|
23
|
-
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
|
24
|
-
border-radius: 8px;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.avatar {
|
|
28
|
-
width: 50px;
|
|
29
|
-
height: 50px;
|
|
30
|
-
border-radius: 50%;
|
|
31
|
-
object-fit: cover;
|
|
32
|
-
flex-shrink: 0;
|
|
33
|
-
margin-right: 15px;
|
|
34
|
-
border: 1px solid #eee;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.content {
|
|
38
|
-
flex: 1;
|
|
39
|
-
display: flex;
|
|
40
|
-
flex-direction: column;
|
|
41
|
-
min-width: 0;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.user-name {
|
|
45
|
-
font-weight: bold;
|
|
46
|
-
font-size: 14px;
|
|
47
|
-
color: #333;
|
|
48
|
-
margin-bottom: 6px;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.reply-block {
|
|
52
|
-
background: #f7f8fa;
|
|
53
|
-
border-left: 3px solid #b9bbbe;
|
|
54
|
-
padding: 6px 10px;
|
|
55
|
-
border-radius: 0 4px 4px 0;
|
|
56
|
-
margin-bottom: 8px;
|
|
57
|
-
/**/display:none;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.reply-user {
|
|
61
|
-
font-size: 12px;
|
|
62
|
-
font-weight: 600;
|
|
63
|
-
color: #555;
|
|
64
|
-
margin-bottom: 3px;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.reply-text {
|
|
68
|
-
font-size: 13px;
|
|
69
|
-
color: #777;
|
|
70
|
-
display: -webkit-box;
|
|
71
|
-
-webkit-line-clamp: 2;
|
|
72
|
-
-webkit-box-orient: vertical;
|
|
73
|
-
overflow: hidden;
|
|
74
|
-
text-overflow: ellipsis;
|
|
75
|
-
word-break: break-all;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.text-bubble {
|
|
79
|
-
font-size: 15px;
|
|
80
|
-
line-height: 1.5;
|
|
81
|
-
color: #444;
|
|
82
|
-
background: #f2f3f5;
|
|
83
|
-
padding: 10px 14px;
|
|
84
|
-
border-radius: 0 12px 12px 12px;
|
|
85
|
-
|
|
86
|
-
white-space: pre-wrap;
|
|
87
|
-
word-wrap: break-word;
|
|
88
|
-
overflow-wrap: break-word;
|
|
89
|
-
word-break: break-all;
|
|
90
|
-
width: fit-content;
|
|
91
|
-
}
|
|
92
|
-
</style>
|
|
93
|
-
</head>
|
|
94
|
-
<body>
|
|
95
|
-
<div id="target-element" class="message-card">
|
|
96
|
-
<img src="{userData.avatarUrl}" class="avatar" alt="Avatar" />
|
|
97
|
-
<div class="content">
|
|
98
|
-
<div class="user-name">{userData.username}</div>
|
|
99
|
-
|
|
100
|
-
<!-- 新增的回复块 -->
|
|
101
|
-
<div class="reply-block">
|
|
102
|
-
<div class="reply-user">@{replyData.username}</div>
|
|
103
|
-
<div class="reply-text">{replyData.message}</div>
|
|
104
|
-
</div>
|
|
105
|
-
|
|
106
|
-
<div class="text-bubble">{userData.message}</div>
|
|
107
|
-
</div>
|
|
108
|
-
</div>
|
|
109
|
-
</body>
|
|
110
|
-
</html>
|