koishi-plugin-starfx-bot 0.13.4 → 0.13.5

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`;
@@ -141,7 +141,6 @@ async function getImageSrc(session, param, option) {
141
141
  if (quoteElementArray?.length) {
142
142
  for (const element of quoteElementArray) {
143
143
  if (img && element?.type === "img") {
144
- return element?.attrs?.src;
145
144
  } else if (at && element?.type === "at" && element?.attrs?.id && element.attrs.id !== session.selfId) {
146
145
  return `https://q1.qlogo.cn/g?b=qq&nk=${element?.attrs?.id}&s=640`;
147
146
  }
@@ -341,8 +340,14 @@ async function drawBanGDream(avatar, inputOptions) {
341
340
  };
342
341
  options.starType ||= options.starNum < 3 ? starTypes[0] : import_koishi.Random.pick(starTypes);
343
342
  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),
343
+ let image;
344
+ try {
345
+ image = await import_jimp.Jimp.read(avatar);
346
+ } catch (e) {
347
+ starfxLogger.error(e);
348
+ return;
349
+ }
350
+ const [colorImage, bandImage, starImage, borderImage] = await Promise.all([
346
351
  import_jimp.Jimp.read(`${assetsDir}/bangborder/${options.color}.png`),
347
352
  import_jimp.Jimp.read(`${assetsDir}/bangborder/${options.band}.png`),
348
353
  import_jimp.Jimp.read(`${assetsDir}/bangborder/${options.starType}.png`),
@@ -535,11 +540,12 @@ function apply(ctx, cfg) {
535
540
  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
541
  if (detectControl(controlJson, session.guildId, "bdbd")) {
537
542
  const p = session.send("图片处理中请稍等...");
538
- console.log(param);
543
+ console.log(param.slice(0, 100));
539
544
  const drawConfig = await handleBanGDreamConfig(options);
540
545
  const imgSrc = await getImageSrc(session, param);
541
546
  if (!imgSrc?.length) return "输入无效";
542
547
  const imageBase64 = await drawBanGDream(imgSrc, drawConfig);
548
+ if (!imageBase64?.length) return "输入无效";
543
549
  await p;
544
550
  await session.send(import_koishi2.h.image(imageBase64));
545
551
  }
@@ -609,6 +615,7 @@ function apply(ctx, cfg) {
609
615
  });
610
616
  if (process.env.NODE_ENV === "development") {
611
617
  ctx.command("test").action(async ({ session }) => {
618
+ await session.send(import_koishi2.h.video("https://video.twimg.com/amplify_video/1920672748596043776/vid/avc1/1080x1920/c3BNP3qg4-sT82fR.mp4?tag=21"));
612
619
  });
613
620
  }
614
621
  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.5",
8
8
  "main": "lib/index.js",
9
9
  "typings": "lib/index.d.ts",
10
10
  "files": [
package/readme.md CHANGED
@@ -101,4 +101,5 @@ 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新增检测异常机制,防止$()可能导致的问题 |