koishi-plugin-starfx-bot 0.13.4 → 0.13.6
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.js +12 -4
- package/package.json +1 -1
- package/readme.md +3 -1
package/lib/index.js
CHANGED
|
@@ -131,7 +131,7 @@ function saveImage(arrayBuffer, directory, filename) {
|
|
|
131
131
|
__name(saveImage, "saveImage");
|
|
132
132
|
async function getImageSrc(session, param, option) {
|
|
133
133
|
const number = option?.number ?? true, img = option?.img ?? true, at = option?.at ?? true, noParam = option?.noParam ?? true, quote = option?.quote ?? true;
|
|
134
|
-
if (number && param?.length &&
|
|
134
|
+
if (number && param?.length && /^\d+$/.test(param)) {
|
|
135
135
|
return `https://q1.qlogo.cn/g?b=qq&nk=${param}&s=640`;
|
|
136
136
|
} else if (noParam && !param?.length) {
|
|
137
137
|
return `https://q1.qlogo.cn/g?b=qq&nk=${session.userId}&s=640`;
|
|
@@ -341,8 +341,14 @@ async function drawBanGDream(avatar, inputOptions) {
|
|
|
341
341
|
};
|
|
342
342
|
options.starType ||= options.starNum < 3 ? starTypes[0] : import_koishi.Random.pick(starTypes);
|
|
343
343
|
options.border ||= `card-${starNums.includes(options.starNum) ? options.starNum : 5}${options.starNum == 1 ? `-${options.color}` : ""}`;
|
|
344
|
-
|
|
345
|
-
|
|
344
|
+
let image;
|
|
345
|
+
try {
|
|
346
|
+
image = await import_jimp.Jimp.read(avatar);
|
|
347
|
+
} catch (e) {
|
|
348
|
+
starfxLogger.error(e);
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
const [colorImage, bandImage, starImage, borderImage] = await Promise.all([
|
|
346
352
|
import_jimp.Jimp.read(`${assetsDir}/bangborder/${options.color}.png`),
|
|
347
353
|
import_jimp.Jimp.read(`${assetsDir}/bangborder/${options.band}.png`),
|
|
348
354
|
import_jimp.Jimp.read(`${assetsDir}/bangborder/${options.starType}.png`),
|
|
@@ -535,11 +541,12 @@ function apply(ctx, cfg) {
|
|
|
535
541
|
ctx.command("bdbd [param]").option("starNum", "-n <starNum: number>").option("color", "-c <color: string>").option("train", "-t <train: string>").option("band", "-b <band: string>").action(async ({ session, options }, param) => {
|
|
536
542
|
if (detectControl(controlJson, session.guildId, "bdbd")) {
|
|
537
543
|
const p = session.send("图片处理中请稍等...");
|
|
538
|
-
console.log(param);
|
|
544
|
+
console.log(param.slice(0, 1e3));
|
|
539
545
|
const drawConfig = await handleBanGDreamConfig(options);
|
|
540
546
|
const imgSrc = await getImageSrc(session, param);
|
|
541
547
|
if (!imgSrc?.length) return "输入无效";
|
|
542
548
|
const imageBase64 = await drawBanGDream(imgSrc, drawConfig);
|
|
549
|
+
if (!imageBase64?.length) return "输入无效...";
|
|
543
550
|
await p;
|
|
544
551
|
await session.send(import_koishi2.h.image(imageBase64));
|
|
545
552
|
}
|
|
@@ -609,6 +616,7 @@ function apply(ctx, cfg) {
|
|
|
609
616
|
});
|
|
610
617
|
if (process.env.NODE_ENV === "development") {
|
|
611
618
|
ctx.command("test").action(async ({ session }) => {
|
|
619
|
+
await session.send(import_koishi2.h.video("https://video.twimg.com/amplify_video/1920672748596043776/vid/avc1/1080x1920/c3BNP3qg4-sT82fR.mp4?tag=21"));
|
|
612
620
|
});
|
|
613
621
|
}
|
|
614
622
|
function initAssets() {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -101,4 +101,6 @@ StarFreedomX机器人的小功能,自用
|
|
|
101
101
|
| `0.13.1` | 修复pure类型绘图名称错误 |
|
|
102
102
|
| `0.13.2` | 优化了tag在权重很大情况下的筛选效率 |
|
|
103
103
|
| `0.13.3` | 不再return图片对象,防止$()可能导致的参数溢出 |
|
|
104
|
-
| `0.13.
|
|
104
|
+
| `0.13.4` | Re修订:不再return图片对象,防止$()可能导致的参数溢出 |
|
|
105
|
+
| `0.13.5` | Re再修订:bdbd新增检测异常机制,防止$()可能导致的问题 |
|
|
106
|
+
| `0.13.6` | 恢复误注释内容 |
|