koishi-plugin-noah 1.1.31 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +371 -50
- package/package.json +72 -71
package/lib/index.cjs
CHANGED
|
@@ -1211,11 +1211,11 @@ function maintain(ctx, config) {
|
|
|
1211
1211
|
let card2 = "";
|
|
1212
1212
|
let text = "";
|
|
1213
1213
|
if (options.stop) {
|
|
1214
|
-
session.send(".stop");
|
|
1214
|
+
session.send(session.text(".stop"));
|
|
1215
1215
|
card2 = config.guildNameCards[0];
|
|
1216
1216
|
text = ".success-stop";
|
|
1217
1217
|
} else {
|
|
1218
|
-
session.send(".start");
|
|
1218
|
+
session.send(session.text(".start"));
|
|
1219
1219
|
card2 = "Noah | 🚧维护中";
|
|
1220
1220
|
text = ".success-start";
|
|
1221
1221
|
}
|
|
@@ -1707,7 +1707,7 @@ function guildRequest(ctx, config) {
|
|
|
1707
1707
|
__name(guildRequest, "guildRequest");
|
|
1708
1708
|
function guildNameCard(ctx, config) {
|
|
1709
1709
|
let currentNameCardIndex = 0;
|
|
1710
|
-
const
|
|
1710
|
+
const timerDisposers = /* @__PURE__ */ new Map();
|
|
1711
1711
|
async function updateBotNameCards(bot) {
|
|
1712
1712
|
if (!config.guildNameCards || config.guildNameCards.length === 0) {
|
|
1713
1713
|
config.guildNameCards = [config.guildNameCards[0]];
|
|
@@ -1723,7 +1723,7 @@ function guildNameCard(ctx, config) {
|
|
|
1723
1723
|
ctx.logger("guild-namecard").info(
|
|
1724
1724
|
`更新 ${bot.selfId} 在 ${guild.name} 的群名片为 ${nameCard}`
|
|
1725
1725
|
);
|
|
1726
|
-
await
|
|
1726
|
+
await ctx.sleep(1e3);
|
|
1727
1727
|
} catch (error) {
|
|
1728
1728
|
ctx.logger("guild-namecard").warn(
|
|
1729
1729
|
`更新 ${bot.selfId} 在 ${guild.name} 的群名片失败: ${error}`
|
|
@@ -1734,12 +1734,12 @@ function guildNameCard(ctx, config) {
|
|
|
1734
1734
|
}
|
|
1735
1735
|
__name(updateBotNameCards, "updateBotNameCards");
|
|
1736
1736
|
async function setupTimersForBot(bot) {
|
|
1737
|
-
const
|
|
1738
|
-
if (
|
|
1739
|
-
|
|
1737
|
+
const disposer = timerDisposers.get(bot.selfId);
|
|
1738
|
+
if (disposer) {
|
|
1739
|
+
disposer();
|
|
1740
1740
|
}
|
|
1741
1741
|
await updateBotNameCards(bot);
|
|
1742
|
-
const
|
|
1742
|
+
const dispose = ctx.setInterval(
|
|
1743
1743
|
() => {
|
|
1744
1744
|
updateBotNameCards(bot).catch((err) => {
|
|
1745
1745
|
ctx.logger("guild-namecard").warn("定时器更新群名片出错", err);
|
|
@@ -1747,7 +1747,7 @@ function guildNameCard(ctx, config) {
|
|
|
1747
1747
|
},
|
|
1748
1748
|
3 * 60 * 60 * 1e3
|
|
1749
1749
|
);
|
|
1750
|
-
|
|
1750
|
+
timerDisposers.set(bot.selfId, dispose);
|
|
1751
1751
|
}
|
|
1752
1752
|
__name(setupTimersForBot, "setupTimersForBot");
|
|
1753
1753
|
ctx.on("ready", () => {
|
|
@@ -1765,10 +1765,10 @@ function guildNameCard(ctx, config) {
|
|
|
1765
1765
|
});
|
|
1766
1766
|
ctx.on("login-removed", (session) => {
|
|
1767
1767
|
const bot = session.bot;
|
|
1768
|
-
const
|
|
1769
|
-
if (
|
|
1770
|
-
|
|
1771
|
-
|
|
1768
|
+
const disposer = timerDisposers.get(bot.selfId);
|
|
1769
|
+
if (disposer) {
|
|
1770
|
+
disposer();
|
|
1771
|
+
timerDisposers.delete(bot.selfId);
|
|
1772
1772
|
}
|
|
1773
1773
|
});
|
|
1774
1774
|
}
|
|
@@ -1957,6 +1957,7 @@ var IIDXDrawer = class extends BaseDrawer {
|
|
|
1957
1957
|
|
|
1958
1958
|
// src/drawer/sdvx/index.ts
|
|
1959
1959
|
var fs2 = __toESM(require("fs"), 1);
|
|
1960
|
+
var import_bwip_js = __toESM(require("bwip-js"), 1);
|
|
1960
1961
|
var SDVXDrawer = class extends BaseDrawer {
|
|
1961
1962
|
constructor(ctx) {
|
|
1962
1963
|
super(ctx);
|
|
@@ -1977,13 +1978,233 @@ var SDVXDrawer = class extends BaseDrawer {
|
|
|
1977
1978
|
if (!compression) {
|
|
1978
1979
|
compression = { lossless: true };
|
|
1979
1980
|
}
|
|
1980
|
-
const
|
|
1981
|
+
const notoSansPath = getAssetPath(this.ctx, "fonts/NotoSans-VariableFont_wdth,wght.ttf");
|
|
1982
|
+
const notoSansJPPath = getAssetPath(this.ctx, "fonts/NotoSansJP-VariableFont_wght.ttf");
|
|
1983
|
+
if (fs2.existsSync(notoSansPath)) {
|
|
1984
|
+
FontLibrary.use("Noto Sans", notoSansPath);
|
|
1985
|
+
this.ctx.logger("SDVX-Drawer").debug("Loaded Noto Sans font successfully");
|
|
1986
|
+
} else {
|
|
1987
|
+
this.ctx.logger("SDVX-Drawer").warn(`Noto Sans font file not found at: ${notoSansPath}`);
|
|
1988
|
+
}
|
|
1989
|
+
if (fs2.existsSync(notoSansJPPath)) {
|
|
1990
|
+
FontLibrary.use("Noto Sans JP", notoSansJPPath);
|
|
1991
|
+
this.ctx.logger("SDVX-Drawer").debug("Loaded Noto Sans JP font successfully");
|
|
1992
|
+
} else {
|
|
1993
|
+
this.ctx.logger("SDVX-Drawer").warn(`Noto Sans JP font file not found at: ${notoSansJPPath}`);
|
|
1994
|
+
}
|
|
1995
|
+
const bgImage = await loadImage(getAssetPath(this.ctx, "sdvx/recent/main_bg.png"));
|
|
1996
|
+
const ticketBgImage = await loadImage(getAssetPath(this.ctx, "sdvx/recent/ticket_bg.png"));
|
|
1997
|
+
const gradeImages = {};
|
|
1998
|
+
const gradeList = ["C", "D", "S", "B", "AAA", "AAA+", "AA+", "A", "A+", "AA"];
|
|
1999
|
+
for (const grade of gradeList) {
|
|
2000
|
+
try {
|
|
2001
|
+
const gradePath = getAssetPath(this.ctx, `sdvx/recent/grade/Type=${grade}.png`);
|
|
2002
|
+
gradeImages[grade] = await loadImage(gradePath);
|
|
2003
|
+
} catch (error) {
|
|
2004
|
+
this.ctx.logger("SDVX-Drawer").warn(`Failed to load grade image for ${grade}: ${error.message}`);
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
const playTypeImages = {};
|
|
2008
|
+
const playTypeList = ["UC", "PLAYED", "SPUC", "PUC", "NOPLAY", "NC", "MC", "HC"];
|
|
2009
|
+
for (const type of playTypeList) {
|
|
2010
|
+
try {
|
|
2011
|
+
const typePath = getAssetPath(this.ctx, `sdvx/recent/play_type/Type=${type}.png`);
|
|
2012
|
+
playTypeImages[type] = await loadImage(typePath);
|
|
2013
|
+
} catch (error) {
|
|
2014
|
+
this.ctx.logger("SDVX-Drawer").warn(`Failed to load play_type image for ${type}: ${error.message}`);
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
let jacketImage;
|
|
2018
|
+
try {
|
|
2019
|
+
if (options.score.difficulty_data?.cover_url) {
|
|
2020
|
+
const coverUrl = `${options.config.sdvx_data_url}${options.score.difficulty_data.cover_url}`.replace(
|
|
2021
|
+
".webp",
|
|
2022
|
+
".png"
|
|
2023
|
+
);
|
|
2024
|
+
jacketImage = await loadImage(coverUrl);
|
|
2025
|
+
}
|
|
2026
|
+
} catch (error) {
|
|
2027
|
+
this.ctx.logger("SDVX-Drawer").warn(`Failed to load jacket image: ${error.message}`);
|
|
2028
|
+
}
|
|
1981
2029
|
const canvas = new Canvas(bgImage.width, bgImage.height);
|
|
1982
2030
|
const ctx = canvas.getContext("2d");
|
|
1983
2031
|
ctx.imageSmoothingEnabled = true;
|
|
1984
2032
|
ctx.imageSmoothingQuality = "high";
|
|
1985
2033
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
1986
2034
|
ctx.drawImage(bgImage, 0, 0);
|
|
2035
|
+
ctx.save();
|
|
2036
|
+
ctx.translate(556, 17);
|
|
2037
|
+
ctx.beginPath();
|
|
2038
|
+
const r = 16, w = 100, h6 = 200, x0 = 0, y0 = 0;
|
|
2039
|
+
ctx.moveTo(x0 + r, y0);
|
|
2040
|
+
ctx.lineTo(x0 + w - r, y0);
|
|
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);
|
|
2046
|
+
ctx.lineTo(x0, y0 + r);
|
|
2047
|
+
ctx.arcTo(x0, y0, x0 + r, y0, r);
|
|
2048
|
+
ctx.closePath();
|
|
2049
|
+
const circleRadius = 14;
|
|
2050
|
+
const circleX = x0 + w;
|
|
2051
|
+
const circleY = y0 + h6 / 2;
|
|
2052
|
+
ctx.moveTo(circleX + circleRadius, circleY);
|
|
2053
|
+
ctx.arc(circleX, circleY, circleRadius, 0, Math.PI * 2, true);
|
|
2054
|
+
ctx.clip();
|
|
2055
|
+
ctx.drawImage(jacketImage, -100, 0, 200, 200);
|
|
2056
|
+
ctx.restore();
|
|
2057
|
+
ctx.drawImage(ticketBgImage, 0, 0);
|
|
2058
|
+
let mainTitle = "";
|
|
2059
|
+
let subTitle = "";
|
|
2060
|
+
if (options.score.music_data) {
|
|
2061
|
+
if (options.score.music_data.main_title_name) {
|
|
2062
|
+
mainTitle = options.score.music_data.main_title_name;
|
|
2063
|
+
} else if (options.score.music_data.title_name) {
|
|
2064
|
+
mainTitle = options.score.music_data.title_name;
|
|
2065
|
+
}
|
|
2066
|
+
if (options.score.music_data.sub_title_name) {
|
|
2067
|
+
subTitle = options.score.music_data.sub_title_name;
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
ctx.font = 'bold 24px "Noto Sans JP"';
|
|
2071
|
+
ctx.textBaseline = "alphabetic";
|
|
2072
|
+
ctx.textAlign = "left";
|
|
2073
|
+
ctx.fillStyle = "#0230A5";
|
|
2074
|
+
const maxWidth = 360;
|
|
2075
|
+
let displayMainTitle = mainTitle;
|
|
2076
|
+
let displaySubTitle = subTitle;
|
|
2077
|
+
const gap = 8;
|
|
2078
|
+
let mainTitleWidth = ctx.measureText(displayMainTitle).width;
|
|
2079
|
+
let subTitleWidth = displaySubTitle ? ctx.measureText(displaySubTitle).width : 0;
|
|
2080
|
+
if (mainTitleWidth + (displaySubTitle ? gap + subTitleWidth : 0) > maxWidth) {
|
|
2081
|
+
if (displaySubTitle) {
|
|
2082
|
+
let fitLength = 0;
|
|
2083
|
+
for (let i = 1; i <= displaySubTitle.length; i++) {
|
|
2084
|
+
if (ctx.measureText(displaySubTitle.substring(0, i)).width + mainTitleWidth + gap > maxWidth) {
|
|
2085
|
+
fitLength = i - 1;
|
|
2086
|
+
break;
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
if (fitLength > 0) {
|
|
2090
|
+
displaySubTitle = displaySubTitle.substring(0, fitLength);
|
|
2091
|
+
} else {
|
|
2092
|
+
displaySubTitle = "";
|
|
2093
|
+
}
|
|
2094
|
+
subTitleWidth = ctx.measureText(displaySubTitle).width;
|
|
2095
|
+
}
|
|
2096
|
+
if (mainTitleWidth + (displaySubTitle ? gap + subTitleWidth : 0) > maxWidth) {
|
|
2097
|
+
let fitLength = 0;
|
|
2098
|
+
for (let i = 1; i <= displayMainTitle.length; i++) {
|
|
2099
|
+
if (ctx.measureText(displayMainTitle.substring(0, i)).width + (displaySubTitle ? gap + subTitleWidth : 0) > maxWidth) {
|
|
2100
|
+
fitLength = i - 1;
|
|
2101
|
+
break;
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
if (fitLength > 0) {
|
|
2105
|
+
displayMainTitle = displayMainTitle.substring(0, fitLength);
|
|
2106
|
+
} else {
|
|
2107
|
+
displayMainTitle = "";
|
|
2108
|
+
}
|
|
2109
|
+
mainTitleWidth = ctx.measureText(displayMainTitle).width;
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
ctx.fillStyle = "#0230A5";
|
|
2113
|
+
ctx.globalAlpha = 1;
|
|
2114
|
+
ctx.fillText(displayMainTitle, 147, 55);
|
|
2115
|
+
if (displaySubTitle) {
|
|
2116
|
+
ctx.fillStyle = "#0230A5";
|
|
2117
|
+
ctx.globalAlpha = 0.8;
|
|
2118
|
+
ctx.fillText(displaySubTitle, 147 + mainTitleWidth + gap, 55);
|
|
2119
|
+
ctx.globalAlpha = 1;
|
|
2120
|
+
}
|
|
2121
|
+
const scoreStr = options.score.music.score.toString();
|
|
2122
|
+
const mainPart = scoreStr.slice(0, scoreStr.length - 4);
|
|
2123
|
+
const lastPart = scoreStr.slice(-4);
|
|
2124
|
+
ctx.fillStyle = "#0230A5";
|
|
2125
|
+
ctx.textBaseline = "alphabetic";
|
|
2126
|
+
ctx.textAlign = "left";
|
|
2127
|
+
ctx.font = '600 48px "Noto Sans JP"';
|
|
2128
|
+
const x = 154;
|
|
2129
|
+
ctx.fillText(mainPart, x, 121);
|
|
2130
|
+
const mainPartWidth = ctx.measureText(mainPart).width;
|
|
2131
|
+
ctx.font = '600 32px "Noto Sans JP"';
|
|
2132
|
+
ctx.fillText(lastPart, x + mainPartWidth, 121);
|
|
2133
|
+
const totalScoreWidth = mainPartWidth + ctx.measureText(lastPart).width;
|
|
2134
|
+
ctx.fillStyle = "#0230A5";
|
|
2135
|
+
ctx.fillRect(x + totalScoreWidth + 8, 121 - 4, 16, 4);
|
|
2136
|
+
const volforceStr = options.score.extra.volforce.toFixed(2);
|
|
2137
|
+
ctx.fillStyle = "#0230A5";
|
|
2138
|
+
ctx.textBaseline = "alphabetic";
|
|
2139
|
+
ctx.textAlign = "right";
|
|
2140
|
+
ctx.font = '600 14px "Noto Sans JP"';
|
|
2141
|
+
ctx.fillText(volforceStr, 539, 118);
|
|
2142
|
+
const exscoreStr = options.score.music.exscore === 0 ? "-" : (options.score.music.exscore / options.score.difficulty_data.max_exscore * 100).toFixed(1) + "%";
|
|
2143
|
+
ctx.fillStyle = "#0230A5";
|
|
2144
|
+
ctx.textBaseline = "alphabetic";
|
|
2145
|
+
ctx.textAlign = "center";
|
|
2146
|
+
ctx.font = '600 14px "Noto Sans JP"';
|
|
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();
|
|
2149
|
+
ctx.fillStyle = "#0230A5";
|
|
2150
|
+
ctx.textBaseline = "alphabetic";
|
|
2151
|
+
ctx.textAlign = "center";
|
|
2152
|
+
ctx.font = '600 14px "Noto Sans JP"';
|
|
2153
|
+
ctx.fillText(maxStr, 409, 195);
|
|
2154
|
+
const gradeImage = gradeImages[options.score.music.score_grade];
|
|
2155
|
+
ctx.drawImage(gradeImage, 139, 151);
|
|
2156
|
+
const playTypeImage = playTypeImages[options.score.music.clear_type];
|
|
2157
|
+
ctx.drawImage(playTypeImage, 139, 178);
|
|
2158
|
+
const levelStr = options.score.music.music_diff.toString();
|
|
2159
|
+
ctx.fillStyle = "#0230A5";
|
|
2160
|
+
ctx.textBaseline = "alphabetic";
|
|
2161
|
+
ctx.textAlign = "left";
|
|
2162
|
+
ctx.font = 'bold 20px "Noto Sans JP"';
|
|
2163
|
+
ctx.save();
|
|
2164
|
+
ctx.translate(86, 201);
|
|
2165
|
+
ctx.rotate(-Math.PI / 2);
|
|
2166
|
+
ctx.fillText(levelStr, 0, 0);
|
|
2167
|
+
ctx.restore();
|
|
2168
|
+
const difficultyStr = options.score.music.music_diff_name;
|
|
2169
|
+
ctx.fillStyle = "#0230A5";
|
|
2170
|
+
ctx.textBaseline = "alphabetic";
|
|
2171
|
+
ctx.textAlign = "right";
|
|
2172
|
+
ctx.font = 'bold 16px "Noto Sans JP"';
|
|
2173
|
+
ctx.save();
|
|
2174
|
+
ctx.translate(86, 32);
|
|
2175
|
+
ctx.rotate(-Math.PI / 2);
|
|
2176
|
+
ctx.fillText(difficultyStr, 0, 0);
|
|
2177
|
+
ctx.restore();
|
|
2178
|
+
const barcodeStr = options.score.music.music_id.toString() + difficultyStr;
|
|
2179
|
+
const barcodePng = await new Promise((resolve3, reject) => {
|
|
2180
|
+
import_bwip_js.default.toBuffer(
|
|
2181
|
+
{
|
|
2182
|
+
bcid: "code128",
|
|
2183
|
+
text: barcodeStr,
|
|
2184
|
+
scale: 1,
|
|
2185
|
+
width: 168,
|
|
2186
|
+
height: 28,
|
|
2187
|
+
includetext: false,
|
|
2188
|
+
backgroundcolor: "F4F4F4",
|
|
2189
|
+
paddingwidth: 0,
|
|
2190
|
+
paddingheight: 0,
|
|
2191
|
+
barcolor: "0230A5"
|
|
2192
|
+
},
|
|
2193
|
+
(err, png) => {
|
|
2194
|
+
if (err) {
|
|
2195
|
+
reject(err);
|
|
2196
|
+
} else {
|
|
2197
|
+
resolve3(png);
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
);
|
|
2201
|
+
});
|
|
2202
|
+
const barcodeImage = await loadImage(barcodePng);
|
|
2203
|
+
ctx.save();
|
|
2204
|
+
ctx.translate(32, 200);
|
|
2205
|
+
ctx.rotate(-Math.PI / 2);
|
|
2206
|
+
ctx.drawImage(barcodeImage, 0, 0, 168, 28);
|
|
2207
|
+
ctx.restore();
|
|
1987
2208
|
return this.compressImage(canvas, compression);
|
|
1988
2209
|
}
|
|
1989
2210
|
/**
|
|
@@ -2683,7 +2904,7 @@ __export(sdvx_exports, {
|
|
|
2683
2904
|
logger: () => logger3,
|
|
2684
2905
|
name: () => name12
|
|
2685
2906
|
});
|
|
2686
|
-
var
|
|
2907
|
+
var import_koishi11 = require("koishi");
|
|
2687
2908
|
|
|
2688
2909
|
// src/games/sdvx/command.ts
|
|
2689
2910
|
var command_exports2 = {};
|
|
@@ -2692,7 +2913,7 @@ __export(command_exports2, {
|
|
|
2692
2913
|
name: () => name9
|
|
2693
2914
|
});
|
|
2694
2915
|
|
|
2695
|
-
// src/games/sdvx/commands/
|
|
2916
|
+
// src/games/sdvx/commands/recent.ts
|
|
2696
2917
|
var import_koishi9 = require("koishi");
|
|
2697
2918
|
|
|
2698
2919
|
// src/servers/index.ts
|
|
@@ -3421,6 +3642,105 @@ function apply8(ctx, config) {
|
|
|
3421
3642
|
}
|
|
3422
3643
|
__name(apply8, "apply");
|
|
3423
3644
|
|
|
3645
|
+
// src/games/sdvx/commands/recent.ts
|
|
3646
|
+
function recent(ctx, config) {
|
|
3647
|
+
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) => {
|
|
3648
|
+
const atGuild = session.guildId != null;
|
|
3649
|
+
if (!count) count = 1;
|
|
3650
|
+
const cardService = new CardService(ctx);
|
|
3651
|
+
const serverService = new ServerService(ctx);
|
|
3652
|
+
const userCards = await cardService.getCardsByUid(session.user.id);
|
|
3653
|
+
if (userCards.length === 0) return session.text(".card-not-found");
|
|
3654
|
+
const userRes = await serverService.getServersByUid(session.user.id);
|
|
3655
|
+
const channelRes = atGuild ? await serverService.getServersByCid(session.channel.id) : [];
|
|
3656
|
+
const serverRes = channelRes.concat(userRes);
|
|
3657
|
+
if (serverRes.length === 0) return session.text(".server-not-found");
|
|
3658
|
+
let cardCode = "";
|
|
3659
|
+
if (!options.card) {
|
|
3660
|
+
const defaultCard = await cardService.getDefaultCardByUid(session.user.id);
|
|
3661
|
+
if (!defaultCard) return session.text(".card-not-found");
|
|
3662
|
+
cardCode = defaultCard.code;
|
|
3663
|
+
} else {
|
|
3664
|
+
let cardListMsg = "";
|
|
3665
|
+
for (let i = 0; i < userCards.length; i++) {
|
|
3666
|
+
const defaultCard = await cardService.getDefaultCardByUid(session.user.id);
|
|
3667
|
+
if (defaultCard && userCards[i].id === defaultCard.id) {
|
|
3668
|
+
cardListMsg += `<p>${i + 1}. ${userCards[i].name} < 默认卡片</p>`;
|
|
3669
|
+
} else {
|
|
3670
|
+
cardListMsg += `<p>${i + 1}. ${userCards[i].name}</p>`;
|
|
3671
|
+
}
|
|
3672
|
+
}
|
|
3673
|
+
const msg = import_koishi9.h.unescape(session.text(".menu-select", { card_list: cardListMsg })).replace("< 默认卡片", "< 默认卡片");
|
|
3674
|
+
await session.send(msg);
|
|
3675
|
+
const select = await session.prompt();
|
|
3676
|
+
if (!select) return session.text("commands.timeout");
|
|
3677
|
+
if (select === "q") return session.text(".quit");
|
|
3678
|
+
const selectNum = parseInt(select, 10);
|
|
3679
|
+
if (isNaN(selectNum) || selectNum < 1 || selectNum > userCards.length) {
|
|
3680
|
+
return session.text(".invalid-select");
|
|
3681
|
+
}
|
|
3682
|
+
cardCode = userCards[selectNum - 1].code;
|
|
3683
|
+
}
|
|
3684
|
+
const card2 = await cardService.getCardByCode(cardCode);
|
|
3685
|
+
let server2;
|
|
3686
|
+
if (card2.defaultServerId != void 0 && card2.defaultServerId != 0)
|
|
3687
|
+
server2 = await serverService.getServerById(card2.defaultServerId);
|
|
3688
|
+
else {
|
|
3689
|
+
const channelDefaultServer = atGuild ? await serverService.getDefaultServerByCid(
|
|
3690
|
+
session.platform,
|
|
3691
|
+
session.channel.id
|
|
3692
|
+
) : null;
|
|
3693
|
+
if (channelDefaultServer) server2 = channelDefaultServer;
|
|
3694
|
+
else {
|
|
3695
|
+
const userDefaultServer = await serverService.getDefaultServerByUid(
|
|
3696
|
+
session.user.id
|
|
3697
|
+
);
|
|
3698
|
+
if (userDefaultServer) server2 = userDefaultServer;
|
|
3699
|
+
else return session.text(".server-not-found");
|
|
3700
|
+
}
|
|
3701
|
+
}
|
|
3702
|
+
const serverManager = ServerManager.getInstance();
|
|
3703
|
+
const sdvxService = serverManager.getGameService(server2.type, "sdvx");
|
|
3704
|
+
try {
|
|
3705
|
+
const scoreList = await sdvxService.getRecentScores(
|
|
3706
|
+
ctx,
|
|
3707
|
+
server2.baseUrl,
|
|
3708
|
+
card2.code,
|
|
3709
|
+
config,
|
|
3710
|
+
count
|
|
3711
|
+
);
|
|
3712
|
+
if (scoreList.length === 0) {
|
|
3713
|
+
return session.text(".no-scores-found");
|
|
3714
|
+
}
|
|
3715
|
+
const score = scoreList[0];
|
|
3716
|
+
session.send(session.text(".drawing"));
|
|
3717
|
+
const drawerManager = DrawerManager.getInstance(ctx);
|
|
3718
|
+
const sdvxDrawer = drawerManager.getDrawer("sdvx");
|
|
3719
|
+
const imageBuffer = await sdvxDrawer.generateRecentImage(
|
|
3720
|
+
{
|
|
3721
|
+
score,
|
|
3722
|
+
playerName: await sdvxService.getUserName(ctx, server2.baseUrl, card2.code),
|
|
3723
|
+
config
|
|
3724
|
+
},
|
|
3725
|
+
{
|
|
3726
|
+
lossless: options.lossless || false
|
|
3727
|
+
}
|
|
3728
|
+
);
|
|
3729
|
+
if (options.lossless) {
|
|
3730
|
+
return import_koishi9.h.image(imageBuffer, "image/png");
|
|
3731
|
+
}
|
|
3732
|
+
return import_koishi9.h.image(imageBuffer, "image/jpg");
|
|
3733
|
+
} catch (error) {
|
|
3734
|
+
ctx.logger("SDVX-RECENT").warn(error);
|
|
3735
|
+
return session.text(".error");
|
|
3736
|
+
}
|
|
3737
|
+
});
|
|
3738
|
+
}
|
|
3739
|
+
__name(recent, "recent");
|
|
3740
|
+
|
|
3741
|
+
// src/games/sdvx/commands/vf.ts
|
|
3742
|
+
var import_koishi10 = require("koishi");
|
|
3743
|
+
|
|
3424
3744
|
// src/games/sdvx/services/score-service.ts
|
|
3425
3745
|
var ScoreService = class _ScoreService {
|
|
3426
3746
|
static {
|
|
@@ -3591,7 +3911,6 @@ __name(parseFilterQuery, "parseFilterQuery");
|
|
|
3591
3911
|
// src/games/sdvx/commands/vf.ts
|
|
3592
3912
|
function vf(ctx, config) {
|
|
3593
3913
|
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 }) => {
|
|
3594
|
-
const model = config.default_model;
|
|
3595
3914
|
const atGuild = session.guildId != null;
|
|
3596
3915
|
const cardService = new CardService(ctx);
|
|
3597
3916
|
const serverService = new ServerService(ctx);
|
|
@@ -3616,7 +3935,7 @@ function vf(ctx, config) {
|
|
|
3616
3935
|
cardListMsg += `<p>${i + 1}. ${userCards[i].name}</p>`;
|
|
3617
3936
|
}
|
|
3618
3937
|
}
|
|
3619
|
-
const msg =
|
|
3938
|
+
const msg = import_koishi10.h.unescape(session.text(".menu-select", { card_list: cardListMsg })).replace("< 默认卡片", "< 默认卡片");
|
|
3620
3939
|
await session.send(msg);
|
|
3621
3940
|
const select = await session.prompt();
|
|
3622
3941
|
if (!select) return session.text("commands.timeout");
|
|
@@ -3679,9 +3998,9 @@ function vf(ctx, config) {
|
|
|
3679
3998
|
}
|
|
3680
3999
|
);
|
|
3681
4000
|
if (options.lossless) {
|
|
3682
|
-
return
|
|
4001
|
+
return import_koishi10.h.file(imageBuffer, "image/png");
|
|
3683
4002
|
}
|
|
3684
|
-
return
|
|
4003
|
+
return import_koishi10.h.image(imageBuffer, "image/jpg");
|
|
3685
4004
|
} catch (error) {
|
|
3686
4005
|
ctx.logger("SDVX-VF").warn(error);
|
|
3687
4006
|
return session.text(".error");
|
|
@@ -3693,7 +4012,9 @@ __name(vf, "vf");
|
|
|
3693
4012
|
// src/games/sdvx/command.ts
|
|
3694
4013
|
var name9 = "command";
|
|
3695
4014
|
function apply9(ctx, config) {
|
|
4015
|
+
ctx.command("sdvx").alias("s");
|
|
3696
4016
|
vf(ctx, config);
|
|
4017
|
+
recent(ctx, config);
|
|
3697
4018
|
}
|
|
3698
4019
|
__name(apply9, "apply");
|
|
3699
4020
|
|
|
@@ -3728,7 +4049,7 @@ var zh_CN_default4 = { _config: { $desc: "SDVX 模块设置", default_model: "<p
|
|
|
3728
4049
|
// src/games/sdvx/index.ts
|
|
3729
4050
|
var name12 = "Noah-SDVX";
|
|
3730
4051
|
var inject2 = ["database"];
|
|
3731
|
-
var logger3 = new
|
|
4052
|
+
var logger3 = new import_koishi11.Logger("Noah-SDVX");
|
|
3732
4053
|
async function apply12(ctx, config) {
|
|
3733
4054
|
;
|
|
3734
4055
|
[
|
|
@@ -3742,47 +4063,47 @@ async function apply12(ctx, config) {
|
|
|
3742
4063
|
__name(apply12, "apply");
|
|
3743
4064
|
|
|
3744
4065
|
// src/config.ts
|
|
3745
|
-
var
|
|
4066
|
+
var import_koishi16 = require("koishi");
|
|
3746
4067
|
|
|
3747
4068
|
// src/asset/config.ts
|
|
3748
|
-
var
|
|
3749
|
-
var assetConfig =
|
|
3750
|
-
data_path:
|
|
3751
|
-
auto_update:
|
|
3752
|
-
update_url:
|
|
3753
|
-
update_interval:
|
|
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),
|
|
3754
4075
|
// 24 hours in milliseconds
|
|
3755
|
-
github_token:
|
|
4076
|
+
github_token: import_koishi12.Schema.string().description("GitHub token for accessing private repositories").role("secret")
|
|
3756
4077
|
}).i18n({
|
|
3757
4078
|
"en-US": en_US_default._config,
|
|
3758
4079
|
"zh-CN": zh_CN_default._config
|
|
3759
4080
|
});
|
|
3760
4081
|
|
|
3761
4082
|
// src/core/config.ts
|
|
3762
|
-
var
|
|
3763
|
-
var coreConfig =
|
|
3764
|
-
adminUsers:
|
|
3765
|
-
guildNameCards:
|
|
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 获取食用指南"])
|
|
3766
4087
|
}).i18n({
|
|
3767
4088
|
"en-US": en_US_default2._config,
|
|
3768
4089
|
"zh-CN": zh_CN_default2._config
|
|
3769
4090
|
});
|
|
3770
4091
|
|
|
3771
4092
|
// src/fun/poke/config.ts
|
|
3772
|
-
var
|
|
3773
|
-
var pokeConfig =
|
|
3774
|
-
interval:
|
|
3775
|
-
warning:
|
|
3776
|
-
prompt:
|
|
3777
|
-
|
|
3778
|
-
content:
|
|
3779
|
-
weight:
|
|
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)
|
|
3780
4101
|
})
|
|
3781
4102
|
).role("table"),
|
|
3782
|
-
messages:
|
|
3783
|
-
|
|
3784
|
-
content:
|
|
3785
|
-
weight:
|
|
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)
|
|
3786
4107
|
})
|
|
3787
4108
|
).role("table")
|
|
3788
4109
|
}).i18n({
|
|
@@ -3791,17 +4112,17 @@ var pokeConfig = import_koishi13.Schema.object({
|
|
|
3791
4112
|
});
|
|
3792
4113
|
|
|
3793
4114
|
// src/games/sdvx/config.ts
|
|
3794
|
-
var
|
|
3795
|
-
var sdvxConfig =
|
|
3796
|
-
default_model:
|
|
3797
|
-
sdvx_data_url:
|
|
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()
|
|
3798
4119
|
}).i18n({
|
|
3799
4120
|
"en-US": en_US_default4._config,
|
|
3800
4121
|
"zh-CN": zh_CN_default4._config
|
|
3801
4122
|
});
|
|
3802
4123
|
|
|
3803
4124
|
// src/config.ts
|
|
3804
|
-
var Config =
|
|
4125
|
+
var Config = import_koishi16.Schema.object({
|
|
3805
4126
|
core: coreConfig,
|
|
3806
4127
|
sdvx: sdvxConfig,
|
|
3807
4128
|
poke: pokeConfig,
|
package/package.json
CHANGED
|
@@ -1,76 +1,77 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
2
|
+
"name": "koishi-plugin-noah",
|
|
3
|
+
"version": "1.2.1",
|
|
4
|
+
"contributors": [
|
|
5
|
+
"Logthm <logthm@outlook.com>"
|
|
6
|
+
],
|
|
7
|
+
"homepage": "https://docs.logthm.cn/noah",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "lib/index.cjs",
|
|
10
|
+
"typings": "lib/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"lib",
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"chatbot",
|
|
18
|
+
"koishi",
|
|
19
|
+
"plugin"
|
|
20
|
+
],
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"koishi": "^4.18.8"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"adm-zip": "^0.5.16",
|
|
26
|
+
"bwip-js": "^4.6.0",
|
|
27
|
+
"koishi-plugin-adapter-onebot": "^6.8.0",
|
|
28
|
+
"sharp": "^0.33.5",
|
|
29
|
+
"xml2js": "^0.6.2"
|
|
30
|
+
},
|
|
31
|
+
"koishi": {
|
|
32
|
+
"description": {
|
|
33
|
+
"en": "A tool bot for arcade music games",
|
|
34
|
+
"zh": "街机音游工具机器人"
|
|
29
35
|
},
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"service": {
|
|
36
|
-
"required": [
|
|
37
|
-
"database",
|
|
38
|
-
"skia"
|
|
39
|
-
]
|
|
40
|
-
},
|
|
41
|
-
"locales": [
|
|
42
|
-
"en",
|
|
43
|
-
"zh"
|
|
44
|
-
]
|
|
36
|
+
"service": {
|
|
37
|
+
"required": [
|
|
38
|
+
"database",
|
|
39
|
+
"skia"
|
|
40
|
+
]
|
|
45
41
|
},
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"prettier --write"
|
|
71
|
-
],
|
|
72
|
-
"*.{css,md,json}": [
|
|
73
|
-
"prettier --write"
|
|
74
|
-
]
|
|
42
|
+
"locales": [
|
|
43
|
+
"en",
|
|
44
|
+
"zh"
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@haixee/eslint-config": "^2.1.11",
|
|
49
|
+
"@ltxhhz/koishi-plugin-skia-canvas": "^0.0.8",
|
|
50
|
+
"@types/adm-zip": "^0",
|
|
51
|
+
"@types/xml2js": "^0",
|
|
52
|
+
"eslint": "^9.29.0",
|
|
53
|
+
"eslint-config-prettier": "^10.1.5",
|
|
54
|
+
"eslint-plugin-prettier": "^5.5.0",
|
|
55
|
+
"husky": "^9.1.7",
|
|
56
|
+
"lint-staged": "^16.1.2",
|
|
57
|
+
"prettier": "^3.5.3"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"lint": "eslint --ext .js,.ts,.tsx src/",
|
|
61
|
+
"format": "prettier --write \"src/**/*.{js,ts,tsx,json,css,md}\""
|
|
62
|
+
},
|
|
63
|
+
"husky": {
|
|
64
|
+
"hooks": {
|
|
65
|
+
"pre-commit": "lint-staged"
|
|
75
66
|
}
|
|
67
|
+
},
|
|
68
|
+
"lint-staged": {
|
|
69
|
+
"*.{js,ts,tsx}": [
|
|
70
|
+
"eslint --fix",
|
|
71
|
+
"prettier --write"
|
|
72
|
+
],
|
|
73
|
+
"*.{css,md,json}": [
|
|
74
|
+
"prettier --write"
|
|
75
|
+
]
|
|
76
|
+
}
|
|
76
77
|
}
|