koishi-plugin-noah 1.2.4 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ import { GeneralConfig } from '../../types/config';
2
+ /**
3
+ * 通用工具配置模式定义
4
+ * @property barcode_api_url - 条形码 API 地址
5
+ */
6
+ export declare const generalConfig: GeneralConfig;
File without changes
@@ -0,0 +1,3 @@
1
+ import { Context } from 'koishi';
2
+ import type { GeneralConfig } from '../../../types/config';
3
+ export declare function quote(ctx: Context, config: GeneralConfig): void;
@@ -0,0 +1,5 @@
1
+ import { Context, Logger } from 'koishi';
2
+ import type { AppConfig } from '../../types/config';
3
+ export declare const name = "Noah-General";
4
+ export declare const logger: Logger;
5
+ export declare function apply(ctx: Context, config: AppConfig): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { Context } from 'koishi';
2
+ export declare function readCode128(ctx: Context, barcodeApiUrl: string, imageUrl: string): Promise<any>;
@@ -0,0 +1,7 @@
1
+ import { h } from 'koishi';
2
+ /**
3
+ * 从文本元素中解析选项参数
4
+ * @param textElements - 文本元素数组
5
+ * @returns 解析出的选项字符串
6
+ */
7
+ export declare function parseOptionsFromText(textElements: h[]): string;
package/lib/index.cjs CHANGED
@@ -6,8 +6,8 @@ var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
8
  var __export = (target, all) => {
9
- for (var name14 in all)
10
- __defProp(target, name14, { get: all[name14], enumerable: true });
9
+ for (var name15 in all)
10
+ __defProp(target, name15, { get: all[name15], enumerable: true });
11
11
  };
12
12
  var __copyProps = (to, from, except, desc) => {
13
13
  if (from && typeof from === "object" || typeof from === "function") {
@@ -31,9 +31,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
33
  Config: () => Config,
34
- apply: () => apply13,
34
+ apply: () => apply14,
35
35
  inject: () => inject3,
36
- name: () => name13
36
+ name: () => name14
37
37
  });
38
38
  module.exports = __toCommonJS(src_exports);
39
39
 
@@ -406,8 +406,8 @@ var CardService = class {
406
406
  * @param name - 卡片名称
407
407
  * @returns 卡片信息,不存在则返回null
408
408
  */
409
- async getCardByName(name14) {
410
- const rows = await this.ctx.database.get(this.tableName, { name: name14 });
409
+ async getCardByName(name15) {
410
+ const rows = await this.ctx.database.get(this.tableName, { name: name15 });
411
411
  if (!rows[0]) return null;
412
412
  return {
413
413
  ...rows[0],
@@ -422,10 +422,10 @@ var CardService = class {
422
422
  * @param defaultServerId - 默认服务器ID(若没有默认服务器则为0)
423
423
  * @returns 创建成功后包含自动填充ID等字段的完整对象
424
424
  */
425
- async createCard(uid, code, name14, defaultServerId = 0) {
425
+ async createCard(uid, code, name15, defaultServerId = 0) {
426
426
  const data = {
427
427
  code,
428
- name: name14,
428
+ name: name15,
429
429
  defaultServerId
430
430
  };
431
431
  const res = await this.ctx.database.create(this.tableName, data);
@@ -808,8 +808,8 @@ var ServerService = class {
808
808
  * @param name - 服务器名称
809
809
  * @returns 服务器信息,不存在则返回null
810
810
  */
811
- async getServerByName(name14) {
812
- const rows = await this.ctx.database.get(this.tableName, { name: name14 });
811
+ async getServerByName(name15) {
812
+ const rows = await this.ctx.database.get(this.tableName, { name: name15 });
813
813
  return rows[0] ?? null;
814
814
  }
815
815
  /**
@@ -2035,20 +2035,20 @@ var SDVXDrawer = class extends BaseDrawer {
2035
2035
  ctx.save();
2036
2036
  ctx.translate(556, 17);
2037
2037
  ctx.beginPath();
2038
- const r = 16, w = 100, h6 = 200, x0 = 0, y0 = 0;
2038
+ const r = 16, w = 100, h8 = 200, x0 = 0, y0 = 0;
2039
2039
  ctx.moveTo(x0 + r, y0);
2040
2040
  ctx.lineTo(x0 + w - r, y0);
2041
2041
  ctx.arcTo(x0 + w, y0, x0 + w, y0 + r, r);
2042
- ctx.lineTo(x0 + w, y0 + h6 - r);
2043
- ctx.arcTo(x0 + w, y0 + h6, x0 + w - r, y0 + h6, r);
2044
- ctx.lineTo(x0 + r, y0 + h6);
2045
- ctx.arcTo(x0, y0 + h6, x0, y0 + h6 - r, r);
2042
+ ctx.lineTo(x0 + w, y0 + h8 - r);
2043
+ ctx.arcTo(x0 + w, y0 + h8, x0 + w - r, y0 + h8, r);
2044
+ ctx.lineTo(x0 + r, y0 + h8);
2045
+ ctx.arcTo(x0, y0 + h8, x0, y0 + h8 - r, r);
2046
2046
  ctx.lineTo(x0, y0 + r);
2047
2047
  ctx.arcTo(x0, y0, x0 + r, y0, r);
2048
2048
  ctx.closePath();
2049
2049
  const circleRadius = 14;
2050
2050
  const circleX = x0 + w;
2051
- const circleY = y0 + h6 / 2;
2051
+ const circleY = y0 + h8 / 2;
2052
2052
  ctx.moveTo(circleX + circleRadius, circleY);
2053
2053
  ctx.arc(circleX, circleY, circleRadius, 0, Math.PI * 2, true);
2054
2054
  ctx.clip();
@@ -2145,7 +2145,7 @@ var SDVXDrawer = class extends BaseDrawer {
2145
2145
  ctx.textAlign = "center";
2146
2146
  ctx.font = '600 14px "Noto Sans JP"';
2147
2147
  ctx.fillText(exscoreStr, 339, 195);
2148
- const maxStr = options.score.difficulty_data.max_exscore - options.score.music.exscore === 0 ? "-" : (options.score.difficulty_data.max_exscore - options.score.music.exscore).toString();
2148
+ const maxStr = options.score.music.exscore === 0 ? "-" : (options.score.difficulty_data.max_exscore - options.score.music.exscore).toString();
2149
2149
  ctx.fillStyle = "#0230A5";
2150
2150
  ctx.textBaseline = "alphabetic";
2151
2151
  ctx.textAlign = "center";
@@ -2175,7 +2175,7 @@ var SDVXDrawer = class extends BaseDrawer {
2175
2175
  ctx.rotate(-Math.PI / 2);
2176
2176
  ctx.fillText(difficultyStr, 0, 0);
2177
2177
  ctx.restore();
2178
- const barcodeStr = options.score.music.music_id.toString() + difficultyStr;
2178
+ const barcodeStr = "s" + options.score.music.music_id.toString().padStart(4, "0") + difficultyStr;
2179
2179
  const barcodePng = await new Promise((resolve3, reject) => {
2180
2180
  import_bwip_js.default.toBuffer(
2181
2181
  {
@@ -2896,56 +2896,195 @@ function parsePlatform(target) {
2896
2896
  }
2897
2897
  __name(parsePlatform, "parsePlatform");
2898
2898
 
2899
+ // src/games/general/index.ts
2900
+ var general_exports = {};
2901
+ __export(general_exports, {
2902
+ apply: () => apply8,
2903
+ logger: () => logger3,
2904
+ name: () => name8
2905
+ });
2906
+ var import_koishi8 = require("koishi");
2907
+
2908
+ // src/games/general/events/quote.ts
2909
+ var import_koishi7 = require("koishi");
2910
+
2911
+ // src/games/general/utils/codeReader.ts
2912
+ async function readCode128(ctx, barcodeApiUrl, imageUrl) {
2913
+ const response = await ctx.http.post(
2914
+ "/decode-barcode",
2915
+ {
2916
+ image_url: imageUrl
2917
+ },
2918
+ {
2919
+ baseURL: barcodeApiUrl
2920
+ }
2921
+ );
2922
+ console.log(imageUrl, response);
2923
+ if (response.count === 1) {
2924
+ return response.barcodes[0].data;
2925
+ } else {
2926
+ return null;
2927
+ }
2928
+ }
2929
+ __name(readCode128, "readCode128");
2930
+
2931
+ // src/games/general/utils/textParser.ts
2932
+ function parseOptionsFromText(textElements) {
2933
+ const allText = textElements.map((el) => el.attrs?.content || "").join(" ");
2934
+ const optionRegex = /(-{1,2}[a-zA-Z][a-zA-Z0-9-]*(?:\s+[^\s-][^\s]*)?)/g;
2935
+ const options = [];
2936
+ let match;
2937
+ while ((match = optionRegex.exec(allText)) !== null) {
2938
+ options.push(match[1].trim());
2939
+ }
2940
+ return options.join(" ");
2941
+ }
2942
+ __name(parseOptionsFromText, "parseOptionsFromText");
2943
+
2944
+ // src/games/general/events/quote.ts
2945
+ function quote(ctx, config) {
2946
+ ctx.on("message", async (session) => {
2947
+ if (session.quote && session.quote.user.id === session.selfId) {
2948
+ const images = await import_koishi7.h.select(session.quote.elements, "img");
2949
+ const textElements = await import_koishi7.h.select(session.elements, "text");
2950
+ const options = parseOptionsFromText(textElements);
2951
+ if (images.length === 1) {
2952
+ const imageUrl = images[0].attrs.src;
2953
+ const code = await readCode128(ctx, config.barcode_api_url, imageUrl);
2954
+ if (code) {
2955
+ const module2 = code[0];
2956
+ let music_id;
2957
+ let music_diff;
2958
+ if (module2 === "s") {
2959
+ ;
2960
+ [music_id, music_diff] = [code.slice(1, 5), code.slice(5)];
2961
+ } else {
2962
+ return;
2963
+ }
2964
+ const command = `${module2}.chart ${options} -b ${music_id}.${music_diff}`;
2965
+ await session.execute(command);
2966
+ }
2967
+ }
2968
+ }
2969
+ });
2970
+ }
2971
+ __name(quote, "quote");
2972
+
2973
+ // src/games/general/index.ts
2974
+ var name8 = "Noah-General";
2975
+ var logger3 = new import_koishi8.Logger("Noah-General");
2976
+ async function apply8(ctx, config) {
2977
+ quote(ctx, config.general);
2978
+ }
2979
+ __name(apply8, "apply");
2980
+
2899
2981
  // src/games/sdvx/index.ts
2900
2982
  var sdvx_exports = {};
2901
2983
  __export(sdvx_exports, {
2902
- apply: () => apply12,
2984
+ apply: () => apply13,
2903
2985
  inject: () => inject2,
2904
- logger: () => logger3,
2905
- name: () => name12
2986
+ logger: () => logger4,
2987
+ name: () => name13
2906
2988
  });
2907
- var import_koishi11 = require("koishi");
2989
+ var import_koishi14 = require("koishi");
2908
2990
 
2909
2991
  // src/games/sdvx/command.ts
2910
2992
  var command_exports2 = {};
2911
2993
  __export(command_exports2, {
2912
- apply: () => apply9,
2913
- name: () => name9
2994
+ apply: () => apply10,
2995
+ name: () => name10
2914
2996
  });
2915
2997
 
2916
- // src/games/sdvx/commands/recent.ts
2998
+ // src/games/sdvx/commands/chart.ts
2917
2999
  var import_koishi9 = require("koishi");
2918
3000
 
2919
- // src/servers/index.ts
2920
- var servers_exports = {};
2921
- __export(servers_exports, {
2922
- ServerManager: () => ServerManager,
2923
- apply: () => apply8,
2924
- name: () => name8
2925
- });
2926
-
2927
- // src/servers/Asphyxia/index.ts
2928
- var import_koishi7 = require("koishi");
2929
-
2930
- // src/servers/Asphyxia/services/iidx-service.ts
2931
- var IIDXService = class _IIDXService {
2932
- static {
2933
- __name(this, "IIDXService");
2934
- }
2935
- static instance;
2936
- logger;
2937
- constructor(logger4) {
2938
- this.logger = logger4;
3001
+ // src/servers/utils/difficulty.ts
3002
+ function getDiffName(diffStr, infVer) {
3003
+ switch (diffStr) {
3004
+ case "novice":
3005
+ return "NOV";
3006
+ case "advanced":
3007
+ return "ADV";
3008
+ case "exhaust":
3009
+ return "EXH";
3010
+ case "infinite":
3011
+ {
3012
+ const infVerStr = String(infVer);
3013
+ switch (infVerStr) {
3014
+ case "2":
3015
+ return "INF";
3016
+ case "3":
3017
+ return "GRV";
3018
+ case "4":
3019
+ return "HVN";
3020
+ case "5":
3021
+ return "VVD";
3022
+ case "6":
3023
+ return "XCD";
3024
+ }
3025
+ }
3026
+ break;
3027
+ case "maximum":
3028
+ return "MXM";
2939
3029
  }
2940
- static getInstance(logger4) {
2941
- if (!_IIDXService.instance) {
2942
- _IIDXService.instance = new _IIDXService(logger4);
2943
- }
2944
- return _IIDXService.instance;
3030
+ }
3031
+ __name(getDiffName, "getDiffName");
3032
+ function getDiffFullName(diffStr, infVer) {
3033
+ switch (diffStr) {
3034
+ case "novice":
3035
+ return "NOVICE";
3036
+ case "advanced":
3037
+ return "ADVANCED";
3038
+ case "exhaust":
3039
+ return "EXHAUST";
3040
+ case "infinite":
3041
+ {
3042
+ const infVerStr = String(infVer);
3043
+ switch (infVerStr) {
3044
+ case "2":
3045
+ return "INFINITE";
3046
+ case "3":
3047
+ return "GRAVITY";
3048
+ case "4":
3049
+ return "HEAVENLY";
3050
+ case "5":
3051
+ return "VIVID";
3052
+ case "6":
3053
+ return "EXCEED";
3054
+ }
3055
+ }
3056
+ break;
3057
+ case "maximum":
3058
+ return "MAXIMUM";
2945
3059
  }
2946
- async fetchData(url) {
3060
+ }
3061
+ __name(getDiffFullName, "getDiffFullName");
3062
+ function getDiffStringFromAbbr(diffAbbr) {
3063
+ const upperAbbr = diffAbbr.toUpperCase();
3064
+ switch (upperAbbr) {
3065
+ case "NOV":
3066
+ return { diffStr: "novice", infVer: null };
3067
+ case "ADV":
3068
+ return { diffStr: "advanced", infVer: null };
3069
+ case "EXH":
3070
+ return { diffStr: "exhaust", infVer: null };
3071
+ case "INF":
3072
+ return { diffStr: "infinite", infVer: 2 };
3073
+ case "GRV":
3074
+ return { diffStr: "infinite", infVer: 3 };
3075
+ case "HVN":
3076
+ return { diffStr: "infinite", infVer: 4 };
3077
+ case "VVD":
3078
+ return { diffStr: "infinite", infVer: 5 };
3079
+ case "XCD":
3080
+ return { diffStr: "infinite", infVer: 6 };
3081
+ case "MXM":
3082
+ return { diffStr: "maximum", infVer: null };
3083
+ default:
3084
+ return null;
2947
3085
  }
2948
- };
3086
+ }
3087
+ __name(getDiffStringFromAbbr, "getDiffStringFromAbbr");
2949
3088
 
2950
3089
  // src/games/sdvx/services/music-service.ts
2951
3090
  var MusicService = class _MusicService {
@@ -2989,6 +3128,68 @@ var MusicService = class _MusicService {
2989
3128
  }
2990
3129
  };
2991
3130
 
3131
+ // src/games/sdvx/commands/chart.ts
3132
+ function chart(ctx, config) {
3133
+ ctx.command("sdvx.chart [query:text]").alias("sdvx.c").option("lossless", "-l").option("barcode", "-b <code:text>").option("mirror", "-m").action(async ({ session, options }, query) => {
3134
+ const musicService = MusicService.getInstance(config);
3135
+ if (options.barcode) {
3136
+ const [mid, diff] = options.barcode.split(".");
3137
+ const diffStr = getDiffStringFromAbbr(diff).diffStr;
3138
+ const [music] = await musicService.getMusic(ctx, [parseInt(mid)]);
3139
+ if (music) {
3140
+ const chart2 = music.difficulty.find((d) => d.difstr === diffStr);
3141
+ if (chart2) {
3142
+ const url = options.mirror ? `${config.sdvx_data_url}${chart2.mirror_chart_url}`.replace(
3143
+ ".webp",
3144
+ ".png"
3145
+ ) : `${config.sdvx_data_url}${chart2.chart_url}`.replace(".webp", ".png");
3146
+ return import_koishi9.h.image(url);
3147
+ }
3148
+ }
3149
+ }
3150
+ if (!query) {
3151
+ await session.send(session.text(".prompt"));
3152
+ query = await session.prompt();
3153
+ if (!query) return session.text("commands.timeout");
3154
+ }
3155
+ });
3156
+ }
3157
+ __name(chart, "chart");
3158
+
3159
+ // src/games/sdvx/commands/recent.ts
3160
+ var import_koishi12 = require("koishi");
3161
+
3162
+ // src/servers/index.ts
3163
+ var servers_exports = {};
3164
+ __export(servers_exports, {
3165
+ ServerManager: () => ServerManager,
3166
+ apply: () => apply9,
3167
+ name: () => name9
3168
+ });
3169
+
3170
+ // src/servers/Asphyxia/index.ts
3171
+ var import_koishi10 = require("koishi");
3172
+
3173
+ // src/servers/Asphyxia/services/iidx-service.ts
3174
+ var IIDXService = class _IIDXService {
3175
+ static {
3176
+ __name(this, "IIDXService");
3177
+ }
3178
+ static instance;
3179
+ logger;
3180
+ constructor(logger5) {
3181
+ this.logger = logger5;
3182
+ }
3183
+ static getInstance(logger5) {
3184
+ if (!_IIDXService.instance) {
3185
+ _IIDXService.instance = new _IIDXService(logger5);
3186
+ }
3187
+ return _IIDXService.instance;
3188
+ }
3189
+ async fetchData(url) {
3190
+ }
3191
+ };
3192
+
2992
3193
  // src/games/sdvx/utils/vf.ts
2993
3194
  var GRADE_FACTORS = {
2994
3195
  S: 1.05,
@@ -3023,68 +3224,6 @@ function calculateVolforce(raw_score) {
3023
3224
  }
3024
3225
  __name(calculateVolforce, "calculateVolforce");
3025
3226
 
3026
- // src/servers/utils/difficulty.ts
3027
- function getDiffName(diffStr, infVer) {
3028
- switch (diffStr) {
3029
- case "novice":
3030
- return "NOV";
3031
- case "advanced":
3032
- return "ADV";
3033
- case "exhaust":
3034
- return "EXH";
3035
- case "infinite":
3036
- {
3037
- const infVerStr = String(infVer);
3038
- switch (infVerStr) {
3039
- case "2":
3040
- return "INF";
3041
- case "3":
3042
- return "GRV";
3043
- case "4":
3044
- return "HVN";
3045
- case "5":
3046
- return "VVD";
3047
- case "6":
3048
- return "XCD";
3049
- }
3050
- }
3051
- break;
3052
- case "maximum":
3053
- return "MXM";
3054
- }
3055
- }
3056
- __name(getDiffName, "getDiffName");
3057
- function getDiffFullName(diffStr, infVer) {
3058
- switch (diffStr) {
3059
- case "novice":
3060
- return "NOVICE";
3061
- case "advanced":
3062
- return "ADVANCED";
3063
- case "exhaust":
3064
- return "EXHAUST";
3065
- case "infinite":
3066
- {
3067
- const infVerStr = String(infVer);
3068
- switch (infVerStr) {
3069
- case "2":
3070
- return "INFINITE";
3071
- case "3":
3072
- return "GRAVITY";
3073
- case "4":
3074
- return "HEAVENLY";
3075
- case "5":
3076
- return "VIVID";
3077
- case "6":
3078
- return "EXCEED";
3079
- }
3080
- }
3081
- break;
3082
- case "maximum":
3083
- return "MAXIMUM";
3084
- }
3085
- }
3086
- __name(getDiffFullName, "getDiffFullName");
3087
-
3088
3227
  // src/servers/utils/grade.ts
3089
3228
  function getSDVXGrade(score) {
3090
3229
  if (score >= 99e5) return "S";
@@ -3125,12 +3264,12 @@ var SDVXService = class _SDVXService {
3125
3264
  }
3126
3265
  static instance;
3127
3266
  logger;
3128
- constructor(logger4) {
3129
- this.logger = logger4;
3267
+ constructor(logger5) {
3268
+ this.logger = logger5;
3130
3269
  }
3131
- static getInstance(logger4) {
3270
+ static getInstance(logger5) {
3132
3271
  if (!_SDVXService.instance) {
3133
- _SDVXService.instance = new _SDVXService(logger4);
3272
+ _SDVXService.instance = new _SDVXService(logger5);
3134
3273
  }
3135
3274
  return _SDVXService.instance;
3136
3275
  }
@@ -3167,9 +3306,9 @@ var SDVXService = class _SDVXService {
3167
3306
  const response = await ctx.http.post(requestUrl, xmlRequestBody, { baseURL: url });
3168
3307
  const decodedResponse = typeof response === "string" ? response : new TextDecoder("utf-8").decode(response);
3169
3308
  const jsonResponse = await xmlToJson(decodedResponse);
3170
- const name14 = jsonResponse.response.game?.[0]?.name?.[0]._;
3171
- if (!name14) throw new Error("User name not found");
3172
- return name14;
3309
+ const name15 = jsonResponse.response.game?.[0]?.name?.[0]._;
3310
+ if (!name15) throw new Error("User name not found");
3311
+ return name15;
3173
3312
  }
3174
3313
  /**
3175
3314
  * 获取所有分数
@@ -3268,7 +3407,7 @@ var Asphyxia = class {
3268
3407
  name = "asphyxia";
3269
3408
  supportedGames = ["sdvx", "iidx"];
3270
3409
  gameServices = {};
3271
- logger = new import_koishi7.Logger("Noah-Asphyxia");
3410
+ logger = new import_koishi10.Logger("Noah-Asphyxia");
3272
3411
  /**
3273
3412
  * 初始化各个游戏服务实例
3274
3413
  */
@@ -3279,7 +3418,7 @@ var Asphyxia = class {
3279
3418
  };
3280
3419
 
3281
3420
  // src/servers/Mao/index.ts
3282
- var import_koishi8 = require("koishi");
3421
+ var import_koishi11 = require("koishi");
3283
3422
 
3284
3423
  // src/servers/Mao/services/sdvx-service.ts
3285
3424
  var SDVXService2 = class _SDVXService {
@@ -3288,12 +3427,12 @@ var SDVXService2 = class _SDVXService {
3288
3427
  }
3289
3428
  static instance;
3290
3429
  logger;
3291
- constructor(logger4) {
3292
- this.logger = logger4;
3430
+ constructor(logger5) {
3431
+ this.logger = logger5;
3293
3432
  }
3294
- static getInstance(logger4) {
3433
+ static getInstance(logger5) {
3295
3434
  if (!_SDVXService.instance) {
3296
- _SDVXService.instance = new _SDVXService(logger4);
3435
+ _SDVXService.instance = new _SDVXService(logger5);
3297
3436
  }
3298
3437
  return _SDVXService.instance;
3299
3438
  }
@@ -3558,7 +3697,7 @@ var Mao = class {
3558
3697
  name = "mao";
3559
3698
  supportedGames = ["sdvx"];
3560
3699
  gameServices = {};
3561
- logger = new import_koishi8.Logger("Noah-Mao");
3700
+ logger = new import_koishi11.Logger("Noah-Mao");
3562
3701
  /**
3563
3702
  * 初始化SDVX游戏服务实例
3564
3703
  */
@@ -3599,7 +3738,7 @@ var ServerFactory = class {
3599
3738
  };
3600
3739
 
3601
3740
  // src/servers/index.ts
3602
- var name8 = "Noah-Server";
3741
+ var name9 = "Noah-Server";
3603
3742
  var ServerManager = class _ServerManager {
3604
3743
  static {
3605
3744
  __name(this, "ServerManager");
@@ -3638,9 +3777,9 @@ var ServerManager = class _ServerManager {
3638
3777
  return server2.gameServices[gameType];
3639
3778
  }
3640
3779
  };
3641
- function apply8(ctx, config) {
3780
+ function apply9(ctx, config) {
3642
3781
  }
3643
- __name(apply8, "apply");
3782
+ __name(apply9, "apply");
3644
3783
 
3645
3784
  // src/games/sdvx/commands/recent.ts
3646
3785
  function recent(ctx, config) {
@@ -3670,7 +3809,7 @@ function recent(ctx, config) {
3670
3809
  cardListMsg += `<p>${i + 1}. ${userCards[i].name}</p>`;
3671
3810
  }
3672
3811
  }
3673
- const msg = import_koishi9.h.unescape(session.text(".menu-select", { card_list: cardListMsg })).replace("< 默认卡片", "&lt; 默认卡片");
3812
+ const msg = import_koishi12.h.unescape(session.text(".menu-select", { card_list: cardListMsg })).replace("< 默认卡片", "&lt; 默认卡片");
3674
3813
  await session.send(msg);
3675
3814
  const select = await session.prompt();
3676
3815
  if (!select) return session.text("commands.timeout");
@@ -3727,9 +3866,9 @@ function recent(ctx, config) {
3727
3866
  }
3728
3867
  );
3729
3868
  if (options.lossless) {
3730
- return import_koishi9.h.image(imageBuffer, "image/png");
3869
+ return import_koishi12.h.image(imageBuffer, "image/png");
3731
3870
  }
3732
- return import_koishi9.h.image(imageBuffer, "image/jpg");
3871
+ return import_koishi12.h.image(imageBuffer, "image/jpg");
3733
3872
  } catch (error) {
3734
3873
  ctx.logger("SDVX-RECENT").warn(error);
3735
3874
  return session.text(".error");
@@ -3739,7 +3878,7 @@ function recent(ctx, config) {
3739
3878
  __name(recent, "recent");
3740
3879
 
3741
3880
  // src/games/sdvx/commands/vf.ts
3742
- var import_koishi10 = require("koishi");
3881
+ var import_koishi13 = require("koishi");
3743
3882
 
3744
3883
  // src/games/sdvx/services/score-service.ts
3745
3884
  var ScoreService = class _ScoreService {
@@ -3935,7 +4074,7 @@ function vf(ctx, config) {
3935
4074
  cardListMsg += `<p>${i + 1}. ${userCards[i].name}</p>`;
3936
4075
  }
3937
4076
  }
3938
- const msg = import_koishi10.h.unescape(session.text(".menu-select", { card_list: cardListMsg })).replace("< 默认卡片", "&lt; 默认卡片");
4077
+ const msg = import_koishi13.h.unescape(session.text(".menu-select", { card_list: cardListMsg })).replace("< 默认卡片", "&lt; 默认卡片");
3939
4078
  await session.send(msg);
3940
4079
  const select = await session.prompt();
3941
4080
  if (!select) return session.text("commands.timeout");
@@ -3998,9 +4137,9 @@ function vf(ctx, config) {
3998
4137
  }
3999
4138
  );
4000
4139
  if (options.lossless) {
4001
- return import_koishi10.h.file(imageBuffer, "image/png");
4140
+ return import_koishi13.h.file(imageBuffer, "image/png");
4002
4141
  }
4003
- return import_koishi10.h.image(imageBuffer, "image/jpg");
4142
+ return import_koishi13.h.image(imageBuffer, "image/jpg");
4004
4143
  } catch (error) {
4005
4144
  ctx.logger("SDVX-VF").warn(error);
4006
4145
  return session.text(".error");
@@ -4010,47 +4149,48 @@ function vf(ctx, config) {
4010
4149
  __name(vf, "vf");
4011
4150
 
4012
4151
  // src/games/sdvx/command.ts
4013
- var name9 = "command";
4014
- function apply9(ctx, config) {
4152
+ var name10 = "command";
4153
+ function apply10(ctx, config) {
4015
4154
  ctx.command("sdvx").alias("s");
4016
4155
  vf(ctx, config);
4017
4156
  recent(ctx, config);
4157
+ chart(ctx, config);
4018
4158
  }
4019
- __name(apply9, "apply");
4159
+ __name(apply10, "apply");
4020
4160
 
4021
4161
  // src/games/sdvx/database.ts
4022
4162
  var database_exports2 = {};
4023
4163
  __export(database_exports2, {
4024
- apply: () => apply10,
4025
- name: () => name10
4164
+ apply: () => apply11,
4165
+ name: () => name11
4026
4166
  });
4027
- var name10 = "database";
4028
- function apply10(ctx) {
4167
+ var name11 = "database";
4168
+ function apply11(ctx) {
4029
4169
  }
4030
- __name(apply10, "apply");
4170
+ __name(apply11, "apply");
4031
4171
 
4032
4172
  // src/games/sdvx/event.ts
4033
4173
  var event_exports2 = {};
4034
4174
  __export(event_exports2, {
4035
- apply: () => apply11,
4036
- name: () => name11
4175
+ apply: () => apply12,
4176
+ name: () => name12
4037
4177
  });
4038
- var name11 = "event";
4039
- function apply11(ctx) {
4178
+ var name12 = "event";
4179
+ function apply12(ctx) {
4040
4180
  }
4041
- __name(apply11, "apply");
4181
+ __name(apply12, "apply");
4042
4182
 
4043
4183
  // src/games/sdvx/locales/en-US.yml
4044
- var en_US_default4 = { _config: { $desc: "SDVX Module Settings", default_model: "<p>Default model value (e.g. `2024110700`)</p>", sdvx_data_url: "<p>The URL of the SDVX data 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, please wait patiently~</p>" } }, sdvx: { recent: { description: "Show recent scores", 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, please wait patiently~</p>" } } } } };
4184
+ var en_US_default4 = { _config: { $desc: "SDVX Module Settings", default_model: "<p>Default model value (e.g. `2024110700`)</p>", sdvx_data_url: "<p>The URL of the SDVX data 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, please wait patiently~</p>" } }, sdvx: { recent: { description: "Show recent scores", 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, please wait patiently~</p>" } }, chart: { description: "Show SDVX chart", messages: { prompt: "<p>Which song's chart would you like to view?</p>" } } } } };
4045
4185
 
4046
4186
  // src/games/sdvx/locales/zh-CN.yml
4047
- var zh_CN_default4 = { _config: { $desc: "SDVX 模块设置", default_model: "<p>默认的 model 值(如 `2024110700`)</p>", sdvx_data_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: { "card-not-found": "<p>你还没绑卡,去绑个卡再来吧~</p>", "server-not-found": "<p>没有可用的服务器哦,自己添加一个吧~</p>", "no-scores-found": "<p>没有找到你的分数数据哦~</p>", error: "<p>Noah 遇到了错误(っ °Д °;)っ</p>", drawing: "<p>Noah 正在画啦,请耐心等待~</p>" } } } } };
4187
+ var zh_CN_default4 = { _config: { $desc: "SDVX 模块设置", default_model: "<p>默认的 model 值(如 `2024110700`)</p>", sdvx_data_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: { "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>" } } } } };
4048
4188
 
4049
4189
  // src/games/sdvx/index.ts
4050
- var name12 = "Noah-SDVX";
4190
+ var name13 = "Noah-SDVX";
4051
4191
  var inject2 = ["database"];
4052
- var logger3 = new import_koishi11.Logger("Noah-SDVX");
4053
- async function apply12(ctx, config) {
4192
+ var logger4 = new import_koishi14.Logger("Noah-SDVX");
4193
+ async function apply13(ctx, config) {
4054
4194
  ;
4055
4195
  [
4056
4196
  ["en-US", en_US_default4],
@@ -4060,50 +4200,50 @@ async function apply12(ctx, config) {
4060
4200
  ctx.plugin(command_exports2, config.sdvx);
4061
4201
  ctx.plugin(event_exports2, config.sdvx);
4062
4202
  }
4063
- __name(apply12, "apply");
4203
+ __name(apply13, "apply");
4064
4204
 
4065
4205
  // src/config.ts
4066
- var import_koishi16 = require("koishi");
4206
+ var import_koishi20 = require("koishi");
4067
4207
 
4068
4208
  // src/asset/config.ts
4069
- var import_koishi12 = require("koishi");
4070
- var assetConfig = import_koishi12.Schema.object({
4071
- data_path: import_koishi12.Schema.string().default("noah_assets"),
4072
- auto_update: import_koishi12.Schema.boolean().default(true),
4073
- update_url: import_koishi12.Schema.string().default("https://github.com/logthm/noah/releases/latest/download/"),
4074
- update_interval: import_koishi12.Schema.number().default(24 * 60 * 60 * 1e3),
4209
+ var import_koishi15 = require("koishi");
4210
+ var assetConfig = import_koishi15.Schema.object({
4211
+ data_path: import_koishi15.Schema.string().default("noah_assets"),
4212
+ auto_update: import_koishi15.Schema.boolean().default(true),
4213
+ update_url: import_koishi15.Schema.string().default("https://github.com/logthm/noah/releases/latest/download/"),
4214
+ update_interval: import_koishi15.Schema.number().default(24 * 60 * 60 * 1e3),
4075
4215
  // 24 hours in milliseconds
4076
- github_token: import_koishi12.Schema.string().description("GitHub token for accessing private repositories").role("secret")
4216
+ github_token: import_koishi15.Schema.string().description("GitHub token for accessing private repositories").role("secret")
4077
4217
  }).i18n({
4078
4218
  "en-US": en_US_default._config,
4079
4219
  "zh-CN": zh_CN_default._config
4080
4220
  });
4081
4221
 
4082
4222
  // src/core/config.ts
4083
- var import_koishi13 = require("koishi");
4084
- var coreConfig = import_koishi13.Schema.object({
4085
- adminUsers: import_koishi13.Schema.array(String).role("table"),
4086
- guildNameCards: import_koishi13.Schema.array(String).role("table").default(["Noah | /help 获取食用指南"])
4223
+ var import_koishi16 = require("koishi");
4224
+ var coreConfig = import_koishi16.Schema.object({
4225
+ adminUsers: import_koishi16.Schema.array(String).role("table"),
4226
+ guildNameCards: import_koishi16.Schema.array(String).role("table").default(["Noah | /help 获取食用指南"])
4087
4227
  }).i18n({
4088
4228
  "en-US": en_US_default2._config,
4089
4229
  "zh-CN": zh_CN_default2._config
4090
4230
  });
4091
4231
 
4092
4232
  // src/fun/poke/config.ts
4093
- var import_koishi14 = require("koishi");
4094
- var pokeConfig = import_koishi14.Schema.object({
4095
- interval: import_koishi14.Schema.number().default(1e3).step(100),
4096
- warning: import_koishi14.Schema.boolean().default(false),
4097
- prompt: import_koishi14.Schema.array(
4098
- import_koishi14.Schema.object({
4099
- content: import_koishi14.Schema.string().required(),
4100
- weight: import_koishi14.Schema.number().min(0).max(100).default(50)
4233
+ var import_koishi17 = require("koishi");
4234
+ var pokeConfig = import_koishi17.Schema.object({
4235
+ interval: import_koishi17.Schema.number().default(1e3).step(100),
4236
+ warning: import_koishi17.Schema.boolean().default(false),
4237
+ prompt: import_koishi17.Schema.array(
4238
+ import_koishi17.Schema.object({
4239
+ content: import_koishi17.Schema.string().required(),
4240
+ weight: import_koishi17.Schema.number().min(0).max(100).default(50)
4101
4241
  })
4102
4242
  ).role("table"),
4103
- messages: import_koishi14.Schema.array(
4104
- import_koishi14.Schema.object({
4105
- content: import_koishi14.Schema.string().required(),
4106
- weight: import_koishi14.Schema.number().min(0).max(100).default(50)
4243
+ messages: import_koishi17.Schema.array(
4244
+ import_koishi17.Schema.object({
4245
+ content: import_koishi17.Schema.string().required(),
4246
+ weight: import_koishi17.Schema.number().min(0).max(100).default(50)
4107
4247
  })
4108
4248
  ).role("table")
4109
4249
  }).i18n({
@@ -4111,37 +4251,56 @@ var pokeConfig = import_koishi14.Schema.object({
4111
4251
  "zh-CN": zh_CN_default3._config
4112
4252
  });
4113
4253
 
4254
+ // src/games/general/config.ts
4255
+ var import_koishi18 = require("koishi");
4256
+
4257
+ // src/games/general/locales/en-US.yml
4258
+ var en_US_default5 = { _config: { $desc: "General Module Settings", barcode_api_url: "<p>The URL of the barcode API</p>" } };
4259
+
4260
+ // src/games/general/locales/zh-CN.yml
4261
+ var zh_CN_default5 = { _config: { $desc: "通用工具模块设置", barcode_api_url: "<p>条形码 API 地址</p>" } };
4262
+
4263
+ // src/games/general/config.ts
4264
+ var generalConfig = import_koishi18.Schema.object({
4265
+ barcode_api_url: import_koishi18.Schema.string().required()
4266
+ }).i18n({
4267
+ "en-US": en_US_default5._config,
4268
+ "zh-CN": zh_CN_default5._config
4269
+ });
4270
+
4114
4271
  // src/games/sdvx/config.ts
4115
- var import_koishi15 = require("koishi");
4116
- var sdvxConfig = import_koishi15.Schema.object({
4117
- default_model: import_koishi15.Schema.string().default("2024110700"),
4118
- sdvx_data_url: import_koishi15.Schema.string().required()
4272
+ var import_koishi19 = require("koishi");
4273
+ var sdvxConfig = import_koishi19.Schema.object({
4274
+ default_model: import_koishi19.Schema.string().default("2024110700"),
4275
+ sdvx_data_url: import_koishi19.Schema.string().required()
4119
4276
  }).i18n({
4120
4277
  "en-US": en_US_default4._config,
4121
4278
  "zh-CN": zh_CN_default4._config
4122
4279
  });
4123
4280
 
4124
4281
  // src/config.ts
4125
- var Config = import_koishi16.Schema.object({
4282
+ var Config = import_koishi20.Schema.object({
4126
4283
  core: coreConfig,
4127
4284
  sdvx: sdvxConfig,
4128
4285
  poke: pokeConfig,
4129
- asset: assetConfig
4286
+ asset: assetConfig,
4287
+ general: generalConfig
4130
4288
  });
4131
4289
 
4132
4290
  // src/index.ts
4133
- var name13 = "noah";
4291
+ var name14 = "noah";
4134
4292
  var inject3 = ["database", "skia"];
4135
- function apply13(ctx, config) {
4293
+ function apply14(ctx, config) {
4136
4294
  initConstants(ctx);
4137
4295
  ctx.plugin(core_exports, config);
4296
+ ctx.plugin(general_exports, config);
4138
4297
  ctx.plugin(sdvx_exports, config);
4139
4298
  ctx.plugin(servers_exports, config);
4140
4299
  ctx.plugin(drawer_exports, config);
4141
4300
  ctx.plugin(poke_exports, config);
4142
4301
  ctx.plugin(asset_exports, config);
4143
4302
  }
4144
- __name(apply13, "apply");
4303
+ __name(apply14, "apply");
4145
4304
  // Annotate the CommonJS export names for ESM import in node:
4146
4305
  0 && (module.exports = {
4147
4306
  Config,
@@ -12,3 +12,12 @@ export declare function getDiffName(diffStr: string, infVer: string | number): s
12
12
  * @returns 完整难度名称 (例如: "NOVICE", "ADVANCED", "INFINITE" 等)
13
13
  */
14
14
  export declare function getDiffFullName(diffStr: string, infVer: string | number): string;
15
+ /**
16
+ * 根据难度缩写名称获取难度字符串和 infVer
17
+ * @param diffAbbr - 难度缩写名称 (例如: "NOV", "ADV", "EXH", "INF", "GRV", "HVN", "VVD", "XCD", "MXM")
18
+ * @returns 包含难度字符串和 infVer 的对象,如果是非 infinite 难度则 infVer 为 null
19
+ */
20
+ export declare function getDiffStringFromAbbr(diffAbbr: string): {
21
+ diffStr: string;
22
+ infVer: number | null;
23
+ } | null;
@@ -68,4 +68,14 @@ export interface AppConfig {
68
68
  poke: PokeConfig;
69
69
  /** 资源文件配置 */
70
70
  asset: AssetConfig;
71
+ /** 通用工具配置 */
72
+ general: GeneralConfig;
73
+ }
74
+ /**
75
+ * 通用工具配置接口
76
+ * 包含通用工具相关的配置项
77
+ */
78
+ export interface GeneralConfig extends BaseConfig {
79
+ /** 条形码 API 地址 */
80
+ barcode_api_url: string;
71
81
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-noah",
3
- "version": "1.2.4",
3
+ "version": "1.3.0",
4
4
  "contributors": [
5
5
  "Logthm <logthm@outlook.com>"
6
6
  ],
@@ -24,6 +24,7 @@
24
24
  "dependencies": {
25
25
  "adm-zip": "^0.5.16",
26
26
  "bwip-js": "^4.6.0",
27
+ "javascript-barcode-reader": "^0.6.9",
27
28
  "koishi-plugin-adapter-onebot": "^6.8.0",
28
29
  "sharp": "^0.33.5",
29
30
  "xml2js": "^0.6.2"