koishi-plugin-node-async-bot-all 2.27.1 → 2.28.1
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 +64 -19
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -34,7 +34,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
34
34
|
// src/locales/zh-CN.yml
|
|
35
35
|
var require_zh_CN = __commonJS({
|
|
36
36
|
"src/locales/zh-CN.yml"(exports2, module2) {
|
|
37
|
-
module2.exports = { noApi: "未指定 API", noop: "无", unknownError: "未知错误。", commands: { na: { description: "NodeAsync Bot" }, cxgame: { description: "查询服务器当前人数。", messages: { msg: "{time}{list}\n进服指南请在群公告中查看。", list: "【MC 服务器 {count}】\n➣ {version}:{players}\n➣ 玩家列表:{list}\n➣ 备注:{note}", listNoPlayer: "【MC 服务器 {count}】\n➣ {version}:{players}\n➣ 备注:{note}", listFailed: "【MC 服务器 {count}】\n➣ 查询失败:{data}\n➣ 请稍后重试。\n➣ 备注:{note}", listA2S: "【A2S 服务器 {count}】\n➣ {version}:{players}\n➣ 机器人:{bots}\n➣ 备注:{note}", listFailedA2S: "【A2S 服务器 {count}】\n➣ 查询失败:{data}\n➣ 请稍后重试。\n➣ 备注:{note}", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\n查询失败:{data}", timeout: "请求超时。", fewData: "服务端返回的数据过少。", close: "服务器已关闭。", host: "没有到主机的路由。", dns: "解析失败。" } }, status: { description: "查询机器人状态。", messages: { msg: "{time}\n--- 系统状态 ---\n系统名称:{name}\nCPU使用率:{cpu}\n内存使用率:{memory}\n--- 机器人状态 ---\n昨日收/发消息数量:{msgCount}\n机器人版本:{version}\n运行时间:{online}", failed: "{time}\n状态获取失败。" } }, random: { description: "随机数生成器。", usage: "缺少参数时默认生成 0-10000 的随机数。\n使用示例:", examples: "random 1 128 生成1到128范围的随机数", messages: { msg: "{time}\n生成的随机数:{data}" } }, info: { description: "查询机器人信息。", messages: { msg: "{data}", failed: "{time}\n读取信息失败。" } }, rw: { description: "随机名言名句。", messages: { msg: "{time}\n{data}", failed: "{time}\n获取失败({data})。" } }, randomba: { description: "随机BA图。", messages: { msg: "{quote}{image}"
|
|
37
|
+
module2.exports = { noApi: "未指定 API", noop: "无", unknownError: "未知错误。", commands: { na: { description: "NodeAsync Bot" }, cxgame: { description: "查询服务器当前人数。", messages: { msg: "{time}{list}\n进服指南请在群公告中查看。", list: "【MC 服务器 {count}】\n➣ {version}:{players}\n➣ 玩家列表:{list}\n➣ 备注:{note}", listNoPlayer: "【MC 服务器 {count}】\n➣ {version}:{players}\n➣ 备注:{note}", listFailed: "【MC 服务器 {count}】\n➣ 查询失败:{data}\n➣ 请稍后重试。\n➣ 备注:{note}", listA2S: "【A2S 服务器 {count}】\n➣ {version}:{players}\n➣ 机器人:{bots}\n➣ 备注:{note}", listFailedA2S: "【A2S 服务器 {count}】\n➣ 查询失败:{data}\n➣ 请稍后重试。\n➣ 备注:{note}", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\n查询失败:{data}", timeout: "请求超时。", fewData: "服务端返回的数据过少。", close: "服务器已关闭。", host: "没有到主机的路由。", dns: "解析失败。" } }, status: { description: "查询机器人状态。", messages: { msg: "{time}\n--- 系统状态 ---\n系统名称:{name}\nCPU使用率:{cpu}\n内存使用率:{memory}\n--- 机器人状态 ---\n昨日收/发消息数量:{msgCount}\n机器人版本:{version}\n运行时间:{online}", failed: "{time}\n状态获取失败。" } }, random: { description: "随机数生成器。", usage: "缺少参数时默认生成 0-10000 的随机数。\n使用示例:", examples: "random 1 128 生成1到128范围的随机数", messages: { msg: "{time}\n生成的随机数:{data}" } }, info: { description: "查询机器人信息。", messages: { msg: "{data}", failed: "{time}\n读取信息失败。" } }, rw: { description: "随机名言名句。", messages: { msg: "{time}\n{data}", failed: "{time}\n获取失败({data})。" } }, randomba: { description: "随机BA图。", messages: { msg: "{quote}{image}" } }, centerservertest: { description: "查看中心服务器状态。", messages: { msg: "{time}{list}", list: "== {name} ==\n状态:{status}\n存活率:{uptime}\n检测时间:{time}", listFailed: "== {name} ==\n查看失败:{data}", failed: "{time}\n查看失败:{data}", statusLive: "✅ 正常", statusDie: "❌ 故障", dataFail: "未能获取到此服务器的状态信息。" } }, meme: { description: "群友的怪话!", usage: "不带参数时随机查看\n带参数时为查看指定 meme", examples: "meme\nmeme 1145", messages: { msg: "{quote}{time}\n{image}\n{title}", failed: "{quote}{time}\n获取失败:{data}", forbidden: "{quote}{time}\n此指令不允许在本群使用。" } }, randomcat: { description: "随机猫猫图。", messages: { msg: "{quote}{image}", failed: "{quote}{time}\n获取失败:{data}" } }, getqqinfo: { description: "获取 QQ 号的信息。", usage: "获取 QQ 号的信息。", examples: "getqqinfo 10001", messages: { msg: "{quote}{image}", failed: "{quote}{time}\n获取失败:{data}", command: "QQ 号不正确。" } }, msg2img: { description: "引用一个消息并使用此指令,即可将消息转图。", usage: "引用一条消息,/m。(不要带@)", messages: { msg: "{quote}{image}", failed: "{quote}{time}\n获取失败:{data}", null: "未引用任何消息。", matroska: "{quote}禁止套娃!" } }, slnews: { description: "抓取 NorthWood 的 Steam 最新新闻。" }, use: { description: "使用 TA !", usage: "use @用户", examples: "use @用户", messages: { command: "请 @ 一个用户。", msg: "{at} {desc}了 {at2} !" } } } };
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
|
|
@@ -613,14 +613,12 @@ async function getBlueArchive(ctx, session) {
|
|
|
613
613
|
await session.send(session.text(".msg", { "quote": import_koishi2.h.quote(session.messageId), "image": session.text("noApi") }));
|
|
614
614
|
return 1;
|
|
615
615
|
}
|
|
616
|
-
const vid = await session.send(session.text(".wait", { "quote": import_koishi2.h.quote(session.messageId), "time": time }));
|
|
617
616
|
const ms = random(0, 0, 1500);
|
|
618
617
|
const link = random(2, ctx.config.baAPI) + `?cacheBuster=${random(1, 1, 2147483647)}`;
|
|
619
618
|
log.debug(`Link: ${link}`);
|
|
620
619
|
await (0, import_koishi2.sleep)(ms);
|
|
621
620
|
const status2 = await session.send(session.text(".msg", { "quote": import_koishi2.h.quote(session.messageId), "image": import_koishi2.h.image(link) }));
|
|
622
621
|
if (!status2) await session.send(session.text(".msg", { "quote": import_koishi2.h.quote(session.messageId), "image": import_koishi2.h.image(link) }));
|
|
623
|
-
await session.bot.deleteMessage(session.event.guild?.id, vid[0]);
|
|
624
622
|
return 0;
|
|
625
623
|
}
|
|
626
624
|
__name(getBlueArchive, "getBlueArchive");
|
|
@@ -743,7 +741,6 @@ async function getCat(ctx, session) {
|
|
|
743
741
|
log.warn("未指定 API");
|
|
744
742
|
return 1;
|
|
745
743
|
}
|
|
746
|
-
const vid = await session.send(session.text(".wait", { "quote": import_koishi2.h.quote(session.messageId), "time": time }));
|
|
747
744
|
const response = await request(ctx.config.catAPI, {}, ctx.config.timeout, log);
|
|
748
745
|
if (response.success) {
|
|
749
746
|
log.debug(response.data);
|
|
@@ -762,7 +759,6 @@ async function getCat(ctx, session) {
|
|
|
762
759
|
log.warn(response.error);
|
|
763
760
|
}
|
|
764
761
|
}
|
|
765
|
-
await session.bot.deleteMessage(session.event.guild?.id, vid[0]);
|
|
766
762
|
return 0;
|
|
767
763
|
}
|
|
768
764
|
__name(getCat, "getCat");
|
|
@@ -943,7 +939,7 @@ async function getUse(ctx, session, qq, desc) {
|
|
|
943
939
|
__name(getUse, "getUse");
|
|
944
940
|
|
|
945
941
|
// package.json
|
|
946
|
-
var version = "2.
|
|
942
|
+
var version = "2.28.1";
|
|
947
943
|
|
|
948
944
|
// src/index.ts
|
|
949
945
|
var inject = ["database", "installer", "puppeteer", "cron"];
|
|
@@ -1001,6 +997,20 @@ var Config = import_koishi3.Schema.intersect([
|
|
|
1001
997
|
})).default([{ "id": "1", "name": "中心 鲁贝 1" }, { "id": "19", "name": "中心 斯特拉斯堡 1" }, { "id": "3", "name": "Steam 认证 API" }]).description("测试中心服务器")
|
|
1002
998
|
}).description("测试中心服务器")
|
|
1003
999
|
]).description("基础设置");
|
|
1000
|
+
async function startReaction(session) {
|
|
1001
|
+
await session.bot.createReaction(session.channelId, session.messageId, `face|424`);
|
|
1002
|
+
}
|
|
1003
|
+
__name(startReaction, "startReaction");
|
|
1004
|
+
async function endReaction(session) {
|
|
1005
|
+
await session.bot.deleteReaction(session.channelId, session.messageId, `face|424`);
|
|
1006
|
+
await session.bot.createReaction(session.channelId, session.messageId, `face|144`);
|
|
1007
|
+
}
|
|
1008
|
+
__name(endReaction, "endReaction");
|
|
1009
|
+
async function endReactionFailed(session) {
|
|
1010
|
+
await session.bot.deleteReaction(session.channelId, session.messageId, `face|424`);
|
|
1011
|
+
await session.bot.createReaction(session.channelId, session.messageId, `face|41`);
|
|
1012
|
+
}
|
|
1013
|
+
__name(endReactionFailed, "endReactionFailed");
|
|
1004
1014
|
function apply(ctx) {
|
|
1005
1015
|
ctx.i18n.define("zh-CN", require_zh_CN());
|
|
1006
1016
|
ctx.on("ready", async () => {
|
|
@@ -1051,67 +1061,102 @@ ${import_koishi3.h.image(outMsg.data, "image/png")}`);
|
|
|
1051
1061
|
}
|
|
1052
1062
|
});
|
|
1053
1063
|
na.subcommand("cxGame").action(async ({ session }) => {
|
|
1064
|
+
await startReaction(session);
|
|
1054
1065
|
const cx = await getServer(ctx, session);
|
|
1055
1066
|
if (cx["success"] == 0) {
|
|
1056
|
-
|
|
1067
|
+
session?.send(session?.text(".msg", cx));
|
|
1068
|
+
await endReaction(session);
|
|
1057
1069
|
} else if (cx["success"] == 1) {
|
|
1058
|
-
|
|
1070
|
+
session?.send(session?.text(".forbidden", cx));
|
|
1071
|
+
await endReactionFailed(session);
|
|
1059
1072
|
} else if (cx["success"] == 2) {
|
|
1060
|
-
|
|
1073
|
+
session?.send(session?.text(".failed", cx));
|
|
1074
|
+
await endReactionFailed(session);
|
|
1061
1075
|
}
|
|
1062
1076
|
});
|
|
1063
1077
|
na.subcommand("status").alias("stats").alias("状态").action(async ({ session }) => {
|
|
1078
|
+
await startReaction(session);
|
|
1064
1079
|
const status2 = await getStatus(ctx, session);
|
|
1065
1080
|
if (status2["success"] == 0) {
|
|
1066
|
-
|
|
1081
|
+
session?.send(session?.text(".msg", status2));
|
|
1082
|
+
await endReaction(session);
|
|
1067
1083
|
} else {
|
|
1068
|
-
|
|
1084
|
+
session?.send(session?.text(".failed", status2));
|
|
1085
|
+
await endReactionFailed(session);
|
|
1069
1086
|
}
|
|
1070
1087
|
});
|
|
1071
1088
|
na.subcommand("random [最小数:number] [最大数:number]").alias("随机数").action(async ({ session }, min, max) => {
|
|
1089
|
+
await startReaction(session);
|
|
1072
1090
|
const random2 = await getRandom(ctx, session, min, max);
|
|
1073
|
-
|
|
1091
|
+
session?.send(session?.text(".msg", random2));
|
|
1092
|
+
await endReaction(session);
|
|
1074
1093
|
});
|
|
1075
1094
|
na.subcommand("info").action(async ({ session }) => {
|
|
1095
|
+
await startReaction(session);
|
|
1076
1096
|
const info = await getInfo(ctx, session);
|
|
1077
1097
|
if (info["success"] == 0) {
|
|
1078
|
-
|
|
1098
|
+
session?.send(session?.text(".msg", info));
|
|
1099
|
+
await endReaction(session);
|
|
1079
1100
|
} else {
|
|
1080
|
-
|
|
1101
|
+
session?.send(session?.text(".failed", info));
|
|
1102
|
+
await endReactionFailed(session);
|
|
1081
1103
|
}
|
|
1082
1104
|
});
|
|
1083
1105
|
na.subcommand("rw").action(async ({ session }) => {
|
|
1106
|
+
await startReaction(session);
|
|
1084
1107
|
const rw = await getRandomWord(ctx, session);
|
|
1085
1108
|
if (rw["success"] == 0) {
|
|
1086
|
-
|
|
1109
|
+
session?.send(session?.text(".msg", rw));
|
|
1110
|
+
await endReaction(session);
|
|
1087
1111
|
} else {
|
|
1088
|
-
|
|
1112
|
+
session?.send(session?.text(".failed", rw));
|
|
1113
|
+
await endReactionFailed(session);
|
|
1089
1114
|
}
|
|
1090
1115
|
});
|
|
1091
1116
|
na.subcommand("randomBA").alias("随机ba图").action(async ({ session }) => {
|
|
1117
|
+
await startReaction(session);
|
|
1092
1118
|
await getBlueArchive(ctx, session);
|
|
1119
|
+
await endReaction(session);
|
|
1093
1120
|
});
|
|
1094
1121
|
na.subcommand("centerServerTest").alias("测测中心服务器").action(async ({ session }) => {
|
|
1122
|
+
await startReaction(session);
|
|
1095
1123
|
const msg = await centerServerTest(ctx, session);
|
|
1096
|
-
|
|
1124
|
+
session?.send(session?.text(msg.success, msg.data));
|
|
1125
|
+
await endReaction(session);
|
|
1097
1126
|
});
|
|
1098
1127
|
na.subcommand("meme [序号:posint]").alias("memes").action(async ({ session }, count) => {
|
|
1128
|
+
await startReaction(session);
|
|
1099
1129
|
await getMeme(ctx, session, count);
|
|
1130
|
+
await endReaction(session);
|
|
1100
1131
|
});
|
|
1101
1132
|
na.subcommand("randomCat").alias("随机猫猫图").alias("随机猫猫").action(async ({ session }) => {
|
|
1133
|
+
await startReaction(session);
|
|
1102
1134
|
await getCat(ctx, session);
|
|
1135
|
+
await endReaction(session);
|
|
1103
1136
|
});
|
|
1104
1137
|
na.subcommand("getQQInfo <QQ号:string>").alias("获取QQ信息").action(async ({ session }, qq) => {
|
|
1105
|
-
|
|
1138
|
+
await startReaction(session);
|
|
1139
|
+
if (qq == void 0 || isNaN(Number(qq))) {
|
|
1140
|
+
await endReactionFailed(session);
|
|
1141
|
+
return session?.text(".command");
|
|
1142
|
+
}
|
|
1106
1143
|
await getQQInfo(ctx, session, qq);
|
|
1144
|
+
await endReaction(session);
|
|
1107
1145
|
});
|
|
1108
1146
|
na.subcommand("msg2img").option("inversion", "-i").alias("消息转图").alias("m").action(async ({ session, options }) => {
|
|
1147
|
+
await startReaction(session);
|
|
1109
1148
|
await getMsg(ctx, session, options?.inversion);
|
|
1149
|
+
await endReaction(session);
|
|
1110
1150
|
});
|
|
1111
1151
|
na.subcommand("use <user:user> [方法:string]").alias("u").action(async ({ session }, user, desc) => {
|
|
1152
|
+
await startReaction(session);
|
|
1112
1153
|
const qq = user?.split(":")?.[1];
|
|
1113
|
-
if (qq == void 0 || isNaN(Number(qq)))
|
|
1154
|
+
if (qq == void 0 || isNaN(Number(qq))) {
|
|
1155
|
+
await endReactionFailed(session);
|
|
1156
|
+
return session?.text(".command");
|
|
1157
|
+
}
|
|
1114
1158
|
await getUse(ctx, session, qq, desc);
|
|
1159
|
+
await endReaction(session);
|
|
1115
1160
|
});
|
|
1116
1161
|
}
|
|
1117
1162
|
__name(apply, "apply");
|