koishi-plugin-noah 2.4.1 → 2.4.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/core/command.d.ts +1 -4
- package/lib/core/utils/server.d.ts +0 -7
- package/lib/fun/poke/index.d.ts +1 -2
- package/lib/fun/poke/types.d.ts +0 -5
- package/lib/games/sdvx/utils/param-parser.d.ts +3 -5
- package/lib/index.cjs +443 -1263
- package/lib/servers/Asphyxia/services/sdvx-service.d.ts +26 -0
- package/lib/servers/Mao/services/sdvx-service.d.ts +44 -0
- package/lib/servers/Official/services/sdvx-service.d.ts +25 -0
- package/lib/servers/utils/difficulty.d.ts +23 -0
- package/lib/servers/utils/grade.d.ts +8 -0
- package/lib/servers/utils/xml.d.ts +13 -0
- package/lib/types/config.d.ts +2 -8
- package/package.json +7 -7
- package/lib/core/api/auth.d.ts +0 -18
- package/lib/core/api/index.d.ts +0 -3
- package/lib/core/commands/settings.d.ts +0 -3
- package/lib/core/utils/selector.d.ts +0 -13
- package/lib/fun/poke/commands/poke.d.ts +0 -6
- package/lib/fun/poke/commands/stamp.d.ts +0 -6
- package/lib/fun/poke/constants.d.ts +0 -10
- package/lib/fun/poke/events/notice.d.ts +0 -9
- package/lib/fun/poke/utils/file.d.ts +0 -18
- package/lib/fun/poke/utils/random.d.ts +0 -14
- package/lib/fun/poke/utils/stamp.d.ts +0 -14
- package/lib/fun/poke/utils/tip.d.ts +0 -10
package/lib/index.cjs
CHANGED
|
@@ -28,14 +28,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
30
|
// src/index.ts
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
33
|
Config: () => Config,
|
|
34
34
|
apply: () => apply14,
|
|
35
35
|
inject: () => inject4,
|
|
36
36
|
name: () => name14
|
|
37
37
|
});
|
|
38
|
-
module.exports = __toCommonJS(
|
|
38
|
+
module.exports = __toCommonJS(src_exports);
|
|
39
39
|
|
|
40
40
|
// src/asset/index.ts
|
|
41
41
|
var asset_exports = {};
|
|
@@ -64,7 +64,6 @@ var AssetService = class {
|
|
|
64
64
|
this.config = config;
|
|
65
65
|
this.basePath = import_path.default.resolve(this.ctx.baseDir, this.config.data_path);
|
|
66
66
|
}
|
|
67
|
-
ctx;
|
|
68
67
|
static {
|
|
69
68
|
__name(this, "AssetService");
|
|
70
69
|
}
|
|
@@ -337,61 +336,18 @@ __export(core_exports, {
|
|
|
337
336
|
});
|
|
338
337
|
var import_koishi6 = require("koishi");
|
|
339
338
|
|
|
340
|
-
// src/core/
|
|
341
|
-
var
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
frontendUrl: config.frontendUrl ?? "",
|
|
347
|
-
corsOrigin: config.corsOrigin ?? "*"
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
__name(resolveApiContext, "resolveApiContext");
|
|
351
|
-
var ALG = "sha256";
|
|
352
|
-
function base64url(data) {
|
|
353
|
-
const buf = typeof data === "string" ? Buffer.from(data) : data;
|
|
354
|
-
return buf.toString("base64url");
|
|
355
|
-
}
|
|
356
|
-
__name(base64url, "base64url");
|
|
357
|
-
function sign(payload, secret) {
|
|
358
|
-
const header = base64url(JSON.stringify({ alg: "HS256", typ: "JWT" }));
|
|
359
|
-
const body = base64url(payload);
|
|
360
|
-
const signature = crypto.createHmac(ALG, secret).update(`${header}.${body}`).digest("base64url");
|
|
361
|
-
return `${header}.${body}.${signature}`;
|
|
362
|
-
}
|
|
363
|
-
__name(sign, "sign");
|
|
364
|
-
function createToken(uid, secret, ttlSeconds = 1800) {
|
|
365
|
-
const now = Math.floor(Date.now() / 1e3);
|
|
366
|
-
const payload = { uid, iat: now, exp: now + ttlSeconds };
|
|
367
|
-
return sign(JSON.stringify(payload), secret);
|
|
368
|
-
}
|
|
369
|
-
__name(createToken, "createToken");
|
|
370
|
-
function verifyToken(token, secret) {
|
|
371
|
-
const parts = token.split(".");
|
|
372
|
-
if (parts.length !== 3) return null;
|
|
373
|
-
const [header, body, signature] = parts;
|
|
374
|
-
const expected = crypto.createHmac(ALG, secret).update(`${header}.${body}`).digest("base64url");
|
|
375
|
-
if (!crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected))) return null;
|
|
376
|
-
try {
|
|
377
|
-
const payload = JSON.parse(Buffer.from(body, "base64url").toString());
|
|
378
|
-
if (payload.exp < Math.floor(Date.now() / 1e3)) return null;
|
|
379
|
-
return payload;
|
|
380
|
-
} catch {
|
|
381
|
-
return null;
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
__name(verifyToken, "verifyToken");
|
|
385
|
-
|
|
386
|
-
// src/types/index.ts
|
|
387
|
-
var serverValues = ["asphyxia", "mao", "official"];
|
|
339
|
+
// src/core/command.ts
|
|
340
|
+
var command_exports = {};
|
|
341
|
+
__export(command_exports, {
|
|
342
|
+
apply: () => apply2,
|
|
343
|
+
name: () => name2
|
|
344
|
+
});
|
|
388
345
|
|
|
389
346
|
// src/core/services/card-service.ts
|
|
390
347
|
var CardService = class {
|
|
391
348
|
constructor(ctx) {
|
|
392
349
|
this.ctx = ctx;
|
|
393
350
|
}
|
|
394
|
-
ctx;
|
|
395
351
|
static {
|
|
396
352
|
__name(this, "CardService");
|
|
397
353
|
}
|
|
@@ -536,7 +492,6 @@ var ServerService = class {
|
|
|
536
492
|
constructor(ctx) {
|
|
537
493
|
this.ctx = ctx;
|
|
538
494
|
}
|
|
539
|
-
ctx;
|
|
540
495
|
static {
|
|
541
496
|
__name(this, "ServerService");
|
|
542
497
|
}
|
|
@@ -686,20 +641,18 @@ var ServerService = class {
|
|
|
686
641
|
if (channelServerRes.length > 0) {
|
|
687
642
|
await this.ctx.database.set(
|
|
688
643
|
"channel",
|
|
689
|
-
{ id: channel.id
|
|
644
|
+
{ id: channel.id },
|
|
690
645
|
{ defaultServerId: channelServerRes[0].sid }
|
|
691
646
|
);
|
|
692
647
|
} else {
|
|
693
|
-
await this.ctx.database.set(
|
|
694
|
-
"channel",
|
|
695
|
-
{ id: channel.id, platform: channel.platform },
|
|
696
|
-
{ defaultServerId: 0 }
|
|
697
|
-
);
|
|
648
|
+
await this.ctx.database.set("channel", { id: channel.id }, { defaultServerId: 0 });
|
|
698
649
|
}
|
|
699
650
|
}
|
|
700
651
|
const cardRes = await this.ctx.database.get("card", { defaultServerId: id });
|
|
701
652
|
for (const card2 of cardRes) {
|
|
702
|
-
|
|
653
|
+
if (card2.defaultServerId !== void 0 && card2.defaultServerId !== 0) {
|
|
654
|
+
await this.ctx.database.set("card", { id: card2.id }, { defaultServerId: 0 });
|
|
655
|
+
}
|
|
703
656
|
}
|
|
704
657
|
}
|
|
705
658
|
/**
|
|
@@ -732,7 +685,6 @@ var UserService = class {
|
|
|
732
685
|
constructor(ctx) {
|
|
733
686
|
this.ctx = ctx;
|
|
734
687
|
}
|
|
735
|
-
ctx;
|
|
736
688
|
static {
|
|
737
689
|
__name(this, "UserService");
|
|
738
690
|
}
|
|
@@ -767,7 +719,7 @@ var UserService = class {
|
|
|
767
719
|
};
|
|
768
720
|
|
|
769
721
|
// src/core/utils/card.ts
|
|
770
|
-
var
|
|
722
|
+
var crypto = __toESM(require("crypto"), 1);
|
|
771
723
|
var KEY_STRING = "?I'llB2c.YouXXXeMeHaYpy!";
|
|
772
724
|
var KEY_BUFFER = Buffer.from(KEY_STRING, "ascii");
|
|
773
725
|
var DES3_KEY = Buffer.from(KEY_BUFFER.map((b) => b * 2 & 255));
|
|
@@ -777,7 +729,7 @@ function encDes(data) {
|
|
|
777
729
|
if (data.length !== 8) {
|
|
778
730
|
throw new Error("encDes: data must be 8 bytes");
|
|
779
731
|
}
|
|
780
|
-
const cipher =
|
|
732
|
+
const cipher = crypto.createCipheriv("des-ede3-cbc", DES3_KEY, IV);
|
|
781
733
|
cipher.setAutoPadding(false);
|
|
782
734
|
const encrypted = Buffer.concat([cipher.update(data), cipher.final()]);
|
|
783
735
|
return encrypted;
|
|
@@ -787,7 +739,7 @@ function decDes(data) {
|
|
|
787
739
|
if (data.length !== 8) {
|
|
788
740
|
throw new Error("decDes: data must be 8 bytes");
|
|
789
741
|
}
|
|
790
|
-
const decipher =
|
|
742
|
+
const decipher = crypto.createDecipheriv("des-ede3-cbc", DES3_KEY, IV);
|
|
791
743
|
decipher.setAutoPadding(false);
|
|
792
744
|
const decrypted = Buffer.concat([decipher.update(data), decipher.final()]);
|
|
793
745
|
return decrypted;
|
|
@@ -1041,19 +993,6 @@ function formatCardInfo(data) {
|
|
|
1041
993
|
__name(formatCardInfo, "formatCardInfo");
|
|
1042
994
|
|
|
1043
995
|
// src/core/utils/server.ts
|
|
1044
|
-
async function resolveServerForCard(card2, cardService, serverService, uid, platform, channelId) {
|
|
1045
|
-
if (card2.defaultServerId != void 0 && card2.defaultServerId != 0) {
|
|
1046
|
-
const cardServer = await serverService.getServerById(card2.defaultServerId);
|
|
1047
|
-
if (cardServer) return cardServer;
|
|
1048
|
-
await cardService.updateCard(card2.id, { defaultServerId: 0 });
|
|
1049
|
-
}
|
|
1050
|
-
if (channelId) {
|
|
1051
|
-
const channelDefault = await serverService.getDefaultServerByCid(platform, channelId);
|
|
1052
|
-
if (channelDefault) return channelDefault;
|
|
1053
|
-
}
|
|
1054
|
-
return await serverService.getDefaultServerByUid(uid);
|
|
1055
|
-
}
|
|
1056
|
-
__name(resolveServerForCard, "resolveServerForCard");
|
|
1057
996
|
async function ensureOfficialServerForUser(ctx, serverService, userService, uid, officialSupportUrl) {
|
|
1058
997
|
const userServers = await serverService.getServersByUid(uid);
|
|
1059
998
|
const existingOfficial = userServers.find((server3) => server3.type === "official");
|
|
@@ -1076,352 +1015,6 @@ async function ensureOfficialServerForUser(ctx, serverService, userService, uid,
|
|
|
1076
1015
|
}
|
|
1077
1016
|
__name(ensureOfficialServerForUser, "ensureOfficialServerForUser");
|
|
1078
1017
|
|
|
1079
|
-
// src/core/api/index.ts
|
|
1080
|
-
function registerApiRoutes(ctx, apiCtx) {
|
|
1081
|
-
const { secret, corsOrigin } = apiCtx;
|
|
1082
|
-
function setCors(kctx) {
|
|
1083
|
-
kctx.set("Access-Control-Allow-Origin", corsOrigin);
|
|
1084
|
-
kctx.set("Access-Control-Allow-Methods", "GET, POST, PUT, PATCH, DELETE, OPTIONS");
|
|
1085
|
-
kctx.set("Access-Control-Allow-Headers", "Authorization, Content-Type");
|
|
1086
|
-
}
|
|
1087
|
-
__name(setCors, "setCors");
|
|
1088
|
-
function authenticate(kctx) {
|
|
1089
|
-
const auth = kctx.get("Authorization");
|
|
1090
|
-
if (!auth?.startsWith("Bearer ")) return null;
|
|
1091
|
-
return verifyToken(auth.slice(7), secret);
|
|
1092
|
-
}
|
|
1093
|
-
__name(authenticate, "authenticate");
|
|
1094
|
-
function unauthorized(kctx) {
|
|
1095
|
-
kctx.status = 401;
|
|
1096
|
-
kctx.body = { error: "Unauthorized" };
|
|
1097
|
-
}
|
|
1098
|
-
__name(unauthorized, "unauthorized");
|
|
1099
|
-
function badRequest(kctx, message) {
|
|
1100
|
-
kctx.status = 400;
|
|
1101
|
-
kctx.body = { error: message };
|
|
1102
|
-
}
|
|
1103
|
-
__name(badRequest, "badRequest");
|
|
1104
|
-
ctx.server.get("/noah/api/health", async (kctx) => {
|
|
1105
|
-
setCors(kctx);
|
|
1106
|
-
kctx.body = { status: "ok" };
|
|
1107
|
-
});
|
|
1108
|
-
const apiPaths = [
|
|
1109
|
-
"/noah/api/me",
|
|
1110
|
-
"/noah/api/cards",
|
|
1111
|
-
"/noah/api/cards/:id",
|
|
1112
|
-
"/noah/api/servers",
|
|
1113
|
-
"/noah/api/servers/:id",
|
|
1114
|
-
"/noah/api/defaults",
|
|
1115
|
-
"/noah/api/resolve",
|
|
1116
|
-
"/noah/api/health"
|
|
1117
|
-
];
|
|
1118
|
-
for (const path4 of apiPaths) {
|
|
1119
|
-
ctx.server.all(path4, async (kctx, next) => {
|
|
1120
|
-
setCors(kctx);
|
|
1121
|
-
if (kctx.method === "OPTIONS") {
|
|
1122
|
-
kctx.status = 204;
|
|
1123
|
-
return;
|
|
1124
|
-
}
|
|
1125
|
-
await next();
|
|
1126
|
-
});
|
|
1127
|
-
}
|
|
1128
|
-
ctx.server.get("/noah/api/me", async (kctx) => {
|
|
1129
|
-
setCors(kctx);
|
|
1130
|
-
const payload = authenticate(kctx);
|
|
1131
|
-
if (!payload) return unauthorized(kctx);
|
|
1132
|
-
const cardService = new CardService(ctx);
|
|
1133
|
-
const serverService = new ServerService(ctx);
|
|
1134
|
-
const defaultCard = await cardService.getDefaultCardByUid(payload.uid);
|
|
1135
|
-
const defaultServer = await serverService.getDefaultServerByUid(payload.uid);
|
|
1136
|
-
kctx.body = {
|
|
1137
|
-
uid: payload.uid,
|
|
1138
|
-
defaultCardId: defaultCard?.id ?? null,
|
|
1139
|
-
defaultServerId: defaultServer?.id ?? null
|
|
1140
|
-
};
|
|
1141
|
-
});
|
|
1142
|
-
ctx.server.get("/noah/api/cards", async (kctx) => {
|
|
1143
|
-
setCors(kctx);
|
|
1144
|
-
const payload = authenticate(kctx);
|
|
1145
|
-
if (!payload) return unauthorized(kctx);
|
|
1146
|
-
const cardService = new CardService(ctx);
|
|
1147
|
-
const defaultCard = await cardService.getDefaultCardByUid(payload.uid);
|
|
1148
|
-
const cards = await cardService.getCardsByUid(payload.uid);
|
|
1149
|
-
kctx.body = cards.map((card2) => ({
|
|
1150
|
-
id: card2.id,
|
|
1151
|
-
code: card2.code,
|
|
1152
|
-
name: card2.name,
|
|
1153
|
-
defaultServerId: card2.defaultServerId || null,
|
|
1154
|
-
isDefault: defaultCard?.id === card2.id
|
|
1155
|
-
}));
|
|
1156
|
-
});
|
|
1157
|
-
ctx.server.post("/noah/api/cards", async (kctx) => {
|
|
1158
|
-
setCors(kctx);
|
|
1159
|
-
const payload = authenticate(kctx);
|
|
1160
|
-
if (!payload) return unauthorized(kctx);
|
|
1161
|
-
const body = kctx.request.body;
|
|
1162
|
-
if (!body?.code || !body?.name) return badRequest(kctx, "code and name are required");
|
|
1163
|
-
const cardService = new CardService(ctx);
|
|
1164
|
-
const serverService = new ServerService(ctx);
|
|
1165
|
-
const userService = new UserService(ctx);
|
|
1166
|
-
const processed = processInputCardCode(body.code);
|
|
1167
|
-
const cardType = classifyCardId(ctx, processed);
|
|
1168
|
-
if (cardType === "invalid") return badRequest(kctx, "Invalid card code");
|
|
1169
|
-
let finalCode = processed;
|
|
1170
|
-
if (cardType === "access") {
|
|
1171
|
-
try {
|
|
1172
|
-
finalCode = await accessToUid(ctx, processed);
|
|
1173
|
-
} catch (e) {
|
|
1174
|
-
return badRequest(kctx, `Failed to convert access code: ${e.message}`);
|
|
1175
|
-
}
|
|
1176
|
-
} else if (cardType === "konamiid") {
|
|
1177
|
-
try {
|
|
1178
|
-
finalCode = konamiIdToUid(processed);
|
|
1179
|
-
} catch (e) {
|
|
1180
|
-
return badRequest(kctx, `Failed to convert Konami ID: ${e.message}`);
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
const existing = await cardService.getCardByCode(finalCode);
|
|
1184
|
-
if (existing) return badRequest(kctx, "Card already exists");
|
|
1185
|
-
const card2 = await cardService.createCard(payload.uid, finalCode, body.name);
|
|
1186
|
-
if (cardType === "official") {
|
|
1187
|
-
await ensureOfficialServerForUser(ctx, serverService, userService, payload.uid);
|
|
1188
|
-
}
|
|
1189
|
-
const defaultCard = await cardService.getDefaultCardByUid(payload.uid);
|
|
1190
|
-
if (!defaultCard) {
|
|
1191
|
-
await userService.updateUserDefaultCard(payload.uid, card2.id);
|
|
1192
|
-
}
|
|
1193
|
-
kctx.status = 201;
|
|
1194
|
-
kctx.body = { id: card2.id, code: card2.code, name: card2.name, defaultServerId: null };
|
|
1195
|
-
});
|
|
1196
|
-
ctx.server.patch("/noah/api/cards/:id", async (kctx) => {
|
|
1197
|
-
setCors(kctx);
|
|
1198
|
-
const payload = authenticate(kctx);
|
|
1199
|
-
if (!payload) return unauthorized(kctx);
|
|
1200
|
-
const cardId = Number(kctx.params.id);
|
|
1201
|
-
if (isNaN(cardId)) return badRequest(kctx, "Invalid card id");
|
|
1202
|
-
const cardService = new CardService(ctx);
|
|
1203
|
-
const cards = await cardService.getCardsByUid(payload.uid);
|
|
1204
|
-
if (!cards.find((c) => c.id === cardId)) {
|
|
1205
|
-
kctx.status = 404;
|
|
1206
|
-
kctx.body = { error: "Card not found" };
|
|
1207
|
-
return;
|
|
1208
|
-
}
|
|
1209
|
-
const body = kctx.request.body ?? {};
|
|
1210
|
-
const update = {};
|
|
1211
|
-
if (body.name !== void 0) update.name = body.name;
|
|
1212
|
-
if (body.defaultServerId !== void 0) update.defaultServerId = body.defaultServerId ?? 0;
|
|
1213
|
-
if (Object.keys(update).length > 0) {
|
|
1214
|
-
await cardService.updateCard(cardId, update);
|
|
1215
|
-
}
|
|
1216
|
-
const updated = await cardService.getCardById(cardId);
|
|
1217
|
-
kctx.body = updated;
|
|
1218
|
-
});
|
|
1219
|
-
ctx.server.delete("/noah/api/cards/:id", async (kctx) => {
|
|
1220
|
-
setCors(kctx);
|
|
1221
|
-
const payload = authenticate(kctx);
|
|
1222
|
-
if (!payload) return unauthorized(kctx);
|
|
1223
|
-
const cardId = Number(kctx.params.id);
|
|
1224
|
-
if (isNaN(cardId)) return badRequest(kctx, "Invalid card id");
|
|
1225
|
-
const cardService = new CardService(ctx);
|
|
1226
|
-
const cards = await cardService.getCardsByUid(payload.uid);
|
|
1227
|
-
if (!cards.find((c) => c.id === cardId)) {
|
|
1228
|
-
kctx.status = 404;
|
|
1229
|
-
kctx.body = { error: "Card not found" };
|
|
1230
|
-
return;
|
|
1231
|
-
}
|
|
1232
|
-
await cardService.removeCard(cardId);
|
|
1233
|
-
kctx.status = 204;
|
|
1234
|
-
});
|
|
1235
|
-
ctx.server.get("/noah/api/servers", async (kctx) => {
|
|
1236
|
-
setCors(kctx);
|
|
1237
|
-
const payload = authenticate(kctx);
|
|
1238
|
-
if (!payload) return unauthorized(kctx);
|
|
1239
|
-
const serverService = new ServerService(ctx);
|
|
1240
|
-
const defaultServer = await serverService.getDefaultServerByUid(payload.uid);
|
|
1241
|
-
const servers = await serverService.getServersByUid(payload.uid);
|
|
1242
|
-
kctx.body = servers.map((s) => ({
|
|
1243
|
-
id: s.id,
|
|
1244
|
-
type: s.type,
|
|
1245
|
-
name: s.name,
|
|
1246
|
-
baseUrl: s.baseUrl,
|
|
1247
|
-
pcbid: s.pcbid ?? null,
|
|
1248
|
-
isDefault: defaultServer?.id === s.id
|
|
1249
|
-
}));
|
|
1250
|
-
});
|
|
1251
|
-
ctx.server.post("/noah/api/servers", async (kctx) => {
|
|
1252
|
-
setCors(kctx);
|
|
1253
|
-
const payload = authenticate(kctx);
|
|
1254
|
-
if (!payload) return unauthorized(kctx);
|
|
1255
|
-
const body = kctx.request.body;
|
|
1256
|
-
if (!body?.type) return badRequest(kctx, "type is required");
|
|
1257
|
-
if (!serverValues.includes(body.type)) {
|
|
1258
|
-
return badRequest(
|
|
1259
|
-
kctx,
|
|
1260
|
-
`Invalid server type. Must be one of: ${serverValues.join(", ")}`
|
|
1261
|
-
);
|
|
1262
|
-
}
|
|
1263
|
-
const serverType = body.type;
|
|
1264
|
-
let baseUrl;
|
|
1265
|
-
let serverName;
|
|
1266
|
-
if (serverType === "mao") {
|
|
1267
|
-
baseUrl = ctx.globalConfig.maoServerUrl;
|
|
1268
|
-
serverName = body.name || "MaoMaNi";
|
|
1269
|
-
} else if (serverType === "official") {
|
|
1270
|
-
baseUrl = ctx.globalConfig.official_support_url;
|
|
1271
|
-
serverName = body.name || "Official";
|
|
1272
|
-
} else {
|
|
1273
|
-
if (!body.baseUrl) return badRequest(kctx, "baseUrl is required for asphyxia servers");
|
|
1274
|
-
if (!body.name) return badRequest(kctx, "name is required for asphyxia servers");
|
|
1275
|
-
baseUrl = body.baseUrl;
|
|
1276
|
-
serverName = body.name;
|
|
1277
|
-
}
|
|
1278
|
-
const serverService = new ServerService(ctx);
|
|
1279
|
-
const userService = new UserService(ctx);
|
|
1280
|
-
const server2 = await serverService.createServerForUser(
|
|
1281
|
-
{
|
|
1282
|
-
type: serverType,
|
|
1283
|
-
name: serverName,
|
|
1284
|
-
baseUrl,
|
|
1285
|
-
pcbid: body.pcbid,
|
|
1286
|
-
supportedGames: []
|
|
1287
|
-
},
|
|
1288
|
-
payload.uid
|
|
1289
|
-
);
|
|
1290
|
-
const defaultServer = await serverService.getDefaultServerByUid(payload.uid);
|
|
1291
|
-
if (!defaultServer) {
|
|
1292
|
-
await userService.updateUserDefaultServer(payload.uid, server2.id);
|
|
1293
|
-
}
|
|
1294
|
-
kctx.status = 201;
|
|
1295
|
-
kctx.body = {
|
|
1296
|
-
id: server2.id,
|
|
1297
|
-
type: server2.type,
|
|
1298
|
-
name: server2.name,
|
|
1299
|
-
baseUrl: server2.baseUrl,
|
|
1300
|
-
pcbid: server2.pcbid ?? null
|
|
1301
|
-
};
|
|
1302
|
-
});
|
|
1303
|
-
ctx.server.patch("/noah/api/servers/:id", async (kctx) => {
|
|
1304
|
-
setCors(kctx);
|
|
1305
|
-
const payload = authenticate(kctx);
|
|
1306
|
-
if (!payload) return unauthorized(kctx);
|
|
1307
|
-
const serverId = Number(kctx.params.id);
|
|
1308
|
-
if (isNaN(serverId)) return badRequest(kctx, "Invalid server id");
|
|
1309
|
-
const serverService = new ServerService(ctx);
|
|
1310
|
-
const servers = await serverService.getServersByUid(payload.uid);
|
|
1311
|
-
if (!servers.find((s) => s.id === serverId)) {
|
|
1312
|
-
kctx.status = 404;
|
|
1313
|
-
kctx.body = { error: "Server not found" };
|
|
1314
|
-
return;
|
|
1315
|
-
}
|
|
1316
|
-
const body = kctx.request.body ?? {};
|
|
1317
|
-
const update = {};
|
|
1318
|
-
if (body.name !== void 0) update.name = body.name;
|
|
1319
|
-
if (body.baseUrl !== void 0) update.baseUrl = body.baseUrl;
|
|
1320
|
-
if (body.pcbid !== void 0) update.pcbid = body.pcbid;
|
|
1321
|
-
if (Object.keys(update).length > 0) {
|
|
1322
|
-
await serverService.updateServer(serverId, update);
|
|
1323
|
-
}
|
|
1324
|
-
const updated = await serverService.getServerById(serverId);
|
|
1325
|
-
kctx.body = {
|
|
1326
|
-
id: updated.id,
|
|
1327
|
-
type: updated.type,
|
|
1328
|
-
name: updated.name,
|
|
1329
|
-
baseUrl: updated.baseUrl,
|
|
1330
|
-
pcbid: updated.pcbid ?? null
|
|
1331
|
-
};
|
|
1332
|
-
});
|
|
1333
|
-
ctx.server.delete("/noah/api/servers/:id", async (kctx) => {
|
|
1334
|
-
setCors(kctx);
|
|
1335
|
-
const payload = authenticate(kctx);
|
|
1336
|
-
if (!payload) return unauthorized(kctx);
|
|
1337
|
-
const serverId = Number(kctx.params.id);
|
|
1338
|
-
if (isNaN(serverId)) return badRequest(kctx, "Invalid server id");
|
|
1339
|
-
const serverService = new ServerService(ctx);
|
|
1340
|
-
const servers = await serverService.getServersByUid(payload.uid);
|
|
1341
|
-
if (!servers.find((s) => s.id === serverId)) {
|
|
1342
|
-
kctx.status = 404;
|
|
1343
|
-
kctx.body = { error: "Server not found" };
|
|
1344
|
-
return;
|
|
1345
|
-
}
|
|
1346
|
-
await serverService.removeServer(serverId);
|
|
1347
|
-
kctx.status = 204;
|
|
1348
|
-
});
|
|
1349
|
-
ctx.server.put("/noah/api/defaults", async (kctx) => {
|
|
1350
|
-
setCors(kctx);
|
|
1351
|
-
const payload = authenticate(kctx);
|
|
1352
|
-
if (!payload) return unauthorized(kctx);
|
|
1353
|
-
const body = kctx.request.body ?? {};
|
|
1354
|
-
const userService = new UserService(ctx);
|
|
1355
|
-
const cardService = new CardService(ctx);
|
|
1356
|
-
const serverService = new ServerService(ctx);
|
|
1357
|
-
if (body.defaultCardId !== void 0) {
|
|
1358
|
-
if (body.defaultCardId === null || body.defaultCardId === 0) {
|
|
1359
|
-
await userService.updateUserDefaultCard(payload.uid, 0);
|
|
1360
|
-
} else {
|
|
1361
|
-
const cards = await cardService.getCardsByUid(payload.uid);
|
|
1362
|
-
if (!cards.find((c) => c.id === body.defaultCardId)) {
|
|
1363
|
-
return badRequest(kctx, "Card not found");
|
|
1364
|
-
}
|
|
1365
|
-
await userService.updateUserDefaultCard(payload.uid, body.defaultCardId);
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1368
|
-
if (body.defaultServerId !== void 0) {
|
|
1369
|
-
if (body.defaultServerId === null || body.defaultServerId === 0) {
|
|
1370
|
-
await userService.updateUserDefaultServer(payload.uid, 0);
|
|
1371
|
-
} else {
|
|
1372
|
-
const servers = await serverService.getServersByUid(payload.uid);
|
|
1373
|
-
if (!servers.find((s) => s.id === body.defaultServerId)) {
|
|
1374
|
-
return badRequest(kctx, "Server not found");
|
|
1375
|
-
}
|
|
1376
|
-
await userService.updateUserDefaultServer(payload.uid, body.defaultServerId);
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
const defaultCard = await cardService.getDefaultCardByUid(payload.uid);
|
|
1380
|
-
const defaultServer = await serverService.getDefaultServerByUid(payload.uid);
|
|
1381
|
-
kctx.body = {
|
|
1382
|
-
defaultCardId: defaultCard?.id ?? null,
|
|
1383
|
-
defaultServerId: defaultServer?.id ?? null
|
|
1384
|
-
};
|
|
1385
|
-
});
|
|
1386
|
-
ctx.server.get("/noah/api/resolve", async (kctx) => {
|
|
1387
|
-
setCors(kctx);
|
|
1388
|
-
const payload = authenticate(kctx);
|
|
1389
|
-
if (!payload) return unauthorized(kctx);
|
|
1390
|
-
const cardService = new CardService(ctx);
|
|
1391
|
-
const serverService = new ServerService(ctx);
|
|
1392
|
-
const cards = await cardService.getCardsByUid(payload.uid);
|
|
1393
|
-
const defaultCard = await cardService.getDefaultCardByUid(payload.uid);
|
|
1394
|
-
const result = await Promise.all(
|
|
1395
|
-
cards.map(async (card2) => {
|
|
1396
|
-
let resolvedServer = null;
|
|
1397
|
-
if (card2.defaultServerId && card2.defaultServerId !== 0) {
|
|
1398
|
-
resolvedServer = await serverService.getServerById(card2.defaultServerId);
|
|
1399
|
-
}
|
|
1400
|
-
if (!resolvedServer) {
|
|
1401
|
-
resolvedServer = await serverService.getDefaultServerByUid(payload.uid);
|
|
1402
|
-
}
|
|
1403
|
-
return {
|
|
1404
|
-
cardId: card2.id,
|
|
1405
|
-
cardName: card2.name,
|
|
1406
|
-
isDefaultCard: defaultCard?.id === card2.id,
|
|
1407
|
-
resolvedServerId: resolvedServer?.id ?? null,
|
|
1408
|
-
resolvedServerName: resolvedServer?.name ?? null,
|
|
1409
|
-
source: card2.defaultServerId && card2.defaultServerId !== 0 ? "card" : "user-default"
|
|
1410
|
-
};
|
|
1411
|
-
})
|
|
1412
|
-
);
|
|
1413
|
-
kctx.body = result;
|
|
1414
|
-
});
|
|
1415
|
-
}
|
|
1416
|
-
__name(registerApiRoutes, "registerApiRoutes");
|
|
1417
|
-
|
|
1418
|
-
// src/core/command.ts
|
|
1419
|
-
var command_exports = {};
|
|
1420
|
-
__export(command_exports, {
|
|
1421
|
-
apply: () => apply2,
|
|
1422
|
-
name: () => name2
|
|
1423
|
-
});
|
|
1424
|
-
|
|
1425
1018
|
// src/core/commands/bind.ts
|
|
1426
1019
|
function bind(ctx, config) {
|
|
1427
1020
|
ctx.command("bind [cardCode:text]", { slash: true }).alias("绑卡").userFields(["defaultCardId", "id"]).action(async ({ session }, cardCode) => {
|
|
@@ -1793,9 +1386,8 @@ __name(showCardMenu, "showCardMenu");
|
|
|
1793
1386
|
// src/core/commands/help.ts
|
|
1794
1387
|
function help(ctx, config) {
|
|
1795
1388
|
ctx.command("help", { slash: true }).alias("帮助").action(({ session }) => {
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
return msg;
|
|
1389
|
+
console.log(session);
|
|
1390
|
+
return session.text(".content");
|
|
1799
1391
|
});
|
|
1800
1392
|
}
|
|
1801
1393
|
__name(help, "help");
|
|
@@ -1991,6 +1583,11 @@ __name(maintain, "maintain");
|
|
|
1991
1583
|
|
|
1992
1584
|
// src/core/commands/server.ts
|
|
1993
1585
|
var import_koishi5 = require("koishi");
|
|
1586
|
+
|
|
1587
|
+
// src/types/index.ts
|
|
1588
|
+
var serverValues = ["asphyxia", "mao", "official"];
|
|
1589
|
+
|
|
1590
|
+
// src/core/commands/server.ts
|
|
1994
1591
|
function normalizeUrl(url) {
|
|
1995
1592
|
try {
|
|
1996
1593
|
if (!url.match(/^https?:\/\//i)) {
|
|
@@ -2397,19 +1994,6 @@ async function addServer(ctx, session, serverService, userService, from, uid, us
|
|
|
2397
1994
|
}
|
|
2398
1995
|
__name(addServer, "addServer");
|
|
2399
1996
|
|
|
2400
|
-
// src/core/commands/settings.ts
|
|
2401
|
-
function settings(ctx, apiCtx) {
|
|
2402
|
-
ctx.command("settings", { slash: true }).alias("设置", "setting").userFields(["id"]).channelFields(["id"]).action(async ({ session }) => {
|
|
2403
|
-
const atGuild = session.guildId != null;
|
|
2404
|
-
if (atGuild) return session.text(".dm-only");
|
|
2405
|
-
const { secret, tokenTtl, frontendUrl } = apiCtx;
|
|
2406
|
-
const token = createToken(session.user.id, secret, tokenTtl);
|
|
2407
|
-
const url = frontendUrl ? `${frontendUrl}?token=${token}` : `Token: ${token}`;
|
|
2408
|
-
return session.text(".success", { url, minutes: Math.floor(tokenTtl / 60) });
|
|
2409
|
-
});
|
|
2410
|
-
}
|
|
2411
|
-
__name(settings, "settings");
|
|
2412
|
-
|
|
2413
1997
|
// src/core/command.ts
|
|
2414
1998
|
var name2 = "command";
|
|
2415
1999
|
function apply2(ctx, config) {
|
|
@@ -2420,9 +2004,6 @@ function apply2(ctx, config) {
|
|
|
2420
2004
|
locale(ctx, config);
|
|
2421
2005
|
link(ctx, config);
|
|
2422
2006
|
maintain(ctx, config);
|
|
2423
|
-
if (config._apiCtx) {
|
|
2424
|
-
settings(ctx, config._apiCtx);
|
|
2425
|
-
}
|
|
2426
2007
|
}
|
|
2427
2008
|
__name(apply2, "apply");
|
|
2428
2009
|
|
|
@@ -2667,17 +2248,17 @@ function apply4(ctx, config) {
|
|
|
2667
2248
|
__name(apply4, "apply");
|
|
2668
2249
|
|
|
2669
2250
|
// src/core/locales/en-US.yml
|
|
2670
|
-
var en_US_default2 = { _config: { $desc: "Core Module Settings", adminUsers: "**Plugin Admin** User ID (use inspect command to get)", guildNameCards: "**Group Card** Name List", maoServerUrl: "**Mao Server** URL address", official_support_url: "**Official Support** URL address"
|
|
2251
|
+
var en_US_default2 = { _config: { $desc: "Core Module Settings", adminUsers: "**Plugin Admin** User ID (use inspect command to get)", guildNameCards: "**Group Card** Name List", maoServerUrl: "**Mao Server** URL address", official_support_url: "**Official Support** URL address" }, commands: { maintain: { description: "Switch to maintenance mode", messages: { "no-auth": "<p>You don't have permission to use this feature~</p>", start: "<p>Entering maintenance mode</p>", "success-start": "<p>Successfully switched to maintenance mode</p>", stop: "<p>Exiting maintenance mode</p>", "success-stop": "<p>Successfully exited maintenance mode</p>" } }, timeout: "Noah didn't wait for your reply, please try again!", help: { description: "Show Noah help information", messages: { content: "<p>Guide:</p>\nhttps://docs.logthm.cn/noah" } }, locale: { description: "Set language", messages: { "no-auth": "<p>Only group admins can use this feature~</p>", "invalid-select": "<p>No such option!</p>", quit: "<p>Quit!</p>", "reset-channel": "<p>Reset successfully!</p>", "reset-user": "<p>Reset successfully!</p>", success: "<p>Set successfully!</p>", "set-channel": "<p>Select the default language for group chats:</p>\n<p>1. 简体中文</p>\n<p>2. English</p>\n<p>q. Quit</p>", "set-user": "<p>Select the language you use:</p>\n<p>1. 中文</p>\n<p>2. English</p>\n<p>q. Quit</p>" } }, link: { description: "Link account to another platform", options: { remove: "Unlink" }, messages: { "generated-1": `<p>The Link command can be used to link user data across multiple platforms. During the linking process, the original platform's user data is fully preserved, while the target platform's user data is overwritten.</p>
|
|
2671
2252
|
<p>Please make sure the current platform is your target platform and send the following text to the bot on the original platform within 5 minutes:</p>
|
|
2672
2253
|
<p>{0}</p>
|
|
2673
|
-
<p>Once linked, you can use "link -r" to unlink at any time.</p>`, "generated-2": "<p>Token verified! Now proceeding to the second step.</p>\n<p>Please send the following text to the bot on the target platform within 5 minutes:</p>\n<p>{0}</p>\n<p>Note: The current platform is your original platform. User data here will overwrite the target platform's data.</p>", "self-1": "<p>Please enter this on the original platform.</p>", "self-2": "<p>Please enter this on the target platform.</p>", success: "<p>Account linked successfully!</p>", "remove-success": "<p>Account unlinked successfully!</p>", "remove-original": "<p>Cannot unlink: this is your original account.</p>" } }, bind: { description: "Bind card", messages: { prompt: "<p>Please enter your card number:</p>", "convert-access-failed": "<p>Failed to convert Access Code, please use 16-digit card code instead.</p>", "invalid-code": "<p>The card number is incorrect, if you don't remember it, go to the arcade to check it~</p>", name: "<p>Received! Please give this card a name, no spaces allowed:</p>", "invalid-name": "<p>No spaces allowed! Please try again o(一︿一+)o</p>", success: "<p>Bound successfully, your card information is as follows:</p>\n<p>[{cardName}]</p>\n<p>{cardCode}</p>" } }, card: { description: "Manage cards", options: { detail: "Show detailed card information" }, messages: { "invalid-code": "<p>The card number is incorrect, if you don't remember it, go to the arcade to check it~</p>", "invalid-select": "<p>No such option!</p>", "lookup-error": "Lookup failed: {message}", "lookup-error-unknown": "Lookup failed: unknown error", "menu-select": "<p>[Card Management]</p>\n{card_list}\n<p>0. Add new card</p>\n<p>Please enter the serial number:</p>", menu: "<p>[{name}]</p>\n<p>1. Set as default card</p>\n<p>2. View or modify card number</p>\n<p>3. Delete the card</p>\n<p>4. Rename the card</p>\n<p>5. Bind the card to a specified server</p>\n<p>0. Return to card selection</p>\n<p>Please enter the serial number:</p>", "menu-has-bound-server": "<p>[{name}]</p>\n<p>Bound server: {defaultServerName}</p>\n<p>1. Set as default card</p>\n<p>2. View or modify card number</p>\n<p>3. Delete the card</p>\n<p>4. Rename the card</p>\n<p>5. Bind the card to a specified server</p>\n<p>0. Return to card selection</p>\n<p>Please enter the serial number:</p>", "menu-1-success": "<p>Set successfully!</p>", "menu-1-error-duplicate": "<p>The selected card is the same as the old default card!</p>", "menu-2-prompt": "<p>Card number: {code}</p>\n<p>Please enter the new card number:</p>\n<p>Enter 0 to return</p>", "menu-2-success": "<p>Modified successfully!</p>", "menu-2-error-invalid-code": "<p>The card number is incorrect, if you don't remember it, go to the arcade to check it~</p>", "menu-3-success": "<p>Deleted successfully!</p>", "menu-4-prompt": "<p>Enter a new name, no spaces allowed:</p>", "menu-4-error-invalid-name": "<p>No spaces allowed! Please try again o(一︿一+)o</p>", "menu-4-success": "<p>Modified successfully!</p>", "menu-5": "{server_list}\n<p>Please enter the serial number:</p>", "menu-5-success": "<p>Set successfully!</p>", "menu-5-error-duplicate": "<p>The selected server is the same as the old default server!</p>" } }, server: { description: "Manage servers", messages: { "no-channel": "<p>Please use this feature in group chats~</p>", "invalid-select": "<p>No such option!</p>", "no-auth": "<p>Only group admins can use this feature~</p>", "admin-menu-select": "<p>[Group server management]</p>\n{server_list}\n<p>0. Add new server</p>\n<p>Please enter the serial number:</p>", "menu-select": "<p>[Server management]</p>\n{server_list}\n<p>0. Add new server</p>\n<p>Please enter the serial number:</p>", menu: "<p>[{name}]</p>\n<p>Type: {type}</p>\n<p>1. Set as default server</p>\n<p>2. View or modify url</p>\n<p>3. Delete the server</p>\n<p>4. Rename the server</p>\n<p>0. Return to server selection</p>\n<p>Please enter the serial number:</p>", "menu-1-success": "<p>Set successfully!</p>", "menu-1-error-duplicate": "<p>The selected server is the same as the old default server!</p>", "menu-2-prompt": "<p>The server's url: {baseUrl}</p>\n<p>Please enter the new server url:</p>\n<p>Enter 0 to return</p>", "menu-2-success": "<p>Modified successfully!</p>", "menu-2-invalid-url": "<p>Invalid URL format! Please enter a valid url address.</p>", "menu-2-too-many-attempts": "<p>Too many attempts. Operation cancelled.</p>", "menu-3-success": "<p>Deleted successfully!</p>", "menu-4-prompt": "<p>Enter a new name, no spaces allowed:</p>", "menu-4-error-invalid-name": "<p>No spaces allowed! Please try again o(一︿一+)o</p>", "menu-4-success": "<p>Modified successfully!</p>", "add-type": "<p>Please select the server type:</p>\n{server_type_list}", "add-url": "<p>Please enter the server url:</p>", "add-invalid-url": "<p>Invalid URL format! Please enter a valid url address.</p>", "add-too-many-attempts": "<p>Too many attempts. Operation cancelled.</p>", "add-name": "<p>Received! Please give the server a name, no spaces allowed:</p>", "add-invalid-name": "<p>No spaces allowed! Please try again o(一︿一+)o</p>", "add-success": "<p>Added successfully, the server information is as follows:</p>\n<p>[{serverName}]</p>\n<p>Type: {serverType}</p>" } }
|
|
2254
|
+
<p>Once linked, you can use "link -r" to unlink at any time.</p>`, "generated-2": "<p>Token verified! Now proceeding to the second step.</p>\n<p>Please send the following text to the bot on the target platform within 5 minutes:</p>\n<p>{0}</p>\n<p>Note: The current platform is your original platform. User data here will overwrite the target platform's data.</p>", "self-1": "<p>Please enter this on the original platform.</p>", "self-2": "<p>Please enter this on the target platform.</p>", success: "<p>Account linked successfully!</p>", "remove-success": "<p>Account unlinked successfully!</p>", "remove-original": "<p>Cannot unlink: this is your original account.</p>" } }, bind: { description: "Bind card", messages: { prompt: "<p>Please enter your card number:</p>", "convert-access-failed": "<p>Failed to convert Access Code, please use 16-digit card code instead.</p>", "invalid-code": "<p>The card number is incorrect, if you don't remember it, go to the arcade to check it~</p>", name: "<p>Received! Please give this card a name, no spaces allowed:</p>", "invalid-name": "<p>No spaces allowed! Please try again o(一︿一+)o</p>", success: "<p>Bound successfully, your card information is as follows:</p>\n<p>[{cardName}]</p>\n<p>{cardCode}</p>" } }, card: { description: "Manage cards", options: { detail: "Show detailed card information" }, messages: { "invalid-code": "<p>The card number is incorrect, if you don't remember it, go to the arcade to check it~</p>", "invalid-select": "<p>No such option!</p>", "lookup-error": "Lookup failed: {message}", "lookup-error-unknown": "Lookup failed: unknown error", "menu-select": "<p>[Card Management]</p>\n{card_list}\n<p>0. Add new card</p>\n<p>Please enter the serial number:</p>", menu: "<p>[{name}]</p>\n<p>1. Set as default card</p>\n<p>2. View or modify card number</p>\n<p>3. Delete the card</p>\n<p>4. Rename the card</p>\n<p>5. Bind the card to a specified server</p>\n<p>0. Return to card selection</p>\n<p>Please enter the serial number:</p>", "menu-has-bound-server": "<p>[{name}]</p>\n<p>Bound server: {defaultServerName}</p>\n<p>1. Set as default card</p>\n<p>2. View or modify card number</p>\n<p>3. Delete the card</p>\n<p>4. Rename the card</p>\n<p>5. Bind the card to a specified server</p>\n<p>0. Return to card selection</p>\n<p>Please enter the serial number:</p>", "menu-1-success": "<p>Set successfully!</p>", "menu-1-error-duplicate": "<p>The selected card is the same as the old default card!</p>", "menu-2-prompt": "<p>Card number: {code}</p>\n<p>Please enter the new card number:</p>\n<p>Enter 0 to return</p>", "menu-2-success": "<p>Modified successfully!</p>", "menu-2-error-invalid-code": "<p>The card number is incorrect, if you don't remember it, go to the arcade to check it~</p>", "menu-3-success": "<p>Deleted successfully!</p>", "menu-4-prompt": "<p>Enter a new name, no spaces allowed:</p>", "menu-4-error-invalid-name": "<p>No spaces allowed! Please try again o(一︿一+)o</p>", "menu-4-success": "<p>Modified successfully!</p>", "menu-5": "{server_list}\n<p>Please enter the serial number:</p>", "menu-5-success": "<p>Set successfully!</p>", "menu-5-error-duplicate": "<p>The selected server is the same as the old default server!</p>" } }, server: { description: "Manage servers", messages: { "no-channel": "<p>Please use this feature in group chats~</p>", "invalid-select": "<p>No such option!</p>", "no-auth": "<p>Only group admins can use this feature~</p>", "admin-menu-select": "<p>[Group server management]</p>\n{server_list}\n<p>0. Add new server</p>\n<p>Please enter the serial number:</p>", "menu-select": "<p>[Server management]</p>\n{server_list}\n<p>0. Add new server</p>\n<p>Please enter the serial number:</p>", menu: "<p>[{name}]</p>\n<p>Type: {type}</p>\n<p>1. Set as default server</p>\n<p>2. View or modify url</p>\n<p>3. Delete the server</p>\n<p>4. Rename the server</p>\n<p>0. Return to server selection</p>\n<p>Please enter the serial number:</p>", "menu-1-success": "<p>Set successfully!</p>", "menu-1-error-duplicate": "<p>The selected server is the same as the old default server!</p>", "menu-2-prompt": "<p>The server's url: {baseUrl}</p>\n<p>Please enter the new server url:</p>\n<p>Enter 0 to return</p>", "menu-2-success": "<p>Modified successfully!</p>", "menu-2-invalid-url": "<p>Invalid URL format! Please enter a valid url address.</p>", "menu-2-too-many-attempts": "<p>Too many attempts. Operation cancelled.</p>", "menu-3-success": "<p>Deleted successfully!</p>", "menu-4-prompt": "<p>Enter a new name, no spaces allowed:</p>", "menu-4-error-invalid-name": "<p>No spaces allowed! Please try again o(一︿一+)o</p>", "menu-4-success": "<p>Modified successfully!</p>", "add-type": "<p>Please select the server type:</p>\n{server_type_list}", "add-url": "<p>Please enter the server url:</p>", "add-invalid-url": "<p>Invalid URL format! Please enter a valid url address.</p>", "add-too-many-attempts": "<p>Too many attempts. Operation cancelled.</p>", "add-name": "<p>Received! Please give the server a name, no spaces allowed:</p>", "add-invalid-name": "<p>No spaces allowed! Please try again o(一︿一+)o</p>", "add-success": "<p>Added successfully, the server information is as follows:</p>\n<p>[{serverName}]</p>\n<p>Type: {serverType}</p>" } } } };
|
|
2674
2255
|
|
|
2675
2256
|
// src/core/locales/zh-CN.yml
|
|
2676
|
-
var zh_CN_default2 = { _config: { $desc: "Core 模块设置", adminUsers: "**插件管理员** 的用户id (使用 inspect 指令获取)", guildNameCards: "**群聊卡片** 的名称列表",
|
|
2257
|
+
var zh_CN_default2 = { _config: { $desc: "Core 模块设置", adminUsers: "**插件管理员** 的用户id (使用 inspect 指令获取)", guildNameCards: "**群聊卡片** 的名称列表", maoServerUrl: "**猫网服务器** 的 URL 地址", official_support_url: "**官方支持** 的 URL 地址" }, commands: { maintain: { description: "切换到维护模式", messages: { "no-auth": "<p>你没有权限使用本功能哦~</p>", start: "<p>正在进入维护模式</p>", "success-start": "<p>成功切换到维护模式</p>", stop: "<p>正在退出维护模式</p>", "success-stop": "<p>成功退出维护模式</p>" } }, timeout: "Noah 没等到你的回复,请重试!", help: { description: "显示 Noah 帮助信息", messages: { content: "<p>使用文档:</p>\nhttps://docs.logthm.cn/noah" } }, locale: { description: "设置语言", messages: { "no-auth": "<p>只有群管理员能使用本功能哦~</p>", "invalid-select": "<p>没有该选项!</p>", quit: "<p>已退出~</p>", "reset-channel": "<p>重置成功!</p>", "reset-user": "<p>重置成功!</p>", success: "<p>设置成功!</p>", "set-channel": "<p>选择群聊默认使用的语言:</p>\n<p>1. 简体中文</p>\n<p>2. English</p>\n<p>q. 退出</p>", "set-user": "<p>选择你使用的语言:</p>\n<p>1. 简体中文</p>\n<p>2. English</p>\n<p>q. 退出</p>" } }, link: { description: "关联账号到其他平台", options: { remove: "解除关联" }, messages: { "generated-1": "<p>Link 指令可用于在多个平台间关联用户数据。关联过程中,原始平台的用户数据将完全保留,而目标平台的用户数据将被原始平台的数据所覆盖。</p>\n<p>请确认当前平台是你的目标平台,并在 5 分钟内使用你的账号在原始平台内向机器人发送以下文本:</p>\n<p>{0}</p>\n<p>关联完成后,你可以随时使用「link -r」来解除关联。</p>", "generated-2": "<p>令牌核验成功!下面将进行第二步操作。</p>\n<p>请在 5 分钟内使用你的账号在目标平台内向机器人发送以下文本:</p>\n<p>{0}</p>\n<p>注意:当前平台是你的原始平台,这里的用户数据将覆盖目标平台的数据。</p>", "self-1": "<p>请前往原始平台输入。</p>", "self-2": "<p>请前往目标平台输入。</p>", success: "<p>账号关联成功!</p>", "remove-success": "<p>账号解除关联成功!</p>", "remove-original": "<p>无法解除关联:这是你的原始账号。</p>" } }, bind: { description: "绑定卡片", messages: { prompt: "<p>请输入你的卡号:</p>", "convert-access-failed": "<p>转换 Access Code 失败,请使用 16 位卡号进行绑定。</p>", "invalid-code": "<p>卡号不对哟,不记得的话去机台刷一下吧~</p>", name: "<p>收到!为这张卡取一个名字吧,不要带空格哦:</p>", "invalid-name": "<p>名字不要带空格!重来重来 o(一︿一+)o</p>", success: "<p>绑好啦,你的卡片信息如下:</p>\n<p>[{cardName}]</p>\n<p>{cardCode}</p>" } }, card: { description: "管理卡片", options: { detail: "显示卡片详细信息" }, messages: { "invalid-code": "<p>卡号不对哟,不记得的话去机台刷一下吧~</p>", "invalid-select": "<p>没有该选项!</p>", quit: "<p>已退出~</p>", "lookup-error": "查询失败: {message}", "lookup-error-unknown": "查询失败: 未知错误", "menu-select": "<p>[卡片管理]</p>\n{card_list}\n<p>0. 添加新卡片</p>\n<p>q. 退出菜单</p>\n<p>请输入序号:</p>", menu: "<p>[{name}]</p>\n<p>1. 设为默认卡片</p>\n<p>2. 查看或修改卡号</p>\n<p>3. 删除该卡</p>\n<p>4. 重命名该卡片</p>\n<p>5. 将卡片与指定服务器绑定</p>\n<p>0. 返回卡片选择</p>\n<p>q. 退出菜单</p>\n<p>请输入序号:</p>", "menu-has-bound-server": "<p>[{name}]</p>\n<p>已绑定服务器:{defaultServerName}</p>\n<p>1. 设为默认卡片</p>\n<p>2. 查看或修改卡号</p>\n<p>3. 删除该卡</p>\n<p>4. 重命名该卡片</p>\n<p>5. 将卡片与指定服务器绑定</p>\n<p>0. 返回卡片选择</p>\n<p>q. 退出菜单</p>\n<p>请输入序号:</p>", "menu-1-success": "<p>设置成功!</p>", "menu-1-error-duplicate": "<p>选择的卡片与旧的默认卡片相同!</p>", "menu-2-prompt": "<p>卡号:{code}</p>\n<p>请输入新的卡号:</p>\n<p>0. 返回</p>\n<p>q. 退出</p>", "menu-2-success": "<p>修改成功!</p>", "menu-2-error-invalid-code": "<p>卡号不对哟,不记得的话去机台刷一下吧~</p>", "menu-3-success": "<p>已删除!</p>", "menu-4-prompt": "<p>输入一个新名字,不要带空格哦:</p>\n<p>q. 退出</p>", "menu-4-error-invalid-name": "<p>名字不要带空格!重来重来 o(一︿一+)o</p>", "menu-4-success": "<p>修改成功!</p>", "menu-5": "<p>请选择一个服务器:</p>\n{server_list}\n<p>q. 退出</p>", "menu-5-success": "<p>设置成功!</p>", "menu-5-error-duplicate": "<p>选择的服务器与旧的默认服务器相同!</p>" } }, server: { description: "管理服务器", messages: { "no-channel": "<p>请在群聊中使用本功能哦~</p>", "invalid-select": "<p>没有该选项!</p>", "no-auth": "<p>只有群管理员能使用本功能哦~</p>", quit: "<p>已退出~</p>", "admin-menu-select": "<p>[群聊服务器管理]</p>\n{server_list}\n<p>0. 添加新服务器</p>\n<p>q. 退出菜单</p>\n<p>请输入序号:</p>", "menu-select": "<p>[服务器管理]</p>\n{server_list}\n<p>0. 添加新服务器</p>\n<p>q. 退出菜单</p>\n<p>请输入序号:</p>", menu: "<p>[{name}]</p>\n<p>类型:{type}</p>\n<p>1. 设为默认服务器</p>\n<p>2. 查看或修改 url</p>\n<p>3. 删除该服务器</p>\n<p>4. 重命名该服务器</p>\n<p>0. 返回服务器选择</p>\n<p>q. 退出菜单</p>\n<p>请输入序号:</p>", "menu-1-success": "<p>设置成功!</p>", "menu-1-error-duplicate": "<p>选择的服务器与旧的默认服务器相同!</p>", "menu-2-prompt": "<p>该服务器的 url:{baseUrl}</p>\n<p>请输入新的服务器 url:</p>\n<p>0. 返回</p>\n<p>q. 退出</p>", "menu-2-success": "<p>修改成功!</p>", "menu-2-invalid-url": "<p>URL 格式不正确!请输入有效的 url 地址。</p>", "menu-2-too-many-attempts": "<p>尝试次数过多,操作已取消。</p>", "menu-3-success": "<p>已删除!</p>", "menu-4-prompt": "<p>输入一个新名字,不要带空格哦:</p>\n<p>0. 返回</p>\n<p>q. 退出</p>", "menu-4-error-invalid-name": "<p>名字不要带空格!重来重来 o(一︿一+)o</p>", "menu-4-success": "<p>修改成功!</p>", "add-type": "<p>请选择服务器的类型:</p>\n{server_type_list}\n<p>q. 退出</p>", "add-url": "<p>请输入服务器的 url:</p>\n<p>q. 退出</p>", "add-invalid-url": "<p>URL 格式不正确!请输入有效的 url 地址。</p>", "add-too-many-attempts": "<p>尝试次数过多,操作已取消。</p>", "add-name": "<p>收到!为服务器取一个名字吧,不要带空格哦:</p>\n<p>q. 退出</p>", "add-invalid-name": "<p>名字不要带空格!重来重来 o(一︿一+)o</p>", "add-success": "<p>添加成功啦,服务器信息如下:</p>\n<p>[{serverName}]</p>\n<p>类型:{serverType}</p>" } } } };
|
|
2677
2258
|
|
|
2678
2259
|
// src/core/index.ts
|
|
2679
2260
|
var name5 = "Noah-Core";
|
|
2680
|
-
var inject = ["database", "globalConfig"
|
|
2261
|
+
var inject = ["database", "globalConfig"];
|
|
2681
2262
|
var logger2 = new import_koishi6.Logger("Noah-Core");
|
|
2682
2263
|
function apply5(ctx, config) {
|
|
2683
2264
|
;
|
|
@@ -2685,11 +2266,9 @@ function apply5(ctx, config) {
|
|
|
2685
2266
|
["en-US", en_US_default2],
|
|
2686
2267
|
["zh-CN", zh_CN_default2]
|
|
2687
2268
|
].forEach(([lang, file]) => ctx.i18n.define(lang, file));
|
|
2688
|
-
const apiCtx = resolveApiContext(config.core);
|
|
2689
2269
|
ctx.plugin(database_exports, config.core);
|
|
2690
|
-
ctx.plugin(command_exports,
|
|
2270
|
+
ctx.plugin(command_exports, config.core);
|
|
2691
2271
|
ctx.plugin(event_exports, config.core);
|
|
2692
|
-
registerApiRoutes(ctx, apiCtx);
|
|
2693
2272
|
}
|
|
2694
2273
|
__name(apply5, "apply");
|
|
2695
2274
|
|
|
@@ -2708,7 +2287,6 @@ var BaseDrawer = class {
|
|
|
2708
2287
|
constructor(ctx) {
|
|
2709
2288
|
this.ctx = ctx;
|
|
2710
2289
|
}
|
|
2711
|
-
ctx;
|
|
2712
2290
|
static {
|
|
2713
2291
|
__name(this, "BaseDrawer");
|
|
2714
2292
|
}
|
|
@@ -2748,7 +2326,6 @@ var CoreDrawer = class extends BaseDrawer {
|
|
|
2748
2326
|
super(ctx);
|
|
2749
2327
|
this.ctx = ctx;
|
|
2750
2328
|
}
|
|
2751
|
-
ctx;
|
|
2752
2329
|
static {
|
|
2753
2330
|
__name(this, "CoreDrawer");
|
|
2754
2331
|
}
|
|
@@ -2784,7 +2361,6 @@ var IIDXDrawer = class extends BaseDrawer {
|
|
|
2784
2361
|
super(ctx);
|
|
2785
2362
|
this.ctx = ctx;
|
|
2786
2363
|
}
|
|
2787
|
-
ctx;
|
|
2788
2364
|
static {
|
|
2789
2365
|
__name(this, "IIDXDrawer");
|
|
2790
2366
|
}
|
|
@@ -3069,12 +2645,12 @@ function getNextVFIncrease(level, currentScore, clearType) {
|
|
|
3069
2645
|
}
|
|
3070
2646
|
__name(getNextVFIncrease, "getNextVFIncrease");
|
|
3071
2647
|
function getGradeRange(grade) {
|
|
3072
|
-
if (!grade) return ALL_GRADES
|
|
2648
|
+
if (!grade) return ALL_GRADES;
|
|
3073
2649
|
return Array.isArray(grade) ? grade : [grade];
|
|
3074
2650
|
}
|
|
3075
2651
|
__name(getGradeRange, "getGradeRange");
|
|
3076
2652
|
function getClearTypeRange(clearType) {
|
|
3077
|
-
if (!clearType) return ALL_CLEAR_TYPES
|
|
2653
|
+
if (!clearType) return ALL_CLEAR_TYPES;
|
|
3078
2654
|
return Array.isArray(clearType) ? clearType : [clearType];
|
|
3079
2655
|
}
|
|
3080
2656
|
__name(getClearTypeRange, "getClearTypeRange");
|
|
@@ -3290,20 +2866,7 @@ function generateQueryResults(params) {
|
|
|
3290
2866
|
uniqueResults.push(result);
|
|
3291
2867
|
}
|
|
3292
2868
|
}
|
|
3293
|
-
const
|
|
3294
|
-
const excludeScoreSet = params.excludeScore ? new Set(params.excludeScore) : null;
|
|
3295
|
-
const excludeGradeSet = params.excludeGrade ? new Set(params.excludeGrade) : null;
|
|
3296
|
-
const excludeClearTypeSet = params.excludeClearType ? new Set(params.excludeClearType) : null;
|
|
3297
|
-
const excludeVfSet = params.excludeVf ? new Set(params.excludeVf.map((v) => Math.round(v * 20))) : null;
|
|
3298
|
-
const afterExclusion = uniqueResults.filter((result) => {
|
|
3299
|
-
if (excludeLevelSet && excludeLevelSet.has(Math.round(result.level * 10))) return false;
|
|
3300
|
-
if (excludeScoreSet && excludeScoreSet.has(result.score)) return false;
|
|
3301
|
-
if (excludeGradeSet && excludeGradeSet.has(result.grade)) return false;
|
|
3302
|
-
if (excludeClearTypeSet && excludeClearTypeSet.has(result.clearType)) return false;
|
|
3303
|
-
if (excludeVfSet && excludeVfSet.has(Math.round(result.vf * 20))) return false;
|
|
3304
|
-
return true;
|
|
3305
|
-
});
|
|
3306
|
-
const filteredResults = afterExclusion.filter((result) => result.clearType !== "S-PUC");
|
|
2869
|
+
const filteredResults = uniqueResults.filter((result) => result.clearType !== "S-PUC");
|
|
3307
2870
|
return filteredResults.sort((a, b) => b.vf - a.vf);
|
|
3308
2871
|
}
|
|
3309
2872
|
__name(generateQueryResults, "generateQueryResults");
|
|
@@ -3314,7 +2877,6 @@ var SDVXDrawer = class extends BaseDrawer {
|
|
|
3314
2877
|
super(ctx);
|
|
3315
2878
|
this.ctx = ctx;
|
|
3316
2879
|
}
|
|
3317
|
-
ctx;
|
|
3318
2880
|
static {
|
|
3319
2881
|
__name(this, "SDVXDrawer");
|
|
3320
2882
|
}
|
|
@@ -3331,8 +2893,8 @@ var SDVXDrawer = class extends BaseDrawer {
|
|
|
3331
2893
|
["Fredoka One", "fonts/FredokaOne.ttf"]
|
|
3332
2894
|
];
|
|
3333
2895
|
for (const [name15, file] of fonts) {
|
|
3334
|
-
const
|
|
3335
|
-
if (fs2.existsSync(
|
|
2896
|
+
const path3 = getAssetPath(this.ctx, file);
|
|
2897
|
+
if (fs2.existsSync(path3)) FontLibrary.use(name15, path3);
|
|
3336
2898
|
}
|
|
3337
2899
|
this.fontsLoaded = true;
|
|
3338
2900
|
}
|
|
@@ -3438,20 +3000,20 @@ var SDVXDrawer = class extends BaseDrawer {
|
|
|
3438
3000
|
ctx.save();
|
|
3439
3001
|
ctx.translate(556, 17);
|
|
3440
3002
|
ctx.beginPath();
|
|
3441
|
-
const r = 16, w = 100,
|
|
3003
|
+
const r = 16, w = 100, h10 = 200, x0 = 0, y0 = 0;
|
|
3442
3004
|
ctx.moveTo(x0 + r, y0);
|
|
3443
3005
|
ctx.lineTo(x0 + w - r, y0);
|
|
3444
3006
|
ctx.arcTo(x0 + w, y0, x0 + w, y0 + r, r);
|
|
3445
|
-
ctx.lineTo(x0 + w, y0 +
|
|
3446
|
-
ctx.arcTo(x0 + w, y0 +
|
|
3447
|
-
ctx.lineTo(x0 + r, y0 +
|
|
3448
|
-
ctx.arcTo(x0, y0 +
|
|
3007
|
+
ctx.lineTo(x0 + w, y0 + h10 - r);
|
|
3008
|
+
ctx.arcTo(x0 + w, y0 + h10, x0 + w - r, y0 + h10, r);
|
|
3009
|
+
ctx.lineTo(x0 + r, y0 + h10);
|
|
3010
|
+
ctx.arcTo(x0, y0 + h10, x0, y0 + h10 - r, r);
|
|
3449
3011
|
ctx.lineTo(x0, y0 + r);
|
|
3450
3012
|
ctx.arcTo(x0, y0, x0 + r, y0, r);
|
|
3451
3013
|
ctx.closePath();
|
|
3452
3014
|
const circleRadius = 14;
|
|
3453
3015
|
const circleX = x0 + w;
|
|
3454
|
-
const circleY = y0 +
|
|
3016
|
+
const circleY = y0 + h10 / 2;
|
|
3455
3017
|
ctx.moveTo(circleX + circleRadius, circleY);
|
|
3456
3018
|
ctx.arc(circleX, circleY, circleRadius, 0, Math.PI * 2, true);
|
|
3457
3019
|
ctx.clip();
|
|
@@ -4203,7 +3765,6 @@ var DrawerFactory = class {
|
|
|
4203
3765
|
constructor(ctx) {
|
|
4204
3766
|
this.ctx = ctx;
|
|
4205
3767
|
}
|
|
4206
|
-
ctx;
|
|
4207
3768
|
static {
|
|
4208
3769
|
__name(this, "DrawerFactory");
|
|
4209
3770
|
}
|
|
@@ -4280,20 +3841,154 @@ __name(apply6, "apply");
|
|
|
4280
3841
|
var poke_exports = {};
|
|
4281
3842
|
__export(poke_exports, {
|
|
4282
3843
|
apply: () => apply7,
|
|
4283
|
-
logger: () => logger3,
|
|
4284
3844
|
name: () => name7
|
|
4285
3845
|
});
|
|
4286
|
-
var
|
|
3846
|
+
var fs3 = __toESM(require("fs"), 1);
|
|
3847
|
+
var path2 = __toESM(require("path"), 1);
|
|
3848
|
+
var import_koishi8 = require("koishi");
|
|
4287
3849
|
|
|
4288
|
-
// src/fun/poke/
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
function
|
|
3850
|
+
// src/fun/poke/locales/en-US.yml
|
|
3851
|
+
var en_US_default3 = { _config: { $desc: "Poke Module Settings", interval: "最小触发间隔(毫秒)", warning: "频繁触发是否发送警告", prompt: "警告内容", messages: { $desc: "消息内容", content: "消息内容", weight: "权重" } }, commands: { poke: { description: "poke" } } };
|
|
3852
|
+
|
|
3853
|
+
// src/fun/poke/locales/zh-CN.yml
|
|
3854
|
+
var zh_CN_default3 = { _config: { $desc: "Poke 模块设置", interval: "最小触发间隔(毫秒)", warning: "频繁触发是否发送警告", prompt: { $desc: "警告内容", content: "消息", weight: "权重" }, messages: { $desc: "消息内容", content: "消息", weight: "权重" } }, commands: { poke: { description: "戳一戳" } } };
|
|
3855
|
+
|
|
3856
|
+
// src/fun/poke/index.ts
|
|
3857
|
+
var name7 = "Noah-Poke";
|
|
3858
|
+
function apply7(ctx, config) {
|
|
3859
|
+
;
|
|
3860
|
+
[
|
|
3861
|
+
["en-US", en_US_default3],
|
|
3862
|
+
["zh-CN", zh_CN_default3]
|
|
3863
|
+
].forEach(([lang, file]) => ctx.i18n.define(lang, file));
|
|
3864
|
+
const cache = /* @__PURE__ */ new Map();
|
|
3865
|
+
const pokeConfig2 = config.poke;
|
|
3866
|
+
const IMAGE_EXTENSIONS = [".png", ".jpg", ".jpeg", ".gif", ".webp"];
|
|
3867
|
+
function isImageFile(filename) {
|
|
3868
|
+
const ext = path2.extname(filename).toLowerCase();
|
|
3869
|
+
return IMAGE_EXTENSIONS.includes(ext);
|
|
3870
|
+
}
|
|
3871
|
+
__name(isImageFile, "isImageFile");
|
|
3872
|
+
function getMimeType(filename) {
|
|
3873
|
+
const ext = path2.extname(filename).toLowerCase();
|
|
3874
|
+
switch (ext) {
|
|
3875
|
+
case ".png":
|
|
3876
|
+
return "image/png";
|
|
3877
|
+
case ".jpg":
|
|
3878
|
+
case ".jpeg":
|
|
3879
|
+
return "image/jpeg";
|
|
3880
|
+
case ".gif":
|
|
3881
|
+
return "image/gif";
|
|
3882
|
+
case ".webp":
|
|
3883
|
+
return "image/webp";
|
|
3884
|
+
default:
|
|
3885
|
+
return "image/png";
|
|
3886
|
+
}
|
|
3887
|
+
}
|
|
3888
|
+
__name(getMimeType, "getMimeType");
|
|
3889
|
+
function findMatchingAudio(imagePath) {
|
|
3890
|
+
try {
|
|
3891
|
+
const dir = path2.dirname(imagePath);
|
|
3892
|
+
const filename = path2.basename(imagePath);
|
|
3893
|
+
const match = filename.match(/_(\d+)\.(png|jpg|jpeg|gif|webp)$/i);
|
|
3894
|
+
if (!match) {
|
|
3895
|
+
return null;
|
|
3896
|
+
}
|
|
3897
|
+
const imageNumber = match[1];
|
|
3898
|
+
const audioNumber = parseInt(imageNumber, 10).toString();
|
|
3899
|
+
const files = fs3.readdirSync(dir);
|
|
3900
|
+
const audioFile = files.find((file) => {
|
|
3901
|
+
return file.endsWith(`-${audioNumber}.mp3`);
|
|
3902
|
+
});
|
|
3903
|
+
return audioFile ? path2.join(dir, audioFile) : null;
|
|
3904
|
+
} catch {
|
|
3905
|
+
return null;
|
|
3906
|
+
}
|
|
3907
|
+
}
|
|
3908
|
+
__name(findMatchingAudio, "findMatchingAudio");
|
|
3909
|
+
async function sendRandomNoahStamp(ctx2, session, voiceOnly = false) {
|
|
3910
|
+
try {
|
|
3911
|
+
const stampsPath = getAssetPath(ctx2, "stamps/noah_stamp");
|
|
3912
|
+
const stampDirs = fs3.readdirSync(stampsPath).filter((dir) => dir.startsWith("stamp_"));
|
|
3913
|
+
if (stampDirs.length === 0) {
|
|
3914
|
+
await session.sendQueued("No stamps found!");
|
|
3915
|
+
return;
|
|
3916
|
+
}
|
|
3917
|
+
const allStamps = [];
|
|
3918
|
+
for (const dir of stampDirs) {
|
|
3919
|
+
const stampDirPath = path2.join(stampsPath, dir);
|
|
3920
|
+
const stampFiles = fs3.readdirSync(stampDirPath).filter((file) => file.startsWith(dir) && isImageFile(file));
|
|
3921
|
+
stampFiles.forEach((file) => {
|
|
3922
|
+
allStamps.push({
|
|
3923
|
+
path: path2.join(stampDirPath, file),
|
|
3924
|
+
dirName: dir
|
|
3925
|
+
});
|
|
3926
|
+
});
|
|
3927
|
+
}
|
|
3928
|
+
if (allStamps.length === 0) {
|
|
3929
|
+
await session.sendQueued("No stamps found in any directory!");
|
|
3930
|
+
return;
|
|
3931
|
+
}
|
|
3932
|
+
let availableStamps = allStamps;
|
|
3933
|
+
if (voiceOnly) {
|
|
3934
|
+
availableStamps = allStamps.filter((stamp) => {
|
|
3935
|
+
const audioPath2 = findMatchingAudio(stamp.path);
|
|
3936
|
+
return audioPath2 && fs3.existsSync(audioPath2);
|
|
3937
|
+
});
|
|
3938
|
+
if (availableStamps.length === 0) {
|
|
3939
|
+
await session.sendQueued("No stamps with voice found!");
|
|
3940
|
+
return;
|
|
3941
|
+
}
|
|
3942
|
+
}
|
|
3943
|
+
const randomStamp = availableStamps[Math.floor(Math.random() * availableStamps.length)];
|
|
3944
|
+
ctx2.logger("Noah-Poke").debug(`Selected stamp from ${randomStamp.dirName}`);
|
|
3945
|
+
if (!fs3.existsSync(randomStamp.path)) {
|
|
3946
|
+
await session.sendQueued("Selected stamp not found!");
|
|
3947
|
+
return;
|
|
3948
|
+
}
|
|
3949
|
+
const imageBuffer = fs3.readFileSync(randomStamp.path);
|
|
3950
|
+
const audioPath = findMatchingAudio(randomStamp.path);
|
|
3951
|
+
await session.sendQueued(import_koishi8.h.image(imageBuffer, getMimeType(randomStamp.path)));
|
|
3952
|
+
if (audioPath && fs3.existsSync(audioPath)) {
|
|
3953
|
+
ctx2.logger("Noah-Poke").debug(`Found matching audio: ${path2.basename(audioPath)}`);
|
|
3954
|
+
const audioBuffer = fs3.readFileSync(audioPath);
|
|
3955
|
+
await session.sendQueued(import_koishi8.h.audio(audioBuffer, "audio/mpeg"));
|
|
3956
|
+
}
|
|
3957
|
+
} catch (error) {
|
|
3958
|
+
ctx2.logger("Noah-Poke").error(`Error sending noah stamp: ${error.message}`);
|
|
3959
|
+
await session.sendQueued("Failed to send noah stamp.");
|
|
3960
|
+
}
|
|
3961
|
+
}
|
|
3962
|
+
__name(sendRandomNoahStamp, "sendRandomNoahStamp");
|
|
3963
|
+
async function sendRandomChatStamp(ctx2) {
|
|
3964
|
+
try {
|
|
3965
|
+
const stampsPath = getAssetPath(ctx2, "stamps/chat_stamp");
|
|
3966
|
+
const stampFiles = fs3.readdirSync(stampsPath).filter((file) => isImageFile(file));
|
|
3967
|
+
if (stampFiles.length === 0) {
|
|
3968
|
+
return "No chat stamps found!";
|
|
3969
|
+
}
|
|
3970
|
+
const randomStamp = stampFiles[Math.floor(Math.random() * stampFiles.length)];
|
|
3971
|
+
const stampPath = path2.join(stampsPath, randomStamp);
|
|
3972
|
+
if (!fs3.existsSync(stampPath)) {
|
|
3973
|
+
return "Selected stamp not found!";
|
|
3974
|
+
}
|
|
3975
|
+
const imageBuffer = fs3.readFileSync(stampPath);
|
|
3976
|
+
return import_koishi8.h.image(imageBuffer, getMimeType(stampPath));
|
|
3977
|
+
} catch (error) {
|
|
3978
|
+
ctx2.logger("Noah-Poke").error(`Error sending chat stamp: ${error.message}`);
|
|
3979
|
+
return "Failed to send chat stamp.";
|
|
3980
|
+
}
|
|
3981
|
+
}
|
|
3982
|
+
__name(sendRandomChatStamp, "sendRandomChatStamp");
|
|
3983
|
+
ctx.command("stamp").option("type", "-t [type]").option("voice", "-v", { fallback: false }).action(async ({ session, options }) => {
|
|
3984
|
+
if (options.type == "noah") {
|
|
3985
|
+
await sendRandomNoahStamp(ctx, session, options.voice);
|
|
3986
|
+
} else if (options.type == "chat") {
|
|
3987
|
+
return sendRandomChatStamp(ctx);
|
|
3988
|
+
} else {
|
|
3989
|
+
return sendRandomChatStamp(ctx);
|
|
3990
|
+
}
|
|
3991
|
+
});
|
|
4297
3992
|
ctx.platform("onebot").command("poke [target:user]").action(async ({ session }, target) => {
|
|
4298
3993
|
if (!session.onebot) {
|
|
4299
3994
|
return;
|
|
@@ -4301,7 +3996,7 @@ function registerPokeCommand(ctx) {
|
|
|
4301
3996
|
const params = { user_id: session.userId };
|
|
4302
3997
|
if (target) {
|
|
4303
3998
|
const [platform, id] = parsePlatform(target);
|
|
4304
|
-
if (platform
|
|
3999
|
+
if (platform != "onebot") {
|
|
4305
4000
|
return;
|
|
4306
4001
|
}
|
|
4307
4002
|
params.user_id = id;
|
|
@@ -4309,292 +4004,66 @@ function registerPokeCommand(ctx) {
|
|
|
4309
4004
|
if (session.isDirect) {
|
|
4310
4005
|
await session.onebot._request("friend_poke", params);
|
|
4311
4006
|
} else {
|
|
4312
|
-
params
|
|
4007
|
+
params["group_id"] = session.guildId;
|
|
4313
4008
|
await session.onebot._request("group_poke", params);
|
|
4314
4009
|
}
|
|
4315
4010
|
});
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
// src/fun/poke/utils/stamp.ts
|
|
4320
|
-
var fs4 = __toESM(require("fs"), 1);
|
|
4321
|
-
var path3 = __toESM(require("path"), 1);
|
|
4322
|
-
var import_koishi8 = require("koishi");
|
|
4323
|
-
|
|
4324
|
-
// src/fun/poke/utils/file.ts
|
|
4325
|
-
var fs3 = __toESM(require("fs"), 1);
|
|
4326
|
-
var path2 = __toESM(require("path"), 1);
|
|
4327
|
-
|
|
4328
|
-
// src/fun/poke/constants.ts
|
|
4329
|
-
var IMAGE_EXTENSIONS = [".png", ".jpg", ".jpeg", ".gif", ".webp"];
|
|
4330
|
-
var MIME_MAP = {
|
|
4331
|
-
".png": "image/png",
|
|
4332
|
-
".jpg": "image/jpeg",
|
|
4333
|
-
".jpeg": "image/jpeg",
|
|
4334
|
-
".gif": "image/gif",
|
|
4335
|
-
".webp": "image/webp"
|
|
4336
|
-
};
|
|
4337
|
-
var DEFAULT_MIME = "image/png";
|
|
4338
|
-
var DEFAULT_LOCALE = "zh-CN";
|
|
4339
|
-
var TIP_POOL = {
|
|
4340
|
-
"zh-CN": [
|
|
4341
|
-
"你知道吗: 《FIN4LE ~終止線の彼方へ~》在发布 337 天后才出现首个 PUC。",
|
|
4342
|
-
"你知道吗: Near 是双子中的姐姐哟~",
|
|
4343
|
-
"你知道吗: Noah 是双子中的妹妹哟~",
|
|
4344
|
-
"你知道吗: 可以看刘海方向来区分 Near 和 Noah。",
|
|
4345
|
-
"你知道吗: Near 和 Noah 就读于ボルテ学園初等部。",
|
|
4346
|
-
"你知道吗: 元气满满的是姐姐 Near,文静的是妹妹 Noah。",
|
|
4347
|
-
"你知道吗: Near 和 Noah 的兔子鞋是烈风刀送给她们的。",
|
|
4348
|
-
"你知道吗: Near 和 Noah 都会飞哟~",
|
|
4349
|
-
"你知道吗: Near 和 Noah 初登场于 BOOTH 代歌曲《freaky freak》。",
|
|
4350
|
-
"你知道吗: Near 和 Noah 的 CV 为 日高里菜。",
|
|
4351
|
-
"你知道吗: Near 和 Noah 的身高是 140 cm。",
|
|
4352
|
-
"你知道吗: Near 和 Noah 的生日是 6 月 10 日。"
|
|
4353
|
-
],
|
|
4354
|
-
"en-US": [
|
|
4355
|
-
"Do you know: FIN4LE ~終止線の彼方へ~ took 337 days to get its first PUC.",
|
|
4356
|
-
"Do you know: Near is the older sister of the twin.",
|
|
4357
|
-
"Do you know: Noah is the younger sister of the twin.",
|
|
4358
|
-
"Do you know: You can tell Near and Noah apart by their hair direction.",
|
|
4359
|
-
"Do you know: Near and Noah attend ボルテ学園初等部.",
|
|
4360
|
-
"Do you know: The energetic Near is the older sister, while the quiet Noah is the younger sister.",
|
|
4361
|
-
"Do you know: Near and Noah received their rabbit shoes from 烈风刀.",
|
|
4362
|
-
"Do you know: Near and Noah can fly.",
|
|
4363
|
-
'Do you know: Near and Noah made their debut in the BOOTH song "freaky freak".',
|
|
4364
|
-
"Do you know: Near and Noah's CV is 日高里菜.",
|
|
4365
|
-
"Do you know: Near and Noah's height is 140 cm.",
|
|
4366
|
-
"Do you know: Near and Noah's birthday is June 10th."
|
|
4367
|
-
]
|
|
4368
|
-
};
|
|
4369
|
-
|
|
4370
|
-
// src/fun/poke/utils/file.ts
|
|
4371
|
-
function isImageFile(filename) {
|
|
4372
|
-
const ext = path2.extname(filename).toLowerCase();
|
|
4373
|
-
return IMAGE_EXTENSIONS.includes(ext);
|
|
4374
|
-
}
|
|
4375
|
-
__name(isImageFile, "isImageFile");
|
|
4376
|
-
function getMimeType(filename) {
|
|
4377
|
-
const ext = path2.extname(filename).toLowerCase();
|
|
4378
|
-
return MIME_MAP[ext] ?? DEFAULT_MIME;
|
|
4379
|
-
}
|
|
4380
|
-
__name(getMimeType, "getMimeType");
|
|
4381
|
-
function findMatchingAudio(imagePath) {
|
|
4382
|
-
try {
|
|
4383
|
-
const dir = path2.dirname(imagePath);
|
|
4384
|
-
const filename = path2.basename(imagePath);
|
|
4385
|
-
const match = filename.match(/_(\d+)\.(png|jpg|jpeg|gif|webp)$/i);
|
|
4386
|
-
if (!match) {
|
|
4387
|
-
return null;
|
|
4388
|
-
}
|
|
4389
|
-
const audioNumber = parseInt(match[1], 10).toString();
|
|
4390
|
-
const files = fs3.readdirSync(dir);
|
|
4391
|
-
const audioFile = files.find((file) => file.endsWith(`-${audioNumber}.mp3`));
|
|
4392
|
-
return audioFile ? path2.join(dir, audioFile) : null;
|
|
4393
|
-
} catch {
|
|
4394
|
-
return null;
|
|
4395
|
-
}
|
|
4396
|
-
}
|
|
4397
|
-
__name(findMatchingAudio, "findMatchingAudio");
|
|
4398
|
-
|
|
4399
|
-
// src/fun/poke/utils/random.ts
|
|
4400
|
-
function randomMessage(items) {
|
|
4401
|
-
if (items.length === 0) {
|
|
4402
|
-
return void 0;
|
|
4403
|
-
}
|
|
4404
|
-
const totalWeight = items.reduce((sum2, cur) => sum2 + cur.weight, 0);
|
|
4405
|
-
const random = Math.random() * totalWeight;
|
|
4406
|
-
let sum = 0;
|
|
4407
|
-
for (const item of items) {
|
|
4408
|
-
sum += item.weight;
|
|
4409
|
-
if (random < sum) return item;
|
|
4410
|
-
}
|
|
4411
|
-
return items[items.length - 1];
|
|
4412
|
-
}
|
|
4413
|
-
__name(randomMessage, "randomMessage");
|
|
4414
|
-
function pickRandom(items) {
|
|
4415
|
-
if (items.length === 0) {
|
|
4416
|
-
return void 0;
|
|
4417
|
-
}
|
|
4418
|
-
return items[Math.floor(Math.random() * items.length)];
|
|
4419
|
-
}
|
|
4420
|
-
__name(pickRandom, "pickRandom");
|
|
4421
|
-
|
|
4422
|
-
// src/fun/poke/utils/stamp.ts
|
|
4423
|
-
var LOGGER_NAME = "Noah-Poke";
|
|
4424
|
-
function collectNoahStamps(stampsPath) {
|
|
4425
|
-
const stampDirs = fs4.readdirSync(stampsPath).filter((dir) => dir.startsWith("stamp_"));
|
|
4426
|
-
const allStamps = [];
|
|
4427
|
-
for (const dir of stampDirs) {
|
|
4428
|
-
const stampDirPath = path3.join(stampsPath, dir);
|
|
4429
|
-
const stampFiles = fs4.readdirSync(stampDirPath).filter((file) => file.startsWith(dir) && isImageFile(file));
|
|
4430
|
-
stampFiles.forEach((file) => {
|
|
4431
|
-
allStamps.push({ path: path3.join(stampDirPath, file), dirName: dir });
|
|
4432
|
-
});
|
|
4433
|
-
}
|
|
4434
|
-
return allStamps;
|
|
4435
|
-
}
|
|
4436
|
-
__name(collectNoahStamps, "collectNoahStamps");
|
|
4437
|
-
async function sendRandomNoahStamp(ctx, session, voiceOnly = false) {
|
|
4438
|
-
const logger6 = ctx.logger(LOGGER_NAME);
|
|
4439
|
-
try {
|
|
4440
|
-
const stampsPath = getAssetPath(ctx, "stamps/noah_stamp");
|
|
4441
|
-
const allStamps = collectNoahStamps(stampsPath);
|
|
4442
|
-
if (allStamps.length === 0) {
|
|
4443
|
-
await session.sendQueued("No stamps found!");
|
|
4444
|
-
return;
|
|
4445
|
-
}
|
|
4446
|
-
const availableStamps = voiceOnly ? allStamps.filter((stamp) => {
|
|
4447
|
-
const audioPath2 = findMatchingAudio(stamp.path);
|
|
4448
|
-
return audioPath2 && fs4.existsSync(audioPath2);
|
|
4449
|
-
}) : allStamps;
|
|
4450
|
-
if (availableStamps.length === 0) {
|
|
4451
|
-
await session.sendQueued("No stamps with voice found!");
|
|
4452
|
-
return;
|
|
4453
|
-
}
|
|
4454
|
-
const randomStamp = pickRandom(availableStamps);
|
|
4455
|
-
logger6.debug(`Selected stamp from ${randomStamp.dirName}`);
|
|
4456
|
-
if (!fs4.existsSync(randomStamp.path)) {
|
|
4457
|
-
await session.sendQueued("Selected stamp not found!");
|
|
4458
|
-
return;
|
|
4459
|
-
}
|
|
4460
|
-
const imageBuffer = fs4.readFileSync(randomStamp.path);
|
|
4461
|
-
await session.sendQueued(import_koishi8.h.image(imageBuffer, getMimeType(randomStamp.path)));
|
|
4462
|
-
const audioPath = findMatchingAudio(randomStamp.path);
|
|
4463
|
-
if (audioPath && fs4.existsSync(audioPath)) {
|
|
4464
|
-
logger6.debug(`Found matching audio: ${path3.basename(audioPath)}`);
|
|
4465
|
-
const audioBuffer = fs4.readFileSync(audioPath);
|
|
4466
|
-
await session.sendQueued(import_koishi8.h.audio(audioBuffer, "audio/mpeg"));
|
|
4467
|
-
}
|
|
4468
|
-
} catch (error) {
|
|
4469
|
-
logger6.error(`Error sending noah stamp: ${error.message}`);
|
|
4470
|
-
await session.sendQueued("Failed to send noah stamp.");
|
|
4471
|
-
}
|
|
4472
|
-
}
|
|
4473
|
-
__name(sendRandomNoahStamp, "sendRandomNoahStamp");
|
|
4474
|
-
function getRandomChatStamp(ctx) {
|
|
4475
|
-
const logger6 = ctx.logger(LOGGER_NAME);
|
|
4476
|
-
try {
|
|
4477
|
-
const stampsPath = getAssetPath(ctx, "stamps/chat_stamp");
|
|
4478
|
-
const stampFiles = fs4.readdirSync(stampsPath).filter((file) => isImageFile(file));
|
|
4479
|
-
if (stampFiles.length === 0) {
|
|
4480
|
-
return "No chat stamps found!";
|
|
4481
|
-
}
|
|
4482
|
-
const randomStamp = pickRandom(stampFiles);
|
|
4483
|
-
const stampPath = path3.join(stampsPath, randomStamp);
|
|
4484
|
-
if (!fs4.existsSync(stampPath)) {
|
|
4485
|
-
return "Selected stamp not found!";
|
|
4486
|
-
}
|
|
4487
|
-
const imageBuffer = fs4.readFileSync(stampPath);
|
|
4488
|
-
return import_koishi8.h.image(imageBuffer, getMimeType(stampPath));
|
|
4489
|
-
} catch (error) {
|
|
4490
|
-
logger6.error(`Error sending chat stamp: ${error.message}`);
|
|
4491
|
-
return "Failed to send chat stamp.";
|
|
4492
|
-
}
|
|
4493
|
-
}
|
|
4494
|
-
__name(getRandomChatStamp, "getRandomChatStamp");
|
|
4495
|
-
|
|
4496
|
-
// src/fun/poke/commands/stamp.ts
|
|
4497
|
-
function registerStampCommand(ctx) {
|
|
4498
|
-
ctx.command("stamp").option("type", "-t [type]").option("voice", "-v", { fallback: false }).action(async ({ session, options }) => {
|
|
4499
|
-
if (options.type === "noah") {
|
|
4500
|
-
await sendRandomNoahStamp(ctx, session, options.voice);
|
|
4011
|
+
ctx.platform("onebot").on("notice", async (session) => {
|
|
4012
|
+
if (session.subtype != "poke") {
|
|
4501
4013
|
return;
|
|
4502
4014
|
}
|
|
4503
|
-
|
|
4504
|
-
});
|
|
4505
|
-
}
|
|
4506
|
-
__name(registerStampCommand, "registerStampCommand");
|
|
4507
|
-
|
|
4508
|
-
// src/fun/poke/events/notice.ts
|
|
4509
|
-
var import_koishi9 = require("koishi");
|
|
4510
|
-
|
|
4511
|
-
// src/fun/poke/utils/tip.ts
|
|
4512
|
-
async function pickTip(session) {
|
|
4513
|
-
const user = await session.observeUser(["locales"]);
|
|
4514
|
-
const locales = user.locales ?? [];
|
|
4515
|
-
for (const locale2 of locales) {
|
|
4516
|
-
const tips = TIP_POOL[locale2];
|
|
4517
|
-
if (tips && tips.length > 0) {
|
|
4518
|
-
return pickRandom(tips);
|
|
4519
|
-
}
|
|
4520
|
-
}
|
|
4521
|
-
return pickRandom(TIP_POOL[DEFAULT_LOCALE] ?? []);
|
|
4522
|
-
}
|
|
4523
|
-
__name(pickTip, "pickTip");
|
|
4524
|
-
|
|
4525
|
-
// src/fun/poke/events/notice.ts
|
|
4526
|
-
function registerPokeNotice(ctx, config, cache) {
|
|
4527
|
-
ctx.platform("onebot").on("notice", async (session) => {
|
|
4528
|
-
if (session.subtype !== "poke" || session.targetId !== session.selfId) {
|
|
4015
|
+
if (session.targetId != session.selfId) {
|
|
4529
4016
|
return;
|
|
4530
4017
|
}
|
|
4531
|
-
if (
|
|
4018
|
+
if (pokeConfig2.interval > 0 && cache.has(session.userId)) {
|
|
4532
4019
|
const ts = cache.get(session.userId);
|
|
4533
|
-
if (session.timestamp - ts <
|
|
4534
|
-
if (
|
|
4535
|
-
const
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
}
|
|
4020
|
+
if (session.timestamp - ts < pokeConfig2.interval) {
|
|
4021
|
+
if (pokeConfig2.warning) {
|
|
4022
|
+
const msg = randomMessage(pokeConfig2.prompt);
|
|
4023
|
+
const content = import_koishi8.h.parse(msg, session);
|
|
4024
|
+
session.sendQueued(content);
|
|
4539
4025
|
}
|
|
4540
4026
|
return;
|
|
4541
4027
|
}
|
|
4542
4028
|
}
|
|
4543
4029
|
cache.set(session.userId, session.timestamp);
|
|
4544
|
-
if (
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
if (!msg) {
|
|
4549
|
-
return;
|
|
4550
|
-
}
|
|
4551
|
-
if (msg.type === "noah") {
|
|
4552
|
-
await sendRandomNoahStamp(ctx, session);
|
|
4553
|
-
} else if (msg.type === "chat") {
|
|
4554
|
-
await session.sendQueued(getRandomChatStamp(ctx));
|
|
4555
|
-
} else {
|
|
4556
|
-
const tip = await pickTip(session);
|
|
4557
|
-
if (tip) {
|
|
4558
|
-
await session.sendQueued(import_koishi9.h.parse(tip, session));
|
|
4559
|
-
}
|
|
4030
|
+
if (pokeConfig2.messages.length > 0) {
|
|
4031
|
+
const msg = randomMessage(pokeConfig2.messages);
|
|
4032
|
+
const content = import_koishi8.h.parse(msg, session);
|
|
4033
|
+
await session.sendQueued(content);
|
|
4560
4034
|
}
|
|
4561
4035
|
});
|
|
4562
4036
|
}
|
|
4563
|
-
__name(registerPokeNotice, "registerPokeNotice");
|
|
4564
|
-
|
|
4565
|
-
// src/fun/poke/locales/en-US.yml
|
|
4566
|
-
var en_US_default3 = { _config: { $desc: "Poke Module Settings", interval: "最小触发间隔(毫秒)", warning: "频繁触发是否发送警告", prompt: "警告内容", messages: { $desc: "消息内容", type: "Type (text=random tip / noah=voice stamp / chat=chat stamp)", weight: "权重" } }, commands: { poke: { description: "poke" } } };
|
|
4567
|
-
|
|
4568
|
-
// src/fun/poke/locales/zh-CN.yml
|
|
4569
|
-
var zh_CN_default3 = { _config: { $desc: "Poke 模块设置", interval: "最小触发间隔(毫秒)", warning: "频繁触发是否发送警告", prompt: { $desc: "警告内容", content: "消息", weight: "权重" }, messages: { $desc: "消息内容", type: "类型(text=随机提示 / noah=语音表情 / chat=聊天表情)", weight: "权重" } }, commands: { poke: { description: "戳一戳" } } };
|
|
4570
|
-
|
|
4571
|
-
// src/fun/poke/index.ts
|
|
4572
|
-
var name7 = "Noah-Poke";
|
|
4573
|
-
var logger3 = new import_koishi10.Logger("Noah-Poke");
|
|
4574
|
-
function apply7(ctx, config) {
|
|
4575
|
-
;
|
|
4576
|
-
[
|
|
4577
|
-
["en-US", en_US_default3],
|
|
4578
|
-
["zh-CN", zh_CN_default3]
|
|
4579
|
-
].forEach(([lang, file]) => ctx.i18n.define(lang, file));
|
|
4580
|
-
const cache = /* @__PURE__ */ new Map();
|
|
4581
|
-
registerStampCommand(ctx);
|
|
4582
|
-
registerPokeCommand(ctx);
|
|
4583
|
-
registerPokeNotice(ctx, config.poke, cache);
|
|
4584
|
-
}
|
|
4585
4037
|
__name(apply7, "apply");
|
|
4038
|
+
function randomMessage(messages) {
|
|
4039
|
+
const totalWeight = messages.reduce((sum2, cur) => sum2 + cur.weight, 0);
|
|
4040
|
+
const random = Math.random() * totalWeight;
|
|
4041
|
+
let sum = 0;
|
|
4042
|
+
for (const message of messages) {
|
|
4043
|
+
sum += message.weight;
|
|
4044
|
+
if (random < sum) return message.content;
|
|
4045
|
+
}
|
|
4046
|
+
}
|
|
4047
|
+
__name(randomMessage, "randomMessage");
|
|
4048
|
+
function parsePlatform(target) {
|
|
4049
|
+
const index = target.indexOf(":");
|
|
4050
|
+
const platform = target.slice(0, index);
|
|
4051
|
+
const id = target.slice(index + 1);
|
|
4052
|
+
return [platform, id];
|
|
4053
|
+
}
|
|
4054
|
+
__name(parsePlatform, "parsePlatform");
|
|
4586
4055
|
|
|
4587
4056
|
// src/games/general/index.ts
|
|
4588
4057
|
var general_exports = {};
|
|
4589
4058
|
__export(general_exports, {
|
|
4590
4059
|
apply: () => apply8,
|
|
4591
|
-
logger: () =>
|
|
4060
|
+
logger: () => logger3,
|
|
4592
4061
|
name: () => name8
|
|
4593
4062
|
});
|
|
4594
|
-
var
|
|
4063
|
+
var import_koishi10 = require("koishi");
|
|
4595
4064
|
|
|
4596
4065
|
// src/games/general/events/quote.ts
|
|
4597
|
-
var
|
|
4066
|
+
var import_koishi9 = require("koishi");
|
|
4598
4067
|
|
|
4599
4068
|
// src/games/general/utils/codeReader.ts
|
|
4600
4069
|
async function readCode128(ctx, barcodeApiUrl, imageUrl) {
|
|
@@ -4620,8 +4089,8 @@ __name(readCode128, "readCode128");
|
|
|
4620
4089
|
function quote(ctx, config) {
|
|
4621
4090
|
ctx.on("message", async (session) => {
|
|
4622
4091
|
if (session.quote && session.quote.user.id === session.selfId) {
|
|
4623
|
-
const images = await
|
|
4624
|
-
const textElements = await
|
|
4092
|
+
const images = await import_koishi9.h.select(session.quote.elements, "img");
|
|
4093
|
+
const textElements = await import_koishi9.h.select(session.elements, "text");
|
|
4625
4094
|
const allText = textElements.map((el) => el.attrs?.content || "").join(" ");
|
|
4626
4095
|
if (images.length === 1) {
|
|
4627
4096
|
const imageUrl = images[0].attrs.src;
|
|
@@ -4647,7 +4116,7 @@ __name(quote, "quote");
|
|
|
4647
4116
|
|
|
4648
4117
|
// src/games/general/index.ts
|
|
4649
4118
|
var name8 = "Noah-General";
|
|
4650
|
-
var
|
|
4119
|
+
var logger3 = new import_koishi10.Logger("Noah-General");
|
|
4651
4120
|
async function apply8(ctx, config) {
|
|
4652
4121
|
quote(ctx, config.general);
|
|
4653
4122
|
}
|
|
@@ -4658,10 +4127,10 @@ var sdvx_exports = {};
|
|
|
4658
4127
|
__export(sdvx_exports, {
|
|
4659
4128
|
apply: () => apply13,
|
|
4660
4129
|
inject: () => inject3,
|
|
4661
|
-
logger: () =>
|
|
4130
|
+
logger: () => logger4,
|
|
4662
4131
|
name: () => name13
|
|
4663
4132
|
});
|
|
4664
|
-
var
|
|
4133
|
+
var import_koishi18 = require("koishi");
|
|
4665
4134
|
|
|
4666
4135
|
// src/servers/index.ts
|
|
4667
4136
|
var servers_exports = {};
|
|
@@ -4673,7 +4142,7 @@ __export(servers_exports, {
|
|
|
4673
4142
|
});
|
|
4674
4143
|
|
|
4675
4144
|
// src/servers/Asphyxia/index.ts
|
|
4676
|
-
var
|
|
4145
|
+
var import_koishi11 = require("koishi");
|
|
4677
4146
|
var Asphyxia = class {
|
|
4678
4147
|
static {
|
|
4679
4148
|
__name(this, "Asphyxia");
|
|
@@ -4681,11 +4150,11 @@ var Asphyxia = class {
|
|
|
4681
4150
|
name = "asphyxia";
|
|
4682
4151
|
supportedGames = ["sdvx", "iidx"];
|
|
4683
4152
|
gameServices = {};
|
|
4684
|
-
logger = new
|
|
4153
|
+
logger = new import_koishi11.Logger("Noah-Asphyxia");
|
|
4685
4154
|
};
|
|
4686
4155
|
|
|
4687
4156
|
// src/servers/Mao/index.ts
|
|
4688
|
-
var
|
|
4157
|
+
var import_koishi12 = require("koishi");
|
|
4689
4158
|
var Mao = class {
|
|
4690
4159
|
static {
|
|
4691
4160
|
__name(this, "Mao");
|
|
@@ -4693,11 +4162,11 @@ var Mao = class {
|
|
|
4693
4162
|
name = "mao";
|
|
4694
4163
|
supportedGames = ["sdvx"];
|
|
4695
4164
|
gameServices = {};
|
|
4696
|
-
logger = new
|
|
4165
|
+
logger = new import_koishi12.Logger("Noah-Mao");
|
|
4697
4166
|
};
|
|
4698
4167
|
|
|
4699
4168
|
// src/servers/Official/index.ts
|
|
4700
|
-
var
|
|
4169
|
+
var import_koishi13 = require("koishi");
|
|
4701
4170
|
var Official = class {
|
|
4702
4171
|
static {
|
|
4703
4172
|
__name(this, "Official");
|
|
@@ -4705,7 +4174,7 @@ var Official = class {
|
|
|
4705
4174
|
name = "official";
|
|
4706
4175
|
supportedGames = ["sdvx"];
|
|
4707
4176
|
gameServices = {};
|
|
4708
|
-
logger = new
|
|
4177
|
+
logger = new import_koishi13.Logger("Noah-Official");
|
|
4709
4178
|
};
|
|
4710
4179
|
|
|
4711
4180
|
// src/servers/ServerFactory.ts
|
|
@@ -5073,13 +4542,13 @@ var AsphyxiaSDVXService = class _AsphyxiaSDVXService {
|
|
|
5073
4542
|
logger;
|
|
5074
4543
|
config;
|
|
5075
4544
|
cachedModel = null;
|
|
5076
|
-
constructor(
|
|
5077
|
-
this.logger =
|
|
4545
|
+
constructor(logger5, config) {
|
|
4546
|
+
this.logger = logger5;
|
|
5078
4547
|
this.config = config;
|
|
5079
4548
|
}
|
|
5080
|
-
static getInstance(
|
|
4549
|
+
static getInstance(logger5, config) {
|
|
5081
4550
|
if (!_AsphyxiaSDVXService.instance) {
|
|
5082
|
-
_AsphyxiaSDVXService.instance = new _AsphyxiaSDVXService(
|
|
4551
|
+
_AsphyxiaSDVXService.instance = new _AsphyxiaSDVXService(logger5, config);
|
|
5083
4552
|
}
|
|
5084
4553
|
return _AsphyxiaSDVXService.instance;
|
|
5085
4554
|
}
|
|
@@ -5226,12 +4695,12 @@ var MaoSDVXService = class _MaoSDVXService {
|
|
|
5226
4695
|
}
|
|
5227
4696
|
static instance;
|
|
5228
4697
|
logger;
|
|
5229
|
-
constructor(
|
|
5230
|
-
this.logger =
|
|
4698
|
+
constructor(logger5) {
|
|
4699
|
+
this.logger = logger5;
|
|
5231
4700
|
}
|
|
5232
|
-
static getInstance(
|
|
4701
|
+
static getInstance(logger5) {
|
|
5233
4702
|
if (!_MaoSDVXService.instance) {
|
|
5234
|
-
_MaoSDVXService.instance = new _MaoSDVXService(
|
|
4703
|
+
_MaoSDVXService.instance = new _MaoSDVXService(logger5);
|
|
5235
4704
|
}
|
|
5236
4705
|
return _MaoSDVXService.instance;
|
|
5237
4706
|
}
|
|
@@ -5576,12 +5045,12 @@ var OfficialSDVXService = class _OfficialSDVXService {
|
|
|
5576
5045
|
}
|
|
5577
5046
|
static instance;
|
|
5578
5047
|
logger;
|
|
5579
|
-
constructor(
|
|
5580
|
-
this.logger =
|
|
5048
|
+
constructor(logger5) {
|
|
5049
|
+
this.logger = logger5;
|
|
5581
5050
|
}
|
|
5582
|
-
static getInstance(
|
|
5051
|
+
static getInstance(logger5) {
|
|
5583
5052
|
if (!_OfficialSDVXService.instance) {
|
|
5584
|
-
_OfficialSDVXService.instance = new _OfficialSDVXService(
|
|
5053
|
+
_OfficialSDVXService.instance = new _OfficialSDVXService(logger5);
|
|
5585
5054
|
}
|
|
5586
5055
|
return _OfficialSDVXService.instance;
|
|
5587
5056
|
}
|
|
@@ -5686,15 +5155,15 @@ var OfficialSDVXService = class _OfficialSDVXService {
|
|
|
5686
5155
|
};
|
|
5687
5156
|
|
|
5688
5157
|
// src/games/sdvx/adapters/index.ts
|
|
5689
|
-
function registerSDVXAdapters(
|
|
5158
|
+
function registerSDVXAdapters(logger5, config) {
|
|
5690
5159
|
const serverManager = ServerManager.getInstance();
|
|
5691
5160
|
serverManager.registerGameService(
|
|
5692
5161
|
"asphyxia",
|
|
5693
5162
|
"sdvx",
|
|
5694
|
-
AsphyxiaSDVXService.getInstance(
|
|
5163
|
+
AsphyxiaSDVXService.getInstance(logger5, config)
|
|
5695
5164
|
);
|
|
5696
|
-
serverManager.registerGameService("mao", "sdvx", MaoSDVXService.getInstance(
|
|
5697
|
-
serverManager.registerGameService("official", "sdvx", OfficialSDVXService.getInstance(
|
|
5165
|
+
serverManager.registerGameService("mao", "sdvx", MaoSDVXService.getInstance(logger5));
|
|
5166
|
+
serverManager.registerGameService("official", "sdvx", OfficialSDVXService.getInstance(logger5));
|
|
5698
5167
|
}
|
|
5699
5168
|
__name(registerSDVXAdapters, "registerSDVXAdapters");
|
|
5700
5169
|
|
|
@@ -5706,7 +5175,7 @@ __export(command_exports2, {
|
|
|
5706
5175
|
});
|
|
5707
5176
|
|
|
5708
5177
|
// src/games/sdvx/commands/calculate.ts
|
|
5709
|
-
var
|
|
5178
|
+
var import_koishi14 = require("koishi");
|
|
5710
5179
|
|
|
5711
5180
|
// src/games/sdvx/utils/param-parser.ts
|
|
5712
5181
|
function parseNumberWithSuffix(str) {
|
|
@@ -5894,249 +5363,6 @@ function parseRadarFeature(item) {
|
|
|
5894
5363
|
return null;
|
|
5895
5364
|
}
|
|
5896
5365
|
__name(parseRadarFeature, "parseRadarFeature");
|
|
5897
|
-
function extractOperator(item) {
|
|
5898
|
-
if (item.startsWith(">=")) return { op: ">=", value: item.slice(2) };
|
|
5899
|
-
if (item.startsWith("<=")) return { op: "<=", value: item.slice(2) };
|
|
5900
|
-
if (item.startsWith("!=")) return { op: "!=", value: item.slice(2) };
|
|
5901
|
-
if (item.startsWith(">")) return { op: ">", value: item.slice(1) };
|
|
5902
|
-
if (item.startsWith("<")) return { op: "<", value: item.slice(1) };
|
|
5903
|
-
if (item.startsWith("=")) return { op: "=", value: item.slice(1) };
|
|
5904
|
-
if (item.startsWith("~")) return { op: "~", value: item.slice(1) };
|
|
5905
|
-
return { op: null, value: item };
|
|
5906
|
-
}
|
|
5907
|
-
__name(extractOperator, "extractOperator");
|
|
5908
|
-
function getAllValidLevels2() {
|
|
5909
|
-
const levels = [];
|
|
5910
|
-
for (let i = 1; i <= 16; i++) levels.push(i);
|
|
5911
|
-
levels.push(17, 17.5);
|
|
5912
|
-
for (let scaled = 180; scaled <= 209; scaled++) levels.push(scaled / 10);
|
|
5913
|
-
return levels;
|
|
5914
|
-
}
|
|
5915
|
-
__name(getAllValidLevels2, "getAllValidLevels");
|
|
5916
|
-
function applyLevelOperator(op, levels) {
|
|
5917
|
-
const allLevels = getAllValidLevels2();
|
|
5918
|
-
const value = levels[0];
|
|
5919
|
-
if (op === "=") return { include: levels, exclude: [] };
|
|
5920
|
-
if (op === "!=") return { include: [], exclude: levels };
|
|
5921
|
-
if (op === "~") {
|
|
5922
|
-
const result = /* @__PURE__ */ new Set();
|
|
5923
|
-
for (const lv of levels) {
|
|
5924
|
-
const idx2 = allLevels.indexOf(lv);
|
|
5925
|
-
if (idx2 === -1) continue;
|
|
5926
|
-
if (idx2 > 0) result.add(allLevels[idx2 - 1]);
|
|
5927
|
-
result.add(allLevels[idx2]);
|
|
5928
|
-
if (idx2 < allLevels.length - 1) result.add(allLevels[idx2 + 1]);
|
|
5929
|
-
}
|
|
5930
|
-
return { include: [...result], exclude: [] };
|
|
5931
|
-
}
|
|
5932
|
-
const idx = allLevels.indexOf(value);
|
|
5933
|
-
if (idx === -1) return { include: levels, exclude: [] };
|
|
5934
|
-
switch (op) {
|
|
5935
|
-
case ">":
|
|
5936
|
-
return { include: allLevels.slice(idx + 1), exclude: [] };
|
|
5937
|
-
case ">=":
|
|
5938
|
-
return { include: allLevels.slice(idx), exclude: [] };
|
|
5939
|
-
case "<":
|
|
5940
|
-
return { include: allLevels.slice(0, idx), exclude: [] };
|
|
5941
|
-
case "<=":
|
|
5942
|
-
return { include: allLevels.slice(0, idx + 1), exclude: [] };
|
|
5943
|
-
}
|
|
5944
|
-
}
|
|
5945
|
-
__name(applyLevelOperator, "applyLevelOperator");
|
|
5946
|
-
function applyScoreOperator(op, scores) {
|
|
5947
|
-
const value = scores[0];
|
|
5948
|
-
if (op === "=") return { include: [value], exclude: [] };
|
|
5949
|
-
if (op === "!=") return { include: [], exclude: [value] };
|
|
5950
|
-
if (op === "~") {
|
|
5951
|
-
return { include: [value - 5e4, value + 5e4], exclude: [] };
|
|
5952
|
-
}
|
|
5953
|
-
switch (op) {
|
|
5954
|
-
case ">":
|
|
5955
|
-
return { include: [value + 1, 1e7], exclude: [] };
|
|
5956
|
-
case ">=":
|
|
5957
|
-
return { include: [value, 1e7], exclude: [] };
|
|
5958
|
-
case "<":
|
|
5959
|
-
return { include: [0, value - 1], exclude: [] };
|
|
5960
|
-
case "<=":
|
|
5961
|
-
return { include: [0, value], exclude: [] };
|
|
5962
|
-
}
|
|
5963
|
-
}
|
|
5964
|
-
__name(applyScoreOperator, "applyScoreOperator");
|
|
5965
|
-
function applyVfOperator(op, vfValue) {
|
|
5966
|
-
if (op === "=") return { include: vfValue, exclude: [] };
|
|
5967
|
-
if (op === "!=") return { include: [], exclude: [vfValue] };
|
|
5968
|
-
if (op === "~") {
|
|
5969
|
-
return { include: [vfValue - 0.25, vfValue + 0.25], exclude: [] };
|
|
5970
|
-
}
|
|
5971
|
-
switch (op) {
|
|
5972
|
-
case ">":
|
|
5973
|
-
return { include: [vfValue + 0.05, 99], exclude: [] };
|
|
5974
|
-
case ">=":
|
|
5975
|
-
return { include: [vfValue, 99], exclude: [] };
|
|
5976
|
-
case "<":
|
|
5977
|
-
return { include: [0, vfValue - 0.05], exclude: [] };
|
|
5978
|
-
case "<=":
|
|
5979
|
-
return { include: [0, vfValue], exclude: [] };
|
|
5980
|
-
}
|
|
5981
|
-
}
|
|
5982
|
-
__name(applyVfOperator, "applyVfOperator");
|
|
5983
|
-
function applyGradeOperator(op, grade) {
|
|
5984
|
-
const idx = ALL_GRADES.indexOf(grade);
|
|
5985
|
-
if (idx === -1) return { include: [grade], exclude: [] };
|
|
5986
|
-
if (op === "=") return { include: [grade], exclude: [] };
|
|
5987
|
-
if (op === "!=") return { include: [], exclude: [grade] };
|
|
5988
|
-
if (op === "~") {
|
|
5989
|
-
const result = [];
|
|
5990
|
-
if (idx > 0) result.push(ALL_GRADES[idx - 1]);
|
|
5991
|
-
result.push(ALL_GRADES[idx]);
|
|
5992
|
-
if (idx < ALL_GRADES.length - 1) result.push(ALL_GRADES[idx + 1]);
|
|
5993
|
-
return { include: result, exclude: [] };
|
|
5994
|
-
}
|
|
5995
|
-
switch (op) {
|
|
5996
|
-
case ">":
|
|
5997
|
-
return { include: ALL_GRADES.slice(0, idx), exclude: [] };
|
|
5998
|
-
case ">=":
|
|
5999
|
-
return { include: ALL_GRADES.slice(0, idx + 1), exclude: [] };
|
|
6000
|
-
case "<":
|
|
6001
|
-
return { include: ALL_GRADES.slice(idx + 1), exclude: [] };
|
|
6002
|
-
case "<=":
|
|
6003
|
-
return { include: ALL_GRADES.slice(idx), exclude: [] };
|
|
6004
|
-
}
|
|
6005
|
-
}
|
|
6006
|
-
__name(applyGradeOperator, "applyGradeOperator");
|
|
6007
|
-
function applyClearTypeOperator(op, clearType) {
|
|
6008
|
-
const idx = ALL_CLEAR_TYPES.indexOf(clearType);
|
|
6009
|
-
if (idx === -1) return { include: [clearType], exclude: [] };
|
|
6010
|
-
if (op === "=") return { include: [clearType], exclude: [] };
|
|
6011
|
-
if (op === "!=") return { include: [], exclude: [clearType] };
|
|
6012
|
-
if (op === "~") {
|
|
6013
|
-
const result = [];
|
|
6014
|
-
if (idx > 0) result.push(ALL_CLEAR_TYPES[idx - 1]);
|
|
6015
|
-
result.push(ALL_CLEAR_TYPES[idx]);
|
|
6016
|
-
if (idx < ALL_CLEAR_TYPES.length - 1) result.push(ALL_CLEAR_TYPES[idx + 1]);
|
|
6017
|
-
return { include: result, exclude: [] };
|
|
6018
|
-
}
|
|
6019
|
-
switch (op) {
|
|
6020
|
-
case ">":
|
|
6021
|
-
return { include: ALL_CLEAR_TYPES.slice(0, idx), exclude: [] };
|
|
6022
|
-
case ">=":
|
|
6023
|
-
return { include: ALL_CLEAR_TYPES.slice(0, idx + 1), exclude: [] };
|
|
6024
|
-
case "<":
|
|
6025
|
-
return { include: ALL_CLEAR_TYPES.slice(idx + 1), exclude: [] };
|
|
6026
|
-
case "<=":
|
|
6027
|
-
return { include: ALL_CLEAR_TYPES.slice(idx), exclude: [] };
|
|
6028
|
-
}
|
|
6029
|
-
}
|
|
6030
|
-
__name(applyClearTypeOperator, "applyClearTypeOperator");
|
|
6031
|
-
function mergeLevels(params, levels) {
|
|
6032
|
-
if (params.level !== void 0) {
|
|
6033
|
-
const existing = Array.isArray(params.level) ? params.level : [params.level];
|
|
6034
|
-
params.level = [.../* @__PURE__ */ new Set([...existing, ...levels])];
|
|
6035
|
-
} else {
|
|
6036
|
-
params.level = levels.length === 1 ? levels[0] : levels;
|
|
6037
|
-
}
|
|
6038
|
-
}
|
|
6039
|
-
__name(mergeLevels, "mergeLevels");
|
|
6040
|
-
function mergeScores(params, scores) {
|
|
6041
|
-
if (params.score !== void 0) {
|
|
6042
|
-
const existing = Array.isArray(params.score) ? params.score : [params.score];
|
|
6043
|
-
params.score = [.../* @__PURE__ */ new Set([...existing, ...scores])];
|
|
6044
|
-
} else {
|
|
6045
|
-
params.score = scores.length === 1 ? scores[0] : scores;
|
|
6046
|
-
}
|
|
6047
|
-
}
|
|
6048
|
-
__name(mergeScores, "mergeScores");
|
|
6049
|
-
function mergeVf(params, vf2) {
|
|
6050
|
-
if (params.vf !== void 0) {
|
|
6051
|
-
const existing = Array.isArray(params.vf) ? params.vf : [params.vf];
|
|
6052
|
-
const newVf = Array.isArray(vf2) ? vf2 : [vf2];
|
|
6053
|
-
params.vf = [...existing, ...newVf];
|
|
6054
|
-
} else {
|
|
6055
|
-
params.vf = vf2;
|
|
6056
|
-
}
|
|
6057
|
-
}
|
|
6058
|
-
__name(mergeVf, "mergeVf");
|
|
6059
|
-
function mergeGrades(params, grades) {
|
|
6060
|
-
if (params.grade) {
|
|
6061
|
-
const existing = Array.isArray(params.grade) ? params.grade : [params.grade];
|
|
6062
|
-
params.grade = [.../* @__PURE__ */ new Set([...existing, ...grades])];
|
|
6063
|
-
} else {
|
|
6064
|
-
params.grade = grades.length === 1 ? grades[0] : grades;
|
|
6065
|
-
}
|
|
6066
|
-
}
|
|
6067
|
-
__name(mergeGrades, "mergeGrades");
|
|
6068
|
-
function mergeClearTypes(params, clearTypes) {
|
|
6069
|
-
if (params.clearType) {
|
|
6070
|
-
const existing = Array.isArray(params.clearType) ? params.clearType : [params.clearType];
|
|
6071
|
-
params.clearType = [.../* @__PURE__ */ new Set([...existing, ...clearTypes])];
|
|
6072
|
-
} else {
|
|
6073
|
-
params.clearType = clearTypes;
|
|
6074
|
-
}
|
|
6075
|
-
}
|
|
6076
|
-
__name(mergeClearTypes, "mergeClearTypes");
|
|
6077
|
-
function parseWithOperator(params, op, value) {
|
|
6078
|
-
const vf2 = parseVfValue(value);
|
|
6079
|
-
if (vf2 !== null) {
|
|
6080
|
-
const vfNum = Array.isArray(vf2) ? vf2[0] : vf2;
|
|
6081
|
-
const result = applyVfOperator(op, vfNum);
|
|
6082
|
-
if (result.exclude.length > 0) {
|
|
6083
|
-
params.excludeVf = [...params.excludeVf || [], ...result.exclude];
|
|
6084
|
-
}
|
|
6085
|
-
if (Array.isArray(result.include) && result.include.length > 0) {
|
|
6086
|
-
mergeVf(params, result.include);
|
|
6087
|
-
} else if (typeof result.include === "number") {
|
|
6088
|
-
mergeVf(params, result.include);
|
|
6089
|
-
}
|
|
6090
|
-
return true;
|
|
6091
|
-
}
|
|
6092
|
-
const levels = parseLevelRange(value);
|
|
6093
|
-
if (levels !== null && levels.length === 1) {
|
|
6094
|
-
const result = applyLevelOperator(op, levels);
|
|
6095
|
-
if (result.exclude.length > 0) {
|
|
6096
|
-
params.excludeLevel = [...params.excludeLevel || [], ...result.exclude];
|
|
6097
|
-
}
|
|
6098
|
-
if (result.include.length > 0) {
|
|
6099
|
-
mergeLevels(params, result.include);
|
|
6100
|
-
}
|
|
6101
|
-
return true;
|
|
6102
|
-
}
|
|
6103
|
-
const scores = parseScoreRange(value);
|
|
6104
|
-
if (scores !== null && scores.length === 1) {
|
|
6105
|
-
const result = applyScoreOperator(op, scores);
|
|
6106
|
-
if (result.exclude.length > 0) {
|
|
6107
|
-
params.excludeScore = [...params.excludeScore || [], ...result.exclude];
|
|
6108
|
-
}
|
|
6109
|
-
if (result.include.length > 0) {
|
|
6110
|
-
mergeScores(params, result.include);
|
|
6111
|
-
}
|
|
6112
|
-
return true;
|
|
6113
|
-
}
|
|
6114
|
-
const singleClearTypes = parseSingleClearType(value);
|
|
6115
|
-
if (singleClearTypes !== null) {
|
|
6116
|
-
const ct = singleClearTypes[0];
|
|
6117
|
-
const result = applyClearTypeOperator(op, ct);
|
|
6118
|
-
if (result.exclude.length > 0) {
|
|
6119
|
-
params.excludeClearType = [...params.excludeClearType || [], ...result.exclude];
|
|
6120
|
-
}
|
|
6121
|
-
if (result.include.length > 0) {
|
|
6122
|
-
mergeClearTypes(params, result.include);
|
|
6123
|
-
}
|
|
6124
|
-
return true;
|
|
6125
|
-
}
|
|
6126
|
-
const singleGrades = parseSingleGrade(value);
|
|
6127
|
-
if (singleGrades !== null) {
|
|
6128
|
-
const result = applyGradeOperator(op, singleGrades[0]);
|
|
6129
|
-
if (result.exclude.length > 0) {
|
|
6130
|
-
params.excludeGrade = [...params.excludeGrade || [], ...result.exclude];
|
|
6131
|
-
}
|
|
6132
|
-
if (result.include.length > 0) {
|
|
6133
|
-
mergeGrades(params, result.include);
|
|
6134
|
-
}
|
|
6135
|
-
return true;
|
|
6136
|
-
}
|
|
6137
|
-
return false;
|
|
6138
|
-
}
|
|
6139
|
-
__name(parseWithOperator, "parseWithOperator");
|
|
6140
5366
|
function parseQueryInput(input) {
|
|
6141
5367
|
const params = {};
|
|
6142
5368
|
if (!input || input.trim() === "") {
|
|
@@ -6144,10 +5370,6 @@ function parseQueryInput(input) {
|
|
|
6144
5370
|
}
|
|
6145
5371
|
const items = input.split(/\s+/).map((s) => s.trim()).filter(Boolean);
|
|
6146
5372
|
for (const item of items) {
|
|
6147
|
-
const { op, value } = extractOperator(item);
|
|
6148
|
-
if (op) {
|
|
6149
|
-
if (parseWithOperator(params, op, value)) continue;
|
|
6150
|
-
}
|
|
6151
5373
|
const vf2 = parseVfValue(item);
|
|
6152
5374
|
if (vf2 !== null) {
|
|
6153
5375
|
if (params.vf !== void 0) {
|
|
@@ -6225,7 +5447,7 @@ function parseQueryInput(input) {
|
|
|
6225
5447
|
__name(parseQueryInput, "parseQueryInput");
|
|
6226
5448
|
|
|
6227
5449
|
// src/games/sdvx/commands/calculate.ts
|
|
6228
|
-
function calculate(ctx, config,
|
|
5450
|
+
function calculate(ctx, config, logger5) {
|
|
6229
5451
|
ctx.command("sdvx.calculate <query:text>").alias("sdvx.cal").action(async ({ session, options }, query) => {
|
|
6230
5452
|
try {
|
|
6231
5453
|
let queryInput = query;
|
|
@@ -6259,7 +5481,7 @@ function calculate(ctx, config, logger6) {
|
|
|
6259
5481
|
lossless: true
|
|
6260
5482
|
}
|
|
6261
5483
|
);
|
|
6262
|
-
return
|
|
5484
|
+
return import_koishi14.h.image(imageBuffer, "image/png");
|
|
6263
5485
|
} catch (error) {
|
|
6264
5486
|
ctx.logger("SDVX-Calculate").warn(error);
|
|
6265
5487
|
return session.text(".error");
|
|
@@ -6269,7 +5491,7 @@ function calculate(ctx, config, logger6) {
|
|
|
6269
5491
|
__name(calculate, "calculate");
|
|
6270
5492
|
|
|
6271
5493
|
// src/games/sdvx/commands/chart.ts
|
|
6272
|
-
var
|
|
5494
|
+
var import_koishi15 = require("koishi");
|
|
6273
5495
|
function mapArrangementToken(tok) {
|
|
6274
5496
|
const t = tok.toLowerCase();
|
|
6275
5497
|
if (t === "ran" || t === "random") return "random";
|
|
@@ -6352,7 +5574,7 @@ function getHighestDifstr(diffs) {
|
|
|
6352
5574
|
return diffs[diffs.length - 1].difstr;
|
|
6353
5575
|
}
|
|
6354
5576
|
__name(getHighestDifstr, "getHighestDifstr");
|
|
6355
|
-
function chart(ctx, config,
|
|
5577
|
+
function chart(ctx, config, logger5) {
|
|
6356
5578
|
ctx.command("sdvx.chart [query:text]").alias("sdvx.c").action(async ({ session }, query) => {
|
|
6357
5579
|
if (!query) {
|
|
6358
5580
|
await session.send(session.text(".prompt"));
|
|
@@ -6415,7 +5637,7 @@ function chart(ctx, config, logger6) {
|
|
|
6415
5637
|
const res = await ctx.http.post(`${config.sdvx_data_url}/chart`, payload, {
|
|
6416
5638
|
headers: { "Content-Type": "application/json" }
|
|
6417
5639
|
});
|
|
6418
|
-
return
|
|
5640
|
+
return import_koishi15.h.image(res, "image/png");
|
|
6419
5641
|
} else {
|
|
6420
5642
|
const {
|
|
6421
5643
|
diffStr: parsedDiff,
|
|
@@ -6431,7 +5653,7 @@ function chart(ctx, config, logger6) {
|
|
|
6431
5653
|
const picked = musicInfo[0];
|
|
6432
5654
|
const music_id = Number(picked?.id);
|
|
6433
5655
|
if (!Number.isFinite(music_id)) {
|
|
6434
|
-
|
|
5656
|
+
logger5.warn("search result missing id", picked);
|
|
6435
5657
|
return session.text(".error");
|
|
6436
5658
|
}
|
|
6437
5659
|
let difstr = null;
|
|
@@ -6465,76 +5687,16 @@ function chart(ctx, config, logger6) {
|
|
|
6465
5687
|
const res = await ctx.http.post(`${config.sdvx_data_url}/chart`, payload, {
|
|
6466
5688
|
headers: { "Content-Type": "application/json" }
|
|
6467
5689
|
});
|
|
6468
|
-
return
|
|
5690
|
+
return import_koishi15.h.image(res, "image/png");
|
|
6469
5691
|
}
|
|
6470
5692
|
} catch (err) {
|
|
6471
|
-
|
|
5693
|
+
logger5.warn(err);
|
|
6472
5694
|
return session.text(".error");
|
|
6473
5695
|
}
|
|
6474
5696
|
});
|
|
6475
5697
|
}
|
|
6476
5698
|
__name(chart, "chart");
|
|
6477
5699
|
|
|
6478
|
-
// src/core/utils/selector.ts
|
|
6479
|
-
var import_koishi18 = require("koishi");
|
|
6480
|
-
async function selectCard(session, cardService, uid) {
|
|
6481
|
-
const userCards = await cardService.getCardsByUid(uid);
|
|
6482
|
-
if (userCards.length === 0) {
|
|
6483
|
-
return { ok: false, message: session.text("selector.card-not-found") };
|
|
6484
|
-
}
|
|
6485
|
-
const defaultCard = await cardService.getDefaultCardByUid(uid);
|
|
6486
|
-
const defaultLabel = session.text("selector.default-card");
|
|
6487
|
-
let cardListMsg = "";
|
|
6488
|
-
for (let i = 0; i < userCards.length; i++) {
|
|
6489
|
-
if (defaultCard && userCards[i].id === defaultCard.id) {
|
|
6490
|
-
cardListMsg += `<p>${i + 1}. ${userCards[i].name} < ${defaultLabel}</p>`;
|
|
6491
|
-
} else {
|
|
6492
|
-
cardListMsg += `<p>${i + 1}. ${userCards[i].name}</p>`;
|
|
6493
|
-
}
|
|
6494
|
-
}
|
|
6495
|
-
const msg = import_koishi18.h.unescape(session.text("selector.menu-select", { card_list: cardListMsg }));
|
|
6496
|
-
await session.send(msg);
|
|
6497
|
-
const select = await session.prompt();
|
|
6498
|
-
if (!select) return { ok: false, message: session.text("commands.timeout") };
|
|
6499
|
-
if (select === "q") return { ok: false, message: session.text("selector.quit") };
|
|
6500
|
-
const selectNum = parseInt(select, 10);
|
|
6501
|
-
if (isNaN(selectNum) || selectNum < 1 || selectNum > userCards.length) {
|
|
6502
|
-
return { ok: false, message: session.text("selector.invalid-select") };
|
|
6503
|
-
}
|
|
6504
|
-
const card2 = await cardService.getCardByCode(userCards[selectNum - 1].code);
|
|
6505
|
-
return { ok: true, value: card2 };
|
|
6506
|
-
}
|
|
6507
|
-
__name(selectCard, "selectCard");
|
|
6508
|
-
async function selectServer(session, serverService, uid, channelId) {
|
|
6509
|
-
const servers = await serverService.getSelectableServers(uid, channelId);
|
|
6510
|
-
if (servers.length === 0) {
|
|
6511
|
-
return { ok: false, message: session.text("selector.server-not-found") };
|
|
6512
|
-
}
|
|
6513
|
-
const defaultServer = await serverService.getDefaultServerByUid(uid);
|
|
6514
|
-
const defaultLabel = session.text("selector.default-server");
|
|
6515
|
-
let serverListMsg = "";
|
|
6516
|
-
for (let i = 0; i < servers.length; i++) {
|
|
6517
|
-
if (defaultServer && servers[i].id === defaultServer.id) {
|
|
6518
|
-
serverListMsg += `<p>${i + 1}. ${servers[i].name} (${servers[i].type}) < ${defaultLabel}</p>`;
|
|
6519
|
-
} else {
|
|
6520
|
-
serverListMsg += `<p>${i + 1}. ${servers[i].name} (${servers[i].type})</p>`;
|
|
6521
|
-
}
|
|
6522
|
-
}
|
|
6523
|
-
const msg = import_koishi18.h.unescape(
|
|
6524
|
-
session.text("selector.server-menu-select", { server_list: serverListMsg })
|
|
6525
|
-
);
|
|
6526
|
-
await session.send(msg);
|
|
6527
|
-
const select = await session.prompt();
|
|
6528
|
-
if (!select) return { ok: false, message: session.text("commands.timeout") };
|
|
6529
|
-
if (select === "q") return { ok: false, message: session.text("selector.quit") };
|
|
6530
|
-
const selectNum = parseInt(select, 10);
|
|
6531
|
-
if (isNaN(selectNum) || selectNum < 1 || selectNum > servers.length) {
|
|
6532
|
-
return { ok: false, message: session.text("selector.invalid-select") };
|
|
6533
|
-
}
|
|
6534
|
-
return { ok: true, value: servers[selectNum - 1] };
|
|
6535
|
-
}
|
|
6536
|
-
__name(selectServer, "selectServer");
|
|
6537
|
-
|
|
6538
5700
|
// src/games/sdvx/services/score-service.ts
|
|
6539
5701
|
var ScoreService = class _ScoreService {
|
|
6540
5702
|
static {
|
|
@@ -6657,46 +5819,37 @@ var ScoreService = class _ScoreService {
|
|
|
6657
5819
|
};
|
|
6658
5820
|
|
|
6659
5821
|
// src/games/sdvx/commands/radar.ts
|
|
6660
|
-
function radar(ctx, config,
|
|
6661
|
-
ctx.command("sdvx.radar").userFields(["defaultCardId", "defaultServerId", "id"]).channelFields(["defaultServerId", "id"]).
|
|
5822
|
+
function radar(ctx, config, logger5) {
|
|
5823
|
+
ctx.command("sdvx.radar").userFields(["defaultCardId", "defaultServerId", "id"]).channelFields(["defaultServerId", "id"]).action(async ({ session }) => {
|
|
6662
5824
|
const atGuild = session.guildId != null;
|
|
6663
5825
|
const cardService = new CardService(ctx);
|
|
6664
5826
|
const serverService = new ServerService(ctx);
|
|
6665
|
-
const channelId = atGuild ? session.channel.id : null;
|
|
6666
5827
|
const userCards = await cardService.getCardsByUid(session.user.id);
|
|
6667
5828
|
if (userCards.length === 0) return session.text(".card-not-found");
|
|
6668
|
-
const serverRes = await serverService.getSelectableServers(
|
|
5829
|
+
const serverRes = await serverService.getSelectableServers(
|
|
5830
|
+
session.user.id,
|
|
5831
|
+
atGuild ? session.channel.id : null
|
|
5832
|
+
);
|
|
6669
5833
|
if (serverRes.length === 0) return session.text(".server-not-found");
|
|
6670
|
-
|
|
6671
|
-
if (
|
|
6672
|
-
|
|
6673
|
-
if (result.ok === false) return result.message;
|
|
6674
|
-
card2 = result.value;
|
|
6675
|
-
} else {
|
|
6676
|
-
const defaultCard = await cardService.getDefaultCardByUid(session.user.id);
|
|
6677
|
-
if (!defaultCard) return session.text(".card-not-found");
|
|
6678
|
-
card2 = await cardService.getCardByCode(defaultCard.code);
|
|
6679
|
-
}
|
|
5834
|
+
const defaultCard = await cardService.getDefaultCardByUid(session.user.id);
|
|
5835
|
+
if (!defaultCard) return session.text(".card-not-found");
|
|
5836
|
+
const card2 = await cardService.getCardByCode(defaultCard.code);
|
|
6680
5837
|
let server2;
|
|
6681
|
-
if (
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
session.user.id,
|
|
6686
|
-
channelId
|
|
6687
|
-
);
|
|
6688
|
-
if (result.ok === false) return result.message;
|
|
6689
|
-
server2 = result.value;
|
|
6690
|
-
} else {
|
|
6691
|
-
server2 = await resolveServerForCard(
|
|
6692
|
-
card2,
|
|
6693
|
-
cardService,
|
|
6694
|
-
serverService,
|
|
6695
|
-
session.user.id,
|
|
5838
|
+
if (card2.defaultServerId != void 0 && card2.defaultServerId != 0)
|
|
5839
|
+
server2 = await serverService.getServerById(card2.defaultServerId);
|
|
5840
|
+
else {
|
|
5841
|
+
const channelDefaultServer = atGuild ? await serverService.getDefaultServerByCid(
|
|
6696
5842
|
session.platform,
|
|
6697
|
-
|
|
6698
|
-
);
|
|
6699
|
-
if (
|
|
5843
|
+
session.channel.id
|
|
5844
|
+
) : null;
|
|
5845
|
+
if (channelDefaultServer) server2 = channelDefaultServer;
|
|
5846
|
+
else {
|
|
5847
|
+
const userDefaultServer = await serverService.getDefaultServerByUid(
|
|
5848
|
+
session.user.id
|
|
5849
|
+
);
|
|
5850
|
+
if (userDefaultServer) server2 = userDefaultServer;
|
|
5851
|
+
else return session.text(".server-not-found");
|
|
5852
|
+
}
|
|
6700
5853
|
}
|
|
6701
5854
|
const serverManager = ServerManager.getInstance();
|
|
6702
5855
|
const sdvxService = serverManager.getGameService(server2.type, "sdvx");
|
|
@@ -6723,7 +5876,7 @@ function radar(ctx, config, logger6) {
|
|
|
6723
5876
|
one_hand: radarResult.one_hand.toFixed(2)
|
|
6724
5877
|
});
|
|
6725
5878
|
} catch (error) {
|
|
6726
|
-
|
|
5879
|
+
logger5.warn(error);
|
|
6727
5880
|
return session.text(".error");
|
|
6728
5881
|
}
|
|
6729
5882
|
});
|
|
@@ -6731,48 +5884,63 @@ function radar(ctx, config, logger6) {
|
|
|
6731
5884
|
__name(radar, "radar");
|
|
6732
5885
|
|
|
6733
5886
|
// src/games/sdvx/commands/recent.ts
|
|
6734
|
-
var
|
|
6735
|
-
function recent(ctx, config,
|
|
6736
|
-
ctx.command("sdvx.recent [count:number]").alias("sdvx.r").userFields(["defaultCardId", "defaultServerId", "id"]).channelFields(["defaultServerId", "id"]).option("lossless", "-l").option("card", "-c").
|
|
5887
|
+
var import_koishi16 = require("koishi");
|
|
5888
|
+
function recent(ctx, config, logger5) {
|
|
5889
|
+
ctx.command("sdvx.recent [count:number]").alias("sdvx.r").userFields(["defaultCardId", "defaultServerId", "id"]).channelFields(["defaultServerId", "id"]).option("lossless", "-l").option("card", "-c").action(async ({ session, options }, count) => {
|
|
6737
5890
|
const atGuild = session.guildId != null;
|
|
6738
5891
|
if (!count) count = 1;
|
|
6739
5892
|
const cardService = new CardService(ctx);
|
|
6740
5893
|
const serverService = new ServerService(ctx);
|
|
6741
|
-
const channelId = atGuild ? session.channel.id : null;
|
|
6742
5894
|
const userCards = await cardService.getCardsByUid(session.user.id);
|
|
6743
5895
|
if (userCards.length === 0) return session.text(".card-not-found");
|
|
6744
|
-
const serverRes = await serverService.getSelectableServers(
|
|
5896
|
+
const serverRes = await serverService.getSelectableServers(
|
|
5897
|
+
session.user.id,
|
|
5898
|
+
atGuild ? session.channel.id : null
|
|
5899
|
+
);
|
|
6745
5900
|
if (serverRes.length === 0) return session.text(".server-not-found");
|
|
6746
|
-
let
|
|
6747
|
-
if (options.card) {
|
|
6748
|
-
const result = await selectCard(session, cardService, session.user.id);
|
|
6749
|
-
if (result.ok === false) return result.message;
|
|
6750
|
-
card2 = result.value;
|
|
6751
|
-
} else {
|
|
5901
|
+
let cardCode = "";
|
|
5902
|
+
if (!options.card) {
|
|
6752
5903
|
const defaultCard = await cardService.getDefaultCardByUid(session.user.id);
|
|
6753
5904
|
if (!defaultCard) return session.text(".card-not-found");
|
|
6754
|
-
|
|
5905
|
+
cardCode = defaultCard.code;
|
|
5906
|
+
} else {
|
|
5907
|
+
let cardListMsg = "";
|
|
5908
|
+
for (let i = 0; i < userCards.length; i++) {
|
|
5909
|
+
const defaultCard = await cardService.getDefaultCardByUid(session.user.id);
|
|
5910
|
+
if (defaultCard && userCards[i].id === defaultCard.id) {
|
|
5911
|
+
cardListMsg += `<p>${i + 1}. ${userCards[i].name} < 默认卡片</p>`;
|
|
5912
|
+
} else {
|
|
5913
|
+
cardListMsg += `<p>${i + 1}. ${userCards[i].name}</p>`;
|
|
5914
|
+
}
|
|
5915
|
+
}
|
|
5916
|
+
const msg = import_koishi16.h.unescape(session.text(".menu-select", { card_list: cardListMsg })).replace("< 默认卡片", "< 默认卡片");
|
|
5917
|
+
await session.send(msg);
|
|
5918
|
+
const select = await session.prompt();
|
|
5919
|
+
if (!select) return session.text("commands.timeout");
|
|
5920
|
+
if (select === "q") return session.text(".quit");
|
|
5921
|
+
const selectNum = parseInt(select, 10);
|
|
5922
|
+
if (isNaN(selectNum) || selectNum < 1 || selectNum > userCards.length) {
|
|
5923
|
+
return session.text(".invalid-select");
|
|
5924
|
+
}
|
|
5925
|
+
cardCode = userCards[selectNum - 1].code;
|
|
6755
5926
|
}
|
|
5927
|
+
const card2 = await cardService.getCardByCode(cardCode);
|
|
6756
5928
|
let server2;
|
|
6757
|
-
if (
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
session.user.id,
|
|
6762
|
-
channelId
|
|
6763
|
-
);
|
|
6764
|
-
if (result.ok === false) return result.message;
|
|
6765
|
-
server2 = result.value;
|
|
6766
|
-
} else {
|
|
6767
|
-
server2 = await resolveServerForCard(
|
|
6768
|
-
card2,
|
|
6769
|
-
cardService,
|
|
6770
|
-
serverService,
|
|
6771
|
-
session.user.id,
|
|
5929
|
+
if (card2.defaultServerId != void 0 && card2.defaultServerId != 0)
|
|
5930
|
+
server2 = await serverService.getServerById(card2.defaultServerId);
|
|
5931
|
+
else {
|
|
5932
|
+
const channelDefaultServer = atGuild ? await serverService.getDefaultServerByCid(
|
|
6772
5933
|
session.platform,
|
|
6773
|
-
|
|
6774
|
-
);
|
|
6775
|
-
if (
|
|
5934
|
+
session.channel.id
|
|
5935
|
+
) : null;
|
|
5936
|
+
if (channelDefaultServer) server2 = channelDefaultServer;
|
|
5937
|
+
else {
|
|
5938
|
+
const userDefaultServer = await serverService.getDefaultServerByUid(
|
|
5939
|
+
session.user.id
|
|
5940
|
+
);
|
|
5941
|
+
if (userDefaultServer) server2 = userDefaultServer;
|
|
5942
|
+
else return session.text(".server-not-found");
|
|
5943
|
+
}
|
|
6776
5944
|
}
|
|
6777
5945
|
const serverManager = ServerManager.getInstance();
|
|
6778
5946
|
const sdvxService = serverManager.getGameService(server2.type, "sdvx");
|
|
@@ -6802,11 +5970,11 @@ function recent(ctx, config, logger6) {
|
|
|
6802
5970
|
}
|
|
6803
5971
|
);
|
|
6804
5972
|
if (options.lossless) {
|
|
6805
|
-
return
|
|
5973
|
+
return import_koishi16.h.image(imageBuffer, "image/png");
|
|
6806
5974
|
}
|
|
6807
|
-
return
|
|
5975
|
+
return import_koishi16.h.image(imageBuffer, "image/jpg");
|
|
6808
5976
|
} catch (error) {
|
|
6809
|
-
|
|
5977
|
+
logger5.warn(error);
|
|
6810
5978
|
return session.text(".error");
|
|
6811
5979
|
}
|
|
6812
5980
|
});
|
|
@@ -6814,7 +5982,7 @@ function recent(ctx, config, logger6) {
|
|
|
6814
5982
|
__name(recent, "recent");
|
|
6815
5983
|
|
|
6816
5984
|
// src/games/sdvx/commands/sync.ts
|
|
6817
|
-
function sync(ctx, config,
|
|
5985
|
+
function sync(ctx, config, logger5) {
|
|
6818
5986
|
ctx.command("sdvx.sync").userFields(["id"]).channelFields(["id"]).action(async ({ session }) => {
|
|
6819
5987
|
const serverService = new ServerService(ctx);
|
|
6820
5988
|
const cardService = new CardService(ctx);
|
|
@@ -6889,7 +6057,7 @@ function sync(ctx, config, logger6) {
|
|
|
6889
6057
|
const maoSdvxService = serverManager.getGameService("mao", "sdvx");
|
|
6890
6058
|
const maoVerifyUrl = "https://maomani.cn";
|
|
6891
6059
|
if (!maoSdvxService || typeof maoSdvxService.verifyPin !== "function") {
|
|
6892
|
-
|
|
6060
|
+
logger5.warn("Mao SDVX service does not support PIN verification");
|
|
6893
6061
|
return session.text(".pin-verify-error");
|
|
6894
6062
|
}
|
|
6895
6063
|
const existingPin = await ctx.database.get("sdvx_pin_verified", {
|
|
@@ -6910,7 +6078,7 @@ function sync(ctx, config, logger6) {
|
|
|
6910
6078
|
pinVerified = true;
|
|
6911
6079
|
}
|
|
6912
6080
|
} catch (error) {
|
|
6913
|
-
|
|
6081
|
+
logger5.warn(error);
|
|
6914
6082
|
}
|
|
6915
6083
|
}
|
|
6916
6084
|
if (!pinVerified) {
|
|
@@ -6946,7 +6114,7 @@ function sync(ctx, config, logger6) {
|
|
|
6946
6114
|
})
|
|
6947
6115
|
);
|
|
6948
6116
|
} catch (error) {
|
|
6949
|
-
|
|
6117
|
+
logger5.warn(error);
|
|
6950
6118
|
await session.send(session.text(".pin-verify-error"));
|
|
6951
6119
|
}
|
|
6952
6120
|
}
|
|
@@ -6968,7 +6136,7 @@ function sync(ctx, config, logger6) {
|
|
|
6968
6136
|
config
|
|
6969
6137
|
);
|
|
6970
6138
|
} catch (error) {
|
|
6971
|
-
|
|
6139
|
+
logger5.warn(error);
|
|
6972
6140
|
return session.text(".fetch-error");
|
|
6973
6141
|
}
|
|
6974
6142
|
if (!scoreList || scoreList.length === 0) {
|
|
@@ -6990,11 +6158,11 @@ function sync(ctx, config, logger6) {
|
|
|
6990
6158
|
scoreList
|
|
6991
6159
|
);
|
|
6992
6160
|
if (!ok) {
|
|
6993
|
-
|
|
6161
|
+
logger5.warn("Mao SDVX uploadScore returned falsy result");
|
|
6994
6162
|
return session.text(".sync-failed");
|
|
6995
6163
|
}
|
|
6996
6164
|
} catch (error) {
|
|
6997
|
-
|
|
6165
|
+
logger5.warn(error);
|
|
6998
6166
|
return session.text(".sync-error");
|
|
6999
6167
|
}
|
|
7000
6168
|
return session.text(".selected-summary", {
|
|
@@ -7009,8 +6177,8 @@ function sync(ctx, config, logger6) {
|
|
|
7009
6177
|
__name(sync, "sync");
|
|
7010
6178
|
|
|
7011
6179
|
// src/games/sdvx/commands/vf.ts
|
|
7012
|
-
var
|
|
7013
|
-
var
|
|
6180
|
+
var fs4 = __toESM(require("fs"), 1);
|
|
6181
|
+
var import_koishi17 = require("koishi");
|
|
7014
6182
|
|
|
7015
6183
|
// src/games/sdvx/utils/filter.ts
|
|
7016
6184
|
function parseFilterQuery(query) {
|
|
@@ -7063,46 +6231,61 @@ function parseFilterQuery(query) {
|
|
|
7063
6231
|
__name(parseFilterQuery, "parseFilterQuery");
|
|
7064
6232
|
|
|
7065
6233
|
// src/games/sdvx/commands/vf.ts
|
|
7066
|
-
function vf(ctx, config,
|
|
7067
|
-
ctx.command("vf").userFields(["defaultCardId", "defaultServerId", "id"]).channelFields(["defaultServerId", "id"]).option("lossless", "-l").option("card", "-c").option("
|
|
6234
|
+
function vf(ctx, config, logger5) {
|
|
6235
|
+
ctx.command("vf").userFields(["defaultCardId", "defaultServerId", "id"]).channelFields(["defaultServerId", "id"]).option("lossless", "-l").option("card", "-c").option("filter", "-f <query:text>").action(async ({ session, options }) => {
|
|
7068
6236
|
const atGuild = session.guildId != null;
|
|
7069
6237
|
const cardService = new CardService(ctx);
|
|
7070
6238
|
const serverService = new ServerService(ctx);
|
|
7071
|
-
const channelId = atGuild ? session.channel.id : null;
|
|
7072
6239
|
const userCards = await cardService.getCardsByUid(session.user.id);
|
|
7073
6240
|
if (userCards.length === 0) return session.text(".card-not-found");
|
|
7074
|
-
const serverRes = await serverService.getSelectableServers(
|
|
6241
|
+
const serverRes = await serverService.getSelectableServers(
|
|
6242
|
+
session.user.id,
|
|
6243
|
+
atGuild ? session.channel.id : null
|
|
6244
|
+
);
|
|
7075
6245
|
if (serverRes.length === 0) return session.text(".server-not-found");
|
|
7076
|
-
let
|
|
7077
|
-
if (options.card) {
|
|
7078
|
-
const result = await selectCard(session, cardService, session.user.id);
|
|
7079
|
-
if (result.ok === false) return result.message;
|
|
7080
|
-
card2 = result.value;
|
|
7081
|
-
} else {
|
|
6246
|
+
let cardCode = "";
|
|
6247
|
+
if (!options.card) {
|
|
7082
6248
|
const defaultCard = await cardService.getDefaultCardByUid(session.user.id);
|
|
7083
6249
|
if (!defaultCard) return session.text(".card-not-found");
|
|
7084
|
-
|
|
6250
|
+
cardCode = defaultCard.code;
|
|
6251
|
+
} else {
|
|
6252
|
+
let cardListMsg = "";
|
|
6253
|
+
for (let i = 0; i < userCards.length; i++) {
|
|
6254
|
+
const defaultCard = await cardService.getDefaultCardByUid(session.user.id);
|
|
6255
|
+
if (defaultCard && userCards[i].id === defaultCard.id) {
|
|
6256
|
+
cardListMsg += `<p>${i + 1}. ${userCards[i].name} < 默认卡片</p>`;
|
|
6257
|
+
} else {
|
|
6258
|
+
cardListMsg += `<p>${i + 1}. ${userCards[i].name}</p>`;
|
|
6259
|
+
}
|
|
6260
|
+
}
|
|
6261
|
+
const msg = import_koishi17.h.unescape(session.text(".menu-select", { card_list: cardListMsg })).replace("< 默认卡片", "< 默认卡片");
|
|
6262
|
+
await session.send(msg);
|
|
6263
|
+
const select = await session.prompt();
|
|
6264
|
+
if (!select) return session.text("commands.timeout");
|
|
6265
|
+
if (select === "q") return session.text(".quit");
|
|
6266
|
+
const selectNum = parseInt(select, 10);
|
|
6267
|
+
if (isNaN(selectNum) || selectNum < 1 || selectNum > userCards.length) {
|
|
6268
|
+
return session.text(".invalid-select");
|
|
6269
|
+
}
|
|
6270
|
+
cardCode = userCards[selectNum - 1].code;
|
|
7085
6271
|
}
|
|
6272
|
+
const card2 = await cardService.getCardByCode(cardCode);
|
|
7086
6273
|
let server2;
|
|
7087
|
-
if (
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
session.user.id,
|
|
7092
|
-
channelId
|
|
7093
|
-
);
|
|
7094
|
-
if (result.ok === false) return result.message;
|
|
7095
|
-
server2 = result.value;
|
|
7096
|
-
} else {
|
|
7097
|
-
server2 = await resolveServerForCard(
|
|
7098
|
-
card2,
|
|
7099
|
-
cardService,
|
|
7100
|
-
serverService,
|
|
7101
|
-
session.user.id,
|
|
6274
|
+
if (card2.defaultServerId != void 0 && card2.defaultServerId != 0)
|
|
6275
|
+
server2 = await serverService.getServerById(card2.defaultServerId);
|
|
6276
|
+
else {
|
|
6277
|
+
const channelDefaultServer = atGuild ? await serverService.getDefaultServerByCid(
|
|
7102
6278
|
session.platform,
|
|
7103
|
-
|
|
7104
|
-
);
|
|
7105
|
-
if (
|
|
6279
|
+
session.channel.id
|
|
6280
|
+
) : null;
|
|
6281
|
+
if (channelDefaultServer) server2 = channelDefaultServer;
|
|
6282
|
+
else {
|
|
6283
|
+
const userDefaultServer = await serverService.getDefaultServerByUid(
|
|
6284
|
+
session.user.id
|
|
6285
|
+
);
|
|
6286
|
+
if (userDefaultServer) server2 = userDefaultServer;
|
|
6287
|
+
else return session.text(".server-not-found");
|
|
6288
|
+
}
|
|
7106
6289
|
}
|
|
7107
6290
|
const serverManager = ServerManager.getInstance();
|
|
7108
6291
|
const sdvxService = serverManager.getGameService(server2.type, "sdvx");
|
|
@@ -7138,9 +6321,9 @@ function vf(ctx, config, logger6) {
|
|
|
7138
6321
|
}
|
|
7139
6322
|
);
|
|
7140
6323
|
if (options.lossless) {
|
|
7141
|
-
session.send(
|
|
6324
|
+
session.send(import_koishi17.h.file(imageBuffer, "image/png"));
|
|
7142
6325
|
} else {
|
|
7143
|
-
session.send(
|
|
6326
|
+
session.send(import_koishi17.h.image(imageBuffer, "image/jpg"));
|
|
7144
6327
|
}
|
|
7145
6328
|
const sortedScores = [...best50ScoreList].sort((a, b) => b.extra.volforce - a.extra.volforce).slice(0, 50);
|
|
7146
6329
|
const total = sortedScores.reduce((sum, score) => sum + score.extra.volforce, 0);
|
|
@@ -7167,20 +6350,20 @@ function vf(ctx, config, logger6) {
|
|
|
7167
6350
|
ctx,
|
|
7168
6351
|
"stamps/noah_stamp/stamp_0385/stamp_0385_02.png"
|
|
7169
6352
|
);
|
|
7170
|
-
if (
|
|
7171
|
-
const audioBuffer =
|
|
7172
|
-
session.send(
|
|
6353
|
+
if (fs4.existsSync(audioPath)) {
|
|
6354
|
+
const audioBuffer = fs4.readFileSync(audioPath);
|
|
6355
|
+
session.send(import_koishi17.h.audio(audioBuffer, "audio/mpeg"));
|
|
7173
6356
|
}
|
|
7174
|
-
if (
|
|
7175
|
-
const imageBuffer2 =
|
|
7176
|
-
session.send(
|
|
6357
|
+
if (fs4.existsSync(imagePath)) {
|
|
6358
|
+
const imageBuffer2 = fs4.readFileSync(imagePath);
|
|
6359
|
+
session.send(import_koishi17.h.image(imageBuffer2, "image/png"));
|
|
7177
6360
|
}
|
|
7178
6361
|
} catch (error) {
|
|
7179
|
-
|
|
6362
|
+
logger5.warn(`Failed to send celebration files: ${error.message}`);
|
|
7180
6363
|
}
|
|
7181
6364
|
}
|
|
7182
6365
|
} catch (error) {
|
|
7183
|
-
|
|
6366
|
+
logger5.warn(error);
|
|
7184
6367
|
return session.text(".error");
|
|
7185
6368
|
}
|
|
7186
6369
|
return;
|
|
@@ -7192,12 +6375,12 @@ __name(vf, "vf");
|
|
|
7192
6375
|
var name10 = "command";
|
|
7193
6376
|
function apply10(ctx, config) {
|
|
7194
6377
|
ctx.command("sdvx").alias("s");
|
|
7195
|
-
vf(ctx, config,
|
|
7196
|
-
recent(ctx, config,
|
|
7197
|
-
chart(ctx, config,
|
|
7198
|
-
calculate(ctx, config,
|
|
7199
|
-
sync(ctx, config,
|
|
7200
|
-
radar(ctx, config,
|
|
6378
|
+
vf(ctx, config, logger4);
|
|
6379
|
+
recent(ctx, config, logger4);
|
|
6380
|
+
chart(ctx, config, logger4);
|
|
6381
|
+
calculate(ctx, config, logger4);
|
|
6382
|
+
sync(ctx, config, logger4);
|
|
6383
|
+
radar(ctx, config, logger4);
|
|
7201
6384
|
}
|
|
7202
6385
|
__name(apply10, "apply");
|
|
7203
6386
|
|
|
@@ -7237,22 +6420,22 @@ function apply12(ctx) {
|
|
|
7237
6420
|
__name(apply12, "apply");
|
|
7238
6421
|
|
|
7239
6422
|
// src/games/sdvx/locales/en-US.yml
|
|
7240
|
-
var en_US_default4 = { _config: { $desc: "SDVX Module Settings", sdvx_data_url: "<p>The URL of the SDVX data service</p>", sdvx_search_url: "<p>The URL of the SDVX search service</p>", official_support_url: "<p>The URL of the SDVX official support service</p>" }, commands: { vf: { description: "Show Noah help information", messages: { "card-not-found": "<p>You haven't bound a card yet, go bind a card first~</p>", "server-not-found": "<p>No available servers, add one yourself~</p>", "no-scores-found": "<p>No scores found, please check your data.</p>", error: "<p>An error occurred(っ °Д °;)っ</p>", drawing: "<p>Noah is drawing {name} [{difstr}], please wait patiently~</p>", "menu-select": "<p>Please select the card you want to use:</p>\n{card_list}\n<p>q. Exit</p>", "
|
|
6423
|
+
var en_US_default4 = { _config: { $desc: "SDVX Module Settings", sdvx_data_url: "<p>The URL of the SDVX data service</p>", sdvx_search_url: "<p>The URL of the SDVX search service</p>", official_support_url: "<p>The URL of the SDVX official support service</p>" }, commands: { vf: { description: "Show Noah help information", messages: { "card-not-found": "<p>You haven't bound a card yet, go bind a card first~</p>", "server-not-found": "<p>No available servers, add one yourself~</p>", "no-scores-found": "<p>No scores found, please check your data.</p>", error: "<p>An error occurred(っ °Д °;)っ</p>", drawing: "<p>Noah is drawing {name} [{difstr}], please wait patiently~</p>", "menu-select": "<p>Please select the card you want to use:</p>\n{card_list}\n<p>q. Exit</p>", "invalid-select": "<p>No such option!</p>", quit: "<p>Exited~</p>" } }, sdvx: { recent: { description: "Show recent scores", messages: { "menu-select": "<p>Please select the card you want to use:</p>\n{card_list}\n<p>q. Exit</p>", "invalid-select": "<p>No such option!</p>", "card-not-found": "<p>You haven't bound a card yet, go bind a card first~</p>", "server-not-found": "<p>No available servers, add one yourself~</p>", "no-scores-found": "<p>No scores found, please check your data.</p>", error: "<p>An error occurred(っ °Д °;)っ</p>", drawing: "<p>Noah is drawing, please wait patiently~</p>" } }, chart: { description: "Show SDVX chart", messages: { prompt: "<p>Which song's chart would you like to view?</p>", error: "<p>An error occurred(っ °Д °;)っ</p>", drawing: "<p>Noah is drawing, please wait patiently~</p>", "no-result": "<p>Aww, Noah couldn’t find that song~ try another keyword, okay?</p>" } }, calculate: { description: "Calculate volforce value or score", messages: { "invalid-query": "<p>Invalid query parameters, please check your input~</p>", "no-results": "<p>No results found~</p>", "too-many-results": "<p>Too many results! Found {0} results, please narrow down your query (current limit: 500 results)</p>", drawing: "<p>Noah is drawing, please wait patiently~</p>", error: "<p>An error occurred(っ °Д °;)っ</p>" } }, radar: { description: "Show player radar stats", messages: { "card-not-found": "<p>You haven't bound a card yet, go bind a card first~</p>", "server-not-found": "<p>No available servers, add one yourself~</p>", "no-scores-found": "<p>No scores found, please check your data.</p>", error: "<p>An error occurred(っ °Д °;)っ</p>", result: "<p>{name}'s Radar</p>\n<p>NOTES: {notes}</p>\n<p>PEAK: {peak}</p>\n<p>TSUMAMI: {tsumami}</p>\n<p>TRICKY: {tricky}</p>\n<p>HAND-TRIP: {hand_trip}</p>\n<p>ONE-HAND: {one_hand}</p>" } }, sync: { description: "Sync scores to Mao", messages: { "mao-not-found": "<p>Mao server not found. Please add a Mao server first, then try syncing again.</p>", "source-server-not-found": "<p>No available source servers. Please add a server first.</p>", "source-server-select": "<p>Please choose the source server:</p>\n{server_list}\n<p>q. Exit</p>", "card-not-found": "<p>You haven't bound any card yet. Please bind a card first.</p>", "source-card-select": "<p>Please choose the source card:</p>\n{card_list}\n<p>q. Exit</p>", "target-card-select": "<p>Please choose the target card (sync to Mao):</p>\n{card_list}\n<p>q. Exit</p>", "invalid-select": "<p>No such option!</p>", quit: "<p>Sync cancelled.</p>", "same-card-error": "<p>When the source server is Mao, the source card and target card cannot be the same. Please choose again.</p>", "dm-only": "<p>For security, please use this command in a private chat.</p>", "pin-prompt": "<p>Please enter the Mao PIN (4 digits):</p>\n<p>q. Exit</p>", "pin-invalid": "<p>Invalid PIN format. Please enter 4 digits.</p>", "pin-verify-failed": "<p>PIN verification failed: {message}</p>", "pin-verify-error": "<p>PIN verification error. Please try again later.</p>", "pin-too-many": "<p>Too many PIN attempts. Please try again later.</p>", "fetch-error": "<p>Failed to fetch scores from the source server. Please try again later.</p>", "no-scores": "<p>No scores available for sync.</p>", "confirm-sync": "<p>Found {score_count} scores. Start sync?</p>\n<p>Type y to confirm, any other key to cancel.</p>", "sync-error": "<p>Error occurred during sync(っ °Д °;)っ</p>", "sync-failed": "<p>Sync failed(っ °Д °;)っ</p>", "selected-summary": "<p>Sync completedヾ(≧▽≦*)o</p>\n<p>Source server: {source_server_name} ({source_server_type})</p>\n<p>Source card: {source_card_name}</p>\n<p>Target card: {target_card_name}</p>\n<p>Tracks synced: {score_count}</p>" } } } } };
|
|
7241
6424
|
|
|
7242
6425
|
// src/games/sdvx/locales/zh-CN.yml
|
|
7243
|
-
var zh_CN_default4 = { _config: { $desc: "SDVX 模块设置", sdvx_data_url: "<p>SDVX 数据服务的 URL</p>", sdvx_search_url: "<p>SDVX 搜索服务的 URL</p>", official_support_url: "<p>SDVX 官方支持服务的 URL</p>" }, commands: { vf: { description: "查询 SDVX VOLFORCE", messages: { "card-not-found": "<p>你还没绑卡,去绑个卡再来吧~</p>", "server-not-found": "<p>没有可用的服务器哦,自己添加一个吧~</p>", "no-scores-found": "<p>没有找到你的分数数据哦~</p>", error: "<p>Noah 遇到了错误(っ °Д °;)っ</p>", drawing: "<p>Noah 正在画啦,请耐心等待~</p>", "menu-select": "<p>请选择你要使用的卡片:</p>\n{card_list}\n<p>q. 退出</p>", "
|
|
6426
|
+
var zh_CN_default4 = { _config: { $desc: "SDVX 模块设置", sdvx_data_url: "<p>SDVX 数据服务的 URL</p>", sdvx_search_url: "<p>SDVX 搜索服务的 URL</p>", official_support_url: "<p>SDVX 官方支持服务的 URL</p>" }, commands: { vf: { description: "查询 SDVX VOLFORCE", messages: { "card-not-found": "<p>你还没绑卡,去绑个卡再来吧~</p>", "server-not-found": "<p>没有可用的服务器哦,自己添加一个吧~</p>", "no-scores-found": "<p>没有找到你的分数数据哦~</p>", error: "<p>Noah 遇到了错误(っ °Д °;)っ</p>", drawing: "<p>Noah 正在画啦,请耐心等待~</p>", "menu-select": "<p>请选择你要使用的卡片:</p>\n{card_list}\n<p>q. 退出</p>", "invalid-select": "<p>没有该选项!</p>", quit: "<p>已退出~</p>" } }, sdvx: { recent: { description: "查询最近分数", messages: { "menu-select": "<p>请选择你要使用的卡片:</p>\n{card_list}\n<p>q. 退出</p>", "invalid-select": "<p>没有该选项!</p>", "card-not-found": "<p>你还没绑卡,去绑个卡再来吧~</p>", "server-not-found": "<p>没有可用的服务器哦,自己添加一个吧~</p>", "no-scores-found": "<p>没有找到你的分数数据哦~</p>", error: "<p>Noah 遇到了错误(っ °Д °;)っ</p>", drawing: "<p>Noah 正在画啦,请耐心等待~</p>" } }, chart: { description: "查询 SDVX 谱面", messages: { prompt: "<p>要查哪首歌的铺面呢?</p>", error: "<p>Noah 遇到了错误(っ °Д °;)っ</p>", drawing: "<p>Noah 正在绘制 {name} [{difstr}],请耐心等待~</p>", "no-result": "<p>Noah 没有找到这首歌,换个关键词试试吧~</p>" } }, calculate: { description: "计算 volforce 值或分数", messages: { "invalid-query": "<p>查询参数无效,请检查你的输入~</p>", "no-results": "<p>没有找到符合条件的结果~</p>", "too-many-results": "<p>结果太多啦!共找到 {0} 条结果,请缩小查询范围(当前限制:500 条)</p>", drawing: "<p>Noah 正在画啦,请耐心等待~</p>", error: "<p>Noah 遇到了错误(っ °Д °;)っ</p>" } }, radar: { description: "查询玩家六维雷达", messages: { "card-not-found": "<p>你还没绑卡,去绑个卡再来吧~</p>", "server-not-found": "<p>没有可用的服务器哦,自己添加一个吧~</p>", "no-scores-found": "<p>没有找到你的分数数据哦~</p>", error: "<p>Noah 遇到了错误(っ °Д °;)っ</p>", result: "<p>{name} 的雷达</p>\n<p>NOTES: {notes}</p>\n<p>PEAK: {peak}</p>\n<p>TSUMAMI: {tsumami}</p>\n<p>TRICKY: {tricky}</p>\n<p>HAND-TRIP: {hand_trip}</p>\n<p>ONE-HAND: {one_hand}</p>" } }, sync: { description: "同步成绩到猫网", messages: { "mao-not-found": "<p>没有找到猫网服务器,请先添加猫网服务器后再尝试同步。</p>", "source-server-not-found": "<p>没有可作为来源的服务器,请先添加服务器。</p>", "source-server-select": "<p>请选择来源服务器:</p>\n{server_list}\n<p>q. 退出</p>", "card-not-found": "<p>你还没有绑定任何卡片哦~</p>", "source-card-select": "<p>请选择来源卡片:</p>\n{card_list}\n<p>q. 退出</p>", "target-card-select": "<p>请选择目标卡片(同步到猫网):</p>\n{card_list}\n<p>q. 退出</p>", "invalid-select": "<p>没有该选项!</p>", quit: "<p>已退出同步。</p>", "same-card-error": "<p>来源服务器为猫网时,来源卡片和目标卡片不能相同,请重新选择。</p>", "dm-only": "<p>出于安全考虑,请在私聊中使用该指令。</p>", "pin-prompt": "<p>请输入猫网 PIN 码(4 位数字):</p>\n<p>q. 退出</p>", "pin-invalid": "<p>PIN 码格式不正确,请输入 4 位数字。</p>", "pin-verify-failed": "<p>PIN 验证失败:{message}</p>", "pin-verify-error": "<p>PIN 验证时出现错误,请稍后重试。</p>", "pin-too-many": "<p>PIN 验证次数过多,请稍后再试。</p>", "fetch-error": "<p>获取来源服务器成绩失败,请稍后再试。</p>", "no-scores": "<p>没有可同步的成绩。</p>", "confirm-sync": "<p>共找到 {score_count} 条成绩,是否开始同步?</p>\n<p>输入 y 确认,其他任意键取消。</p>", "sync-error": "<p>同步过程中出现了错误(っ °Д °;)っ</p>", "sync-failed": "<p>同步失败(っ °Д °;)っ</p>", "selected-summary": "<p>同步完成ヾ(≧▽≦*)o</p>\n<p>来源服务器:{source_server_name} ({source_server_type})</p>\n<p>来源卡片:{source_card_name}</p>\n<p>目标卡片:{target_card_name}</p>\n<p>同步曲目数量:{score_count}</p>" } } } } };
|
|
7244
6427
|
|
|
7245
6428
|
// src/games/sdvx/index.ts
|
|
7246
6429
|
var name13 = "Noah-SDVX";
|
|
7247
6430
|
var inject3 = ["database", "globalConfig"];
|
|
7248
|
-
var
|
|
6431
|
+
var logger4 = new import_koishi18.Logger("Noah-SDVX");
|
|
7249
6432
|
async function apply13(ctx, config) {
|
|
7250
6433
|
;
|
|
7251
6434
|
[
|
|
7252
6435
|
["en-US", en_US_default4],
|
|
7253
6436
|
["zh-CN", zh_CN_default4]
|
|
7254
6437
|
].forEach(([lang, file]) => ctx.i18n.define(lang, file));
|
|
7255
|
-
registerSDVXAdapters(
|
|
6438
|
+
registerSDVXAdapters(logger4, config.sdvx);
|
|
7256
6439
|
ctx.plugin(database_exports2, config.sdvx);
|
|
7257
6440
|
ctx.plugin(command_exports2, config.sdvx);
|
|
7258
6441
|
ctx.plugin(event_exports2, config.sdvx);
|
|
@@ -7260,50 +6443,47 @@ async function apply13(ctx, config) {
|
|
|
7260
6443
|
__name(apply13, "apply");
|
|
7261
6444
|
|
|
7262
6445
|
// src/config.ts
|
|
7263
|
-
var
|
|
6446
|
+
var import_koishi26 = require("koishi");
|
|
7264
6447
|
|
|
7265
6448
|
// src/asset/config.ts
|
|
7266
|
-
var
|
|
7267
|
-
var assetConfig =
|
|
7268
|
-
data_path:
|
|
7269
|
-
auto_update:
|
|
7270
|
-
update_url:
|
|
7271
|
-
update_interval:
|
|
6449
|
+
var import_koishi19 = require("koishi");
|
|
6450
|
+
var assetConfig = import_koishi19.Schema.object({
|
|
6451
|
+
data_path: import_koishi19.Schema.string().default("noah_assets"),
|
|
6452
|
+
auto_update: import_koishi19.Schema.boolean().default(true),
|
|
6453
|
+
update_url: import_koishi19.Schema.string().default("https://github.com/logthm/noah/releases/latest/download/"),
|
|
6454
|
+
update_interval: import_koishi19.Schema.number().default(24 * 60 * 60 * 1e3),
|
|
7272
6455
|
// 24 hours in milliseconds
|
|
7273
|
-
github_token:
|
|
6456
|
+
github_token: import_koishi19.Schema.string().description("GitHub token for accessing private repositories").role("secret")
|
|
7274
6457
|
}).i18n({
|
|
7275
6458
|
"en-US": en_US_default._config,
|
|
7276
6459
|
"zh-CN": zh_CN_default._config
|
|
7277
6460
|
});
|
|
7278
6461
|
|
|
7279
6462
|
// src/core/config.ts
|
|
7280
|
-
var
|
|
7281
|
-
var coreConfig =
|
|
7282
|
-
adminUsers:
|
|
7283
|
-
guildNameCards:
|
|
7284
|
-
tokenTtl: import_koishi23.Schema.number().default(1800),
|
|
7285
|
-
frontendUrl: import_koishi23.Schema.string().default(""),
|
|
7286
|
-
corsOrigin: import_koishi23.Schema.string().default("*")
|
|
6463
|
+
var import_koishi20 = require("koishi");
|
|
6464
|
+
var coreConfig = import_koishi20.Schema.object({
|
|
6465
|
+
adminUsers: import_koishi20.Schema.array(String).role("table"),
|
|
6466
|
+
guildNameCards: import_koishi20.Schema.array(String).role("table").default(["Noah | /help 获取食用指南"])
|
|
7287
6467
|
}).i18n({
|
|
7288
6468
|
"en-US": en_US_default2._config,
|
|
7289
6469
|
"zh-CN": zh_CN_default2._config
|
|
7290
6470
|
});
|
|
7291
6471
|
|
|
7292
6472
|
// src/fun/poke/config.ts
|
|
7293
|
-
var
|
|
7294
|
-
var pokeConfig =
|
|
7295
|
-
interval:
|
|
7296
|
-
warning:
|
|
7297
|
-
prompt:
|
|
7298
|
-
|
|
7299
|
-
content:
|
|
7300
|
-
weight:
|
|
6473
|
+
var import_koishi21 = require("koishi");
|
|
6474
|
+
var pokeConfig = import_koishi21.Schema.object({
|
|
6475
|
+
interval: import_koishi21.Schema.number().default(1e3).step(100),
|
|
6476
|
+
warning: import_koishi21.Schema.boolean().default(false),
|
|
6477
|
+
prompt: import_koishi21.Schema.array(
|
|
6478
|
+
import_koishi21.Schema.object({
|
|
6479
|
+
content: import_koishi21.Schema.string().required(),
|
|
6480
|
+
weight: import_koishi21.Schema.number().min(0).max(100).default(50)
|
|
7301
6481
|
})
|
|
7302
6482
|
).role("table"),
|
|
7303
|
-
messages:
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
weight:
|
|
6483
|
+
messages: import_koishi21.Schema.array(
|
|
6484
|
+
import_koishi21.Schema.object({
|
|
6485
|
+
content: import_koishi21.Schema.string().required(),
|
|
6486
|
+
weight: import_koishi21.Schema.number().min(0).max(100).default(50)
|
|
7307
6487
|
})
|
|
7308
6488
|
).role("table")
|
|
7309
6489
|
}).i18n({
|
|
@@ -7312,7 +6492,7 @@ var pokeConfig = import_koishi24.Schema.object({
|
|
|
7312
6492
|
});
|
|
7313
6493
|
|
|
7314
6494
|
// src/games/general/config.ts
|
|
7315
|
-
var
|
|
6495
|
+
var import_koishi22 = require("koishi");
|
|
7316
6496
|
|
|
7317
6497
|
// src/games/general/locales/en-US.yml
|
|
7318
6498
|
var en_US_default5 = { _config: { $desc: "General Module Settings", barcode_api_url: "<p>The URL of the barcode API</p>" } };
|
|
@@ -7321,33 +6501,33 @@ var en_US_default5 = { _config: { $desc: "General Module Settings", barcode_api_
|
|
|
7321
6501
|
var zh_CN_default5 = { _config: { $desc: "通用工具模块设置", barcode_api_url: "<p>条形码 API 地址</p>" } };
|
|
7322
6502
|
|
|
7323
6503
|
// src/games/general/config.ts
|
|
7324
|
-
var generalConfig =
|
|
7325
|
-
barcode_api_url:
|
|
6504
|
+
var generalConfig = import_koishi22.Schema.object({
|
|
6505
|
+
barcode_api_url: import_koishi22.Schema.string().required()
|
|
7326
6506
|
}).i18n({
|
|
7327
6507
|
"en-US": en_US_default5._config,
|
|
7328
6508
|
"zh-CN": zh_CN_default5._config
|
|
7329
6509
|
});
|
|
7330
6510
|
|
|
7331
6511
|
// src/games/sdvx/config.ts
|
|
7332
|
-
var
|
|
7333
|
-
var sdvxConfig =
|
|
7334
|
-
sdvx_data_url:
|
|
7335
|
-
sdvx_search_url:
|
|
6512
|
+
var import_koishi23 = require("koishi");
|
|
6513
|
+
var sdvxConfig = import_koishi23.Schema.object({
|
|
6514
|
+
sdvx_data_url: import_koishi23.Schema.string().required(),
|
|
6515
|
+
sdvx_search_url: import_koishi23.Schema.string().required()
|
|
7336
6516
|
}).i18n({
|
|
7337
6517
|
"en-US": en_US_default4._config,
|
|
7338
6518
|
"zh-CN": zh_CN_default4._config
|
|
7339
6519
|
});
|
|
7340
6520
|
|
|
7341
6521
|
// src/global/config.ts
|
|
7342
|
-
var
|
|
7343
|
-
var globalConfig =
|
|
7344
|
-
official_support_url:
|
|
7345
|
-
maoServerUrl:
|
|
7346
|
-
maoApiKey:
|
|
6522
|
+
var import_koishi24 = require("koishi");
|
|
6523
|
+
var globalConfig = import_koishi24.Schema.object({
|
|
6524
|
+
official_support_url: import_koishi24.Schema.string().default("https://noah.logthm.com"),
|
|
6525
|
+
maoServerUrl: import_koishi24.Schema.string().default("http://maomani.cn:577"),
|
|
6526
|
+
maoApiKey: import_koishi24.Schema.string().role("secret").default("")
|
|
7347
6527
|
});
|
|
7348
6528
|
|
|
7349
6529
|
// src/slash/config.ts
|
|
7350
|
-
var
|
|
6530
|
+
var import_koishi25 = require("koishi");
|
|
7351
6531
|
|
|
7352
6532
|
// src/slash/locales/en-US.yml
|
|
7353
6533
|
var en_US_default6 = { _config: { $desc: "Slash Module Settings", test_guilds: "**Guilds To Sync**", auto_sync_on_start: "**Auto Sync on Connect**" } };
|
|
@@ -7356,16 +6536,16 @@ var en_US_default6 = { _config: { $desc: "Slash Module Settings", test_guilds: "
|
|
|
7356
6536
|
var zh_CN_default6 = { _config: { $desc: "Slash 模块设置", test_guilds: "**默认同步 Guild 列表**", auto_sync_on_start: "**连接后自动同步**" } };
|
|
7357
6537
|
|
|
7358
6538
|
// src/slash/config.ts
|
|
7359
|
-
var slashConfig =
|
|
7360
|
-
test_guilds:
|
|
7361
|
-
auto_sync_on_start:
|
|
6539
|
+
var slashConfig = import_koishi25.Schema.object({
|
|
6540
|
+
test_guilds: import_koishi25.Schema.array(String).default([]),
|
|
6541
|
+
auto_sync_on_start: import_koishi25.Schema.boolean().default(true)
|
|
7362
6542
|
}).i18n({
|
|
7363
6543
|
"en-US": en_US_default6._config,
|
|
7364
6544
|
"zh-CN": zh_CN_default6._config
|
|
7365
6545
|
});
|
|
7366
6546
|
|
|
7367
6547
|
// src/config.ts
|
|
7368
|
-
var Config =
|
|
6548
|
+
var Config = import_koishi26.Schema.object({
|
|
7369
6549
|
global: globalConfig,
|
|
7370
6550
|
core: coreConfig,
|
|
7371
6551
|
sdvx: sdvxConfig,
|
|
@@ -7377,7 +6557,7 @@ var Config = import_koishi29.Schema.object({
|
|
|
7377
6557
|
|
|
7378
6558
|
// src/index.ts
|
|
7379
6559
|
var name14 = "noah";
|
|
7380
|
-
var inject4 = ["database", "skia"
|
|
6560
|
+
var inject4 = ["database", "skia"];
|
|
7381
6561
|
async function apply14(ctx, config) {
|
|
7382
6562
|
initConstants(ctx);
|
|
7383
6563
|
ctx.set("globalConfig", config.global);
|