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 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 && param?.length === String(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
- const [image, colorImage, bandImage, starImage, borderImage] = await Promise.all([
345
- import_jimp.Jimp.read(avatar),
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
@@ -4,7 +4,7 @@
4
4
  "contributors": [
5
5
  "StarFreedomX <starfreedomx@outlook.com>"
6
6
  ],
7
- "version": "0.13.4",
7
+ "version": "0.13.6",
8
8
  "main": "lib/index.js",
9
9
  "typings": "lib/index.d.ts",
10
10
  "files": [
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.3` | Re修订:不再return图片对象,防止$()可能导致的参数溢出 |
104
+ | `0.13.4` | Re修订:不再return图片对象,防止$()可能导致的参数溢出 |
105
+ | `0.13.5` | Re再修订:bdbd新增检测异常机制,防止$()可能导致的问题 |
106
+ | `0.13.6` | 恢复误注释内容 |