koishi-plugin-noah 2.2.1 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.cjs
CHANGED
|
@@ -5028,7 +5028,7 @@ var SDVXService = class _SDVXService {
|
|
|
5028
5028
|
const refid = await this.getRefid(ctx, url, model, cardId);
|
|
5029
5029
|
const requestUrl = `?model=KFC:J:G:A:${model}&f=message.get`;
|
|
5030
5030
|
const xmlRequestBody = `<call model="KFC:J:G:A:${model}" srcid="00010203040506070809">
|
|
5031
|
-
<game method="
|
|
5031
|
+
<game method="sv7_load" ver="0">
|
|
5032
5032
|
<dataid __type="str">${refid}</dataid>
|
|
5033
5033
|
<cardid __type="str">${cardId}</cardid>
|
|
5034
5034
|
<refid __type="str">${refid}</refid>
|
|
@@ -5049,7 +5049,7 @@ var SDVXService = class _SDVXService {
|
|
|
5049
5049
|
const refid = await this.getRefid(ctx, url, model, cardId);
|
|
5050
5050
|
const requestUrl = `?model=KFC:J:G:A:${model}&f=message.get`;
|
|
5051
5051
|
const xmlRequestBody = `<call model="KFC:J:G:A:${model}" srcid="00010203040506070809">
|
|
5052
|
-
<game method="
|
|
5052
|
+
<game method="sv7_load_m" ver="0">
|
|
5053
5053
|
<dataid __type="str">${refid}</dataid>
|
|
5054
5054
|
<cardid __type="str">${cardId}</cardid>
|
|
5055
5055
|
<refid __type="str">${refid}</refid>
|
|
@@ -5226,17 +5226,73 @@ var SDVXService2 = class _SDVXService {
|
|
|
5226
5226
|
);
|
|
5227
5227
|
return resp?.code === 0 && resp?.data?.password === pin;
|
|
5228
5228
|
}
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5229
|
+
clearTypeToNum(clearType) {
|
|
5230
|
+
switch (clearType) {
|
|
5231
|
+
case "MC":
|
|
5232
|
+
return 6;
|
|
5233
|
+
case "PUC":
|
|
5234
|
+
case "S-PUC":
|
|
5235
|
+
return 5;
|
|
5236
|
+
case "UC":
|
|
5237
|
+
return 4;
|
|
5238
|
+
case "HC":
|
|
5239
|
+
return 3;
|
|
5240
|
+
case "NC":
|
|
5241
|
+
return 2;
|
|
5242
|
+
case "PLAYED":
|
|
5243
|
+
return 1;
|
|
5244
|
+
default:
|
|
5245
|
+
return 0;
|
|
5246
|
+
}
|
|
5247
|
+
}
|
|
5248
|
+
diffNameToMusicType(diffName) {
|
|
5249
|
+
switch (diffName.toUpperCase()) {
|
|
5250
|
+
case "NOV":
|
|
5251
|
+
return 0;
|
|
5252
|
+
case "ADV":
|
|
5253
|
+
return 1;
|
|
5254
|
+
case "EXH":
|
|
5255
|
+
return 2;
|
|
5256
|
+
case "INF":
|
|
5257
|
+
case "GRV":
|
|
5258
|
+
case "HVN":
|
|
5259
|
+
case "VVD":
|
|
5260
|
+
case "XCD":
|
|
5261
|
+
return 3;
|
|
5262
|
+
case "MXM":
|
|
5263
|
+
return 4;
|
|
5264
|
+
case "ULT":
|
|
5265
|
+
return 5;
|
|
5266
|
+
default:
|
|
5267
|
+
return 0;
|
|
5268
|
+
}
|
|
5269
|
+
}
|
|
5270
|
+
async uploadScore(ctx, url, cardId, scores) {
|
|
5271
|
+
const apiKey = ctx.globalConfig.maoApiKey;
|
|
5272
|
+
if (!apiKey) {
|
|
5273
|
+
this.logger.warn("maoApiKey not configured");
|
|
5274
|
+
return false;
|
|
5275
|
+
}
|
|
5276
|
+
const payload = scores.filter((s) => {
|
|
5277
|
+
const musicId = Number(s.music.music_id);
|
|
5278
|
+
return musicId > 0 && s.music.music_diff_name;
|
|
5279
|
+
}).map((s) => ({
|
|
5280
|
+
music_id: Number(s.music.music_id),
|
|
5281
|
+
music_type: this.diffNameToMusicType(s.music.music_diff_name),
|
|
5282
|
+
score: s.music.score,
|
|
5283
|
+
exscore: s.music.exscore,
|
|
5284
|
+
clear_type: this.clearTypeToNum(s.music.clear_type)
|
|
5285
|
+
}));
|
|
5286
|
+
if (payload.length === 0) return false;
|
|
5232
5287
|
const resp = await ctx.http.post(
|
|
5233
|
-
|
|
5234
|
-
|
|
5288
|
+
"/bot/v2/sdvx/upload",
|
|
5289
|
+
{ card: cardId, scores: payload },
|
|
5235
5290
|
{
|
|
5236
|
-
baseURL
|
|
5291
|
+
baseURL: ctx.globalConfig.maoServerUrl,
|
|
5292
|
+
headers: { "X-API-Key": apiKey }
|
|
5237
5293
|
}
|
|
5238
5294
|
);
|
|
5239
|
-
return resp ===
|
|
5295
|
+
return resp?.code === 0;
|
|
5240
5296
|
}
|
|
5241
5297
|
async getAllScore(ctx, url, cardId, config) {
|
|
5242
5298
|
try {
|
|
@@ -6125,10 +6181,9 @@ function sync(ctx, config, logger5) {
|
|
|
6125
6181
|
if (!scoreList || scoreList.length === 0) {
|
|
6126
6182
|
return session.text(".no-scores");
|
|
6127
6183
|
}
|
|
6128
|
-
const syncPayload = buildSyncPayload(scoreList);
|
|
6129
6184
|
await session.send(
|
|
6130
6185
|
session.text(".confirm-sync", {
|
|
6131
|
-
score_count:
|
|
6186
|
+
score_count: scoreList.length
|
|
6132
6187
|
})
|
|
6133
6188
|
);
|
|
6134
6189
|
const confirm = await session.prompt();
|
|
@@ -6139,7 +6194,7 @@ function sync(ctx, config, logger5) {
|
|
|
6139
6194
|
ctx,
|
|
6140
6195
|
maoServer.baseUrl,
|
|
6141
6196
|
targetCard.code,
|
|
6142
|
-
|
|
6197
|
+
scoreList
|
|
6143
6198
|
);
|
|
6144
6199
|
if (!ok) {
|
|
6145
6200
|
logger5.warn("Mao SDVX uploadScore returned falsy result");
|
|
@@ -6154,61 +6209,11 @@ function sync(ctx, config, logger5) {
|
|
|
6154
6209
|
source_server_type: sourceServer.type,
|
|
6155
6210
|
source_card_name: sourceCard.name,
|
|
6156
6211
|
target_card_name: targetCard.name,
|
|
6157
|
-
score_count:
|
|
6212
|
+
score_count: scoreList.length
|
|
6158
6213
|
});
|
|
6159
6214
|
});
|
|
6160
6215
|
}
|
|
6161
6216
|
__name(sync, "sync");
|
|
6162
|
-
function clearTypeToMark(clearType) {
|
|
6163
|
-
switch (clearType) {
|
|
6164
|
-
case "S-PUC":
|
|
6165
|
-
return "spuc";
|
|
6166
|
-
case "PUC":
|
|
6167
|
-
return "puc";
|
|
6168
|
-
case "UC":
|
|
6169
|
-
return "uc";
|
|
6170
|
-
case "MC":
|
|
6171
|
-
return "mc";
|
|
6172
|
-
case "HC":
|
|
6173
|
-
return "hc";
|
|
6174
|
-
case "NC":
|
|
6175
|
-
return "nc";
|
|
6176
|
-
case "PLAYED":
|
|
6177
|
-
return "played";
|
|
6178
|
-
case "NO PLAY":
|
|
6179
|
-
return "noplay";
|
|
6180
|
-
default:
|
|
6181
|
-
return "noplay";
|
|
6182
|
-
}
|
|
6183
|
-
}
|
|
6184
|
-
__name(clearTypeToMark, "clearTypeToMark");
|
|
6185
|
-
function buildSyncPayload(scoreList) {
|
|
6186
|
-
const payloadMap = /* @__PURE__ */ new Map();
|
|
6187
|
-
for (const score of scoreList) {
|
|
6188
|
-
const musicIdRaw = String(score.music.music_id);
|
|
6189
|
-
if (!/^\d+$/.test(musicIdRaw)) continue;
|
|
6190
|
-
const musicId = musicIdRaw;
|
|
6191
|
-
let diffName = score.music.music_diff_name;
|
|
6192
|
-
if (!diffName) continue;
|
|
6193
|
-
const upperDiff = diffName.toUpperCase();
|
|
6194
|
-
if (["GRV", "HVN", "VVD", "XCD"].includes(upperDiff)) {
|
|
6195
|
-
diffName = "INF";
|
|
6196
|
-
} else {
|
|
6197
|
-
diffName = upperDiff;
|
|
6198
|
-
}
|
|
6199
|
-
if (!payloadMap.has(musicId)) {
|
|
6200
|
-
payloadMap.set(musicId, { music_id: musicId, difficulties: {} });
|
|
6201
|
-
}
|
|
6202
|
-
const entry = payloadMap.get(musicId);
|
|
6203
|
-
entry.difficulties[diffName] = {
|
|
6204
|
-
score: score.music.score,
|
|
6205
|
-
mark: clearTypeToMark(score.music.clear_type),
|
|
6206
|
-
grade: score.music.score_grade
|
|
6207
|
-
};
|
|
6208
|
-
}
|
|
6209
|
-
return Array.from(payloadMap.values());
|
|
6210
|
-
}
|
|
6211
|
-
__name(buildSyncPayload, "buildSyncPayload");
|
|
6212
6217
|
|
|
6213
6218
|
// src/games/sdvx/commands/vf.ts
|
|
6214
6219
|
var fs4 = __toESM(require("fs"), 1);
|
|
@@ -30,14 +30,9 @@ export declare class SDVXService implements ISDVXService {
|
|
|
30
30
|
* @returns 验证是否通过
|
|
31
31
|
*/
|
|
32
32
|
verifyPin(ctx: Context, url: string, cardId: string, pin: string): Promise<boolean>;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
score: number;
|
|
37
|
-
mark: string;
|
|
38
|
-
grade: string;
|
|
39
|
-
}>;
|
|
40
|
-
}[]): Promise<boolean>;
|
|
33
|
+
private clearTypeToNum;
|
|
34
|
+
private diffNameToMusicType;
|
|
35
|
+
uploadScore(ctx: Context, url: string, cardId: string, scores: SDVXScore[]): Promise<boolean>;
|
|
41
36
|
getAllScore(ctx: Context, url: string, cardId: string, config: SDVXConfig): Promise<SDVXScore[]>;
|
|
42
37
|
getScore(ctx: Context, url: string, cardId: string, musicId: number, config: SDVXConfig): Promise<SDVXScore>;
|
|
43
38
|
getRecentScores(ctx: Context, url: string, cardId: string, config: SDVXConfig, count?: number): Promise<SDVXScore[]>;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -79,14 +79,7 @@ export interface SDVXService extends GameService {
|
|
|
79
79
|
* @param scorePayload - 待上传的分数数据
|
|
80
80
|
* @returns 上传是否成功
|
|
81
81
|
*/
|
|
82
|
-
uploadScore?(ctx: Context, url: string, cardId: string,
|
|
83
|
-
music_id: string;
|
|
84
|
-
difficulties: Record<string, {
|
|
85
|
-
score: number;
|
|
86
|
-
mark: string;
|
|
87
|
-
grade: string;
|
|
88
|
-
}>;
|
|
89
|
-
}[]): Promise<boolean>;
|
|
82
|
+
uploadScore?(ctx: Context, url: string, cardId: string, scores: SDVXScore[]): Promise<boolean>;
|
|
90
83
|
}
|
|
91
84
|
/**
|
|
92
85
|
* 服务器接口
|