koishi-plugin-noah 1.4.2 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +127 -76
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -3332,26 +3332,13 @@ async function readCode128(ctx, barcodeApiUrl, imageUrl) {
|
|
|
3332
3332
|
}
|
|
3333
3333
|
__name(readCode128, "readCode128");
|
|
3334
3334
|
|
|
3335
|
-
// src/games/general/utils/textParser.ts
|
|
3336
|
-
function parseOptionsFromText(textElements) {
|
|
3337
|
-
const allText = textElements.map((el) => el.attrs?.content || "").join(" ");
|
|
3338
|
-
const optionRegex = /(-{1,2}[a-zA-Z][a-zA-Z0-9-]*(?:\s+[^\s-][^\s]*)?)/g;
|
|
3339
|
-
const options = [];
|
|
3340
|
-
let match;
|
|
3341
|
-
while ((match = optionRegex.exec(allText)) !== null) {
|
|
3342
|
-
options.push(match[1].trim());
|
|
3343
|
-
}
|
|
3344
|
-
return options.join(" ");
|
|
3345
|
-
}
|
|
3346
|
-
__name(parseOptionsFromText, "parseOptionsFromText");
|
|
3347
|
-
|
|
3348
3335
|
// src/games/general/events/quote.ts
|
|
3349
3336
|
function quote(ctx, config) {
|
|
3350
3337
|
ctx.on("message", async (session) => {
|
|
3351
3338
|
if (session.quote && session.quote.user.id === session.selfId) {
|
|
3352
3339
|
const images = await import_koishi7.h.select(session.quote.elements, "img");
|
|
3353
3340
|
const textElements = await import_koishi7.h.select(session.elements, "text");
|
|
3354
|
-
const
|
|
3341
|
+
const allText = textElements.map((el) => el.attrs?.content || "").join(" ");
|
|
3355
3342
|
if (images.length === 1) {
|
|
3356
3343
|
const imageUrl = images[0].attrs.src;
|
|
3357
3344
|
const code = await readCode128(ctx, config.barcode_api_url, imageUrl);
|
|
@@ -3365,7 +3352,7 @@ function quote(ctx, config) {
|
|
|
3365
3352
|
} else {
|
|
3366
3353
|
return;
|
|
3367
3354
|
}
|
|
3368
|
-
const command = `${module2}.chart ${
|
|
3355
|
+
const command = `${module2}.chart ${music_id}.${music_diff} ${allText}`;
|
|
3369
3356
|
await session.execute(command);
|
|
3370
3357
|
}
|
|
3371
3358
|
}
|
|
@@ -4089,72 +4076,94 @@ function getDiffStringFromAbbr(diffAbbr) {
|
|
|
4089
4076
|
}
|
|
4090
4077
|
__name(getDiffStringFromAbbr, "getDiffStringFromAbbr");
|
|
4091
4078
|
|
|
4092
|
-
// src/games/sdvx/services/music-service.ts
|
|
4093
|
-
var MusicService = class _MusicService {
|
|
4094
|
-
static {
|
|
4095
|
-
__name(this, "MusicService");
|
|
4096
|
-
}
|
|
4097
|
-
static instance;
|
|
4098
|
-
sdvx_data_url;
|
|
4099
|
-
constructor(config) {
|
|
4100
|
-
this.sdvx_data_url = config.sdvx_data_url;
|
|
4101
|
-
}
|
|
4102
|
-
/**
|
|
4103
|
-
* 获取 MusicService 实例
|
|
4104
|
-
* @param config - SDVX 配置对象
|
|
4105
|
-
* @returns MusicService 实例
|
|
4106
|
-
*/
|
|
4107
|
-
static getInstance(config) {
|
|
4108
|
-
if (!_MusicService.instance) {
|
|
4109
|
-
_MusicService.instance = new _MusicService(config);
|
|
4110
|
-
}
|
|
4111
|
-
return _MusicService.instance;
|
|
4112
|
-
}
|
|
4113
|
-
/**
|
|
4114
|
-
* 获取音乐信息
|
|
4115
|
-
* @param ctx - Koishi 上下文对象
|
|
4116
|
-
* @param musicIds - 音乐 ID 数组
|
|
4117
|
-
* @returns 音乐信息数组
|
|
4118
|
-
*/
|
|
4119
|
-
async getMusic(ctx, musicIds) {
|
|
4120
|
-
const response = await ctx.http.post(
|
|
4121
|
-
`/music`,
|
|
4122
|
-
{
|
|
4123
|
-
ids: musicIds
|
|
4124
|
-
},
|
|
4125
|
-
{
|
|
4126
|
-
baseURL: this.sdvx_data_url
|
|
4127
|
-
}
|
|
4128
|
-
);
|
|
4129
|
-
const musicInfo = await response;
|
|
4130
|
-
return musicInfo;
|
|
4131
|
-
}
|
|
4132
|
-
};
|
|
4133
|
-
|
|
4134
4079
|
// src/games/sdvx/commands/chart.ts
|
|
4080
|
+
function mapArrangementToken(tok) {
|
|
4081
|
+
const t = tok.toLowerCase();
|
|
4082
|
+
if (t === "ran" || t === "random") return "random";
|
|
4083
|
+
if (t === "m" || t === "mirror" || t === "mir") return "mirror";
|
|
4084
|
+
if (t === "sran" || t === "srandom") return "s-random";
|
|
4085
|
+
if (t === "fran" || t === "wtf") return "f-random";
|
|
4086
|
+
return null;
|
|
4087
|
+
}
|
|
4088
|
+
__name(mapArrangementToken, "mapArrangementToken");
|
|
4089
|
+
function mapLeftColorToken(tok) {
|
|
4090
|
+
const m = /^l(blue|red|yellow|green)$/i.exec(tok);
|
|
4091
|
+
return m ? m[1].toUpperCase() : null;
|
|
4092
|
+
}
|
|
4093
|
+
__name(mapLeftColorToken, "mapLeftColorToken");
|
|
4094
|
+
function mapRightColorToken(tok) {
|
|
4095
|
+
const m = /^r(blue|red|yellow|green)$/i.exec(tok);
|
|
4096
|
+
return m ? m[1].toUpperCase() : null;
|
|
4097
|
+
}
|
|
4098
|
+
__name(mapRightColorToken, "mapRightColorToken");
|
|
4099
|
+
function isBarcode(s) {
|
|
4100
|
+
return /^\d+\.[A-Za-z]+$/.test(s);
|
|
4101
|
+
}
|
|
4102
|
+
__name(isBarcode, "isBarcode");
|
|
4135
4103
|
function chart(ctx, config, logger5) {
|
|
4136
|
-
ctx.command("sdvx.chart [query:text]").alias("sdvx.c").option("lossless", "-l").
|
|
4137
|
-
const musicService = MusicService.getInstance(config);
|
|
4138
|
-
if (options.barcode) {
|
|
4139
|
-
const [mid, diff] = options.barcode.split(".");
|
|
4140
|
-
const diffStr = getDiffStringFromAbbr(diff).diffStr;
|
|
4141
|
-
const [music] = await musicService.getMusic(ctx, [parseInt(mid)]);
|
|
4142
|
-
if (music) {
|
|
4143
|
-
const chart2 = music.difficulty.find((d) => d.difstr === diffStr);
|
|
4144
|
-
if (chart2) {
|
|
4145
|
-
const url = options.mirror ? `${config.sdvx_data_url}${chart2.mirror_chart_url}`.replace(
|
|
4146
|
-
".webp",
|
|
4147
|
-
".png"
|
|
4148
|
-
) : `${config.sdvx_data_url}${chart2.chart_url}`.replace(".webp", ".png");
|
|
4149
|
-
return import_koishi10.h.image(url);
|
|
4150
|
-
}
|
|
4151
|
-
}
|
|
4152
|
-
}
|
|
4104
|
+
ctx.command("sdvx.chart [query:text]").alias("sdvx.c").option("lossless", "-l").action(async ({ session, options }, query) => {
|
|
4153
4105
|
if (!query) {
|
|
4154
4106
|
await session.send(session.text(".prompt"));
|
|
4155
4107
|
query = await session.prompt();
|
|
4156
4108
|
if (!query) return session.text("commands.timeout");
|
|
4157
4109
|
}
|
|
4110
|
+
try {
|
|
4111
|
+
let arrangement_mode = "normal";
|
|
4112
|
+
let laser_l_color = "GREEN";
|
|
4113
|
+
let laser_r_color = "RED";
|
|
4114
|
+
const tokens = query.split(/\s+/).filter(Boolean);
|
|
4115
|
+
const remaining = [];
|
|
4116
|
+
for (const tok of tokens) {
|
|
4117
|
+
const arr = mapArrangementToken(tok);
|
|
4118
|
+
if (arr) {
|
|
4119
|
+
arrangement_mode = arr;
|
|
4120
|
+
continue;
|
|
4121
|
+
}
|
|
4122
|
+
const lc = mapLeftColorToken(tok);
|
|
4123
|
+
if (lc) {
|
|
4124
|
+
laser_l_color = lc;
|
|
4125
|
+
continue;
|
|
4126
|
+
}
|
|
4127
|
+
const rc = mapRightColorToken(tok);
|
|
4128
|
+
if (rc) {
|
|
4129
|
+
laser_r_color = rc;
|
|
4130
|
+
continue;
|
|
4131
|
+
}
|
|
4132
|
+
remaining.push(tok);
|
|
4133
|
+
}
|
|
4134
|
+
const rest = remaining.join(" ").trim();
|
|
4135
|
+
if (!rest) {
|
|
4136
|
+
return;
|
|
4137
|
+
}
|
|
4138
|
+
if (isBarcode(rest)) {
|
|
4139
|
+
const [midRaw, diffAbbrRaw] = rest.split(".");
|
|
4140
|
+
const music_id = Number(midRaw);
|
|
4141
|
+
const { diffStr } = getDiffStringFromAbbr(diffAbbrRaw);
|
|
4142
|
+
const difstr = diffStr;
|
|
4143
|
+
const output_format = options?.lossless ? "PNG" : "JPEG";
|
|
4144
|
+
const payload = {
|
|
4145
|
+
music_id,
|
|
4146
|
+
difstr,
|
|
4147
|
+
arrangement_mode,
|
|
4148
|
+
rng_seed: null,
|
|
4149
|
+
output_format,
|
|
4150
|
+
laser_l_color,
|
|
4151
|
+
laser_r_color,
|
|
4152
|
+
px_per_second: 600,
|
|
4153
|
+
column_height: 2800
|
|
4154
|
+
};
|
|
4155
|
+
session.send(session.text(".drawing"));
|
|
4156
|
+
const res = await ctx.http.post(`${config.sdvx_data_url}/chart`, payload, {
|
|
4157
|
+
headers: { "Content-Type": "application/json" }
|
|
4158
|
+
});
|
|
4159
|
+
return import_koishi10.h.image(res, "image/png");
|
|
4160
|
+
} else {
|
|
4161
|
+
return session.text(".error");
|
|
4162
|
+
}
|
|
4163
|
+
} catch (err) {
|
|
4164
|
+
logger5.warn(err);
|
|
4165
|
+
return session.text(".error");
|
|
4166
|
+
}
|
|
4158
4167
|
});
|
|
4159
4168
|
}
|
|
4160
4169
|
__name(chart, "chart");
|
|
@@ -4193,6 +4202,48 @@ var IIDXService = class _IIDXService {
|
|
|
4193
4202
|
}
|
|
4194
4203
|
};
|
|
4195
4204
|
|
|
4205
|
+
// src/games/sdvx/services/music-service.ts
|
|
4206
|
+
var MusicService = class _MusicService {
|
|
4207
|
+
static {
|
|
4208
|
+
__name(this, "MusicService");
|
|
4209
|
+
}
|
|
4210
|
+
static instance;
|
|
4211
|
+
sdvx_data_url;
|
|
4212
|
+
constructor(config) {
|
|
4213
|
+
this.sdvx_data_url = config.sdvx_data_url;
|
|
4214
|
+
}
|
|
4215
|
+
/**
|
|
4216
|
+
* 获取 MusicService 实例
|
|
4217
|
+
* @param config - SDVX 配置对象
|
|
4218
|
+
* @returns MusicService 实例
|
|
4219
|
+
*/
|
|
4220
|
+
static getInstance(config) {
|
|
4221
|
+
if (!_MusicService.instance) {
|
|
4222
|
+
_MusicService.instance = new _MusicService(config);
|
|
4223
|
+
}
|
|
4224
|
+
return _MusicService.instance;
|
|
4225
|
+
}
|
|
4226
|
+
/**
|
|
4227
|
+
* 获取音乐信息
|
|
4228
|
+
* @param ctx - Koishi 上下文对象
|
|
4229
|
+
* @param musicIds - 音乐 ID 数组
|
|
4230
|
+
* @returns 音乐信息数组
|
|
4231
|
+
*/
|
|
4232
|
+
async getMusic(ctx, musicIds) {
|
|
4233
|
+
const response = await ctx.http.post(
|
|
4234
|
+
`/music`,
|
|
4235
|
+
{
|
|
4236
|
+
ids: musicIds
|
|
4237
|
+
},
|
|
4238
|
+
{
|
|
4239
|
+
baseURL: this.sdvx_data_url
|
|
4240
|
+
}
|
|
4241
|
+
);
|
|
4242
|
+
const musicInfo = await response;
|
|
4243
|
+
return musicInfo;
|
|
4244
|
+
}
|
|
4245
|
+
};
|
|
4246
|
+
|
|
4196
4247
|
// src/servers/utils/grade.ts
|
|
4197
4248
|
function getSDVXGrade(score) {
|
|
4198
4249
|
if (score >= 99e5) return "S";
|
|
@@ -5146,10 +5197,10 @@ function apply12(ctx) {
|
|
|
5146
5197
|
__name(apply12, "apply");
|
|
5147
5198
|
|
|
5148
5199
|
// src/games/sdvx/locales/en-US.yml
|
|
5149
|
-
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>", "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: { "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>" } }, 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>" } } } } };
|
|
5200
|
+
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>", "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: { "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>" } }, 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>" } } } } };
|
|
5150
5201
|
|
|
5151
5202
|
// src/games/sdvx/locales/zh-CN.yml
|
|
5152
|
-
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>" } }, 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>" } } } } };
|
|
5203
|
+
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>", error: "<p>Noah 遇到了错误(っ °Д °;)っ</p>", drawing: "<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>" } } } } };
|
|
5153
5204
|
|
|
5154
5205
|
// src/games/sdvx/index.ts
|
|
5155
5206
|
var name13 = "Noah-SDVX";
|