koishi-plugin-starfx-bot 0.10.1 → 0.10.2

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
@@ -373,23 +373,28 @@ function handleRoll(session) {
373
373
  let parts = [];
374
374
  for (const element of elements) {
375
375
  if (element?.type === "text") {
376
- parts.push(...element.attrs.content.split(/(?:\s+)+/).filter(Boolean));
376
+ let str = element.attrs.content;
377
+ let placeholder = "__TEMP__";
378
+ while (str.includes(placeholder)) {
379
+ placeholder += "_X";
380
+ }
381
+ str = str.replace(/我/g, placeholder).replace(/你/g, "我").replace(new RegExp(placeholder, "g"), "你");
382
+ parts.push(...str.split(/(?:\s+)+/).filter(Boolean));
377
383
  } else {
378
384
  parts.push(element);
379
385
  }
380
386
  }
381
- const commandLength = parts[0].length;
382
387
  console.log(parts);
383
388
  parts.shift();
384
389
  if (!parts) return session.text(".noParam");
385
390
  const last = session.elements[session.elements.length - 1];
386
- if (last?.type === "text" && last?.attrs?.content?.endsWith("的概率") && last?.attrs?.content?.length > 3) {
391
+ if (last?.type === "text" && last?.attrs?.content?.endsWith("概率") && last?.attrs?.content?.length > 3) {
387
392
  return session.text(".possibility", {
388
393
  param: parts,
389
394
  possibility: Math.floor(Math.random() * 1e4 + 1) / 100
390
395
  });
391
396
  }
392
- const items = parts.join(" ").split("r");
397
+ const items = parts.join(" ").split("r").filter(Boolean);
393
398
  if (items.length === 2) {
394
399
  const [num, noodles] = items.map(Number);
395
400
  return getPoints(session, num, noodles);
package/lib/utils.d.ts CHANGED
@@ -129,5 +129,4 @@ export declare function drawBanGDream(avatar: string, inputOptions?: {
129
129
  export declare function parseJsonControl(text: string): FeatureControl | null;
130
130
  export declare function detectControl(controlJson: FeatureControl, guildId: string, funName: string): boolean;
131
131
  export declare function handleRoll(session: Session): string;
132
- export declare function saveArchive(quoteElements: h[], gid: string, session: Session): void;
133
132
  export {};
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "contributors": [
5
5
  "StarFreedomX <starfreedomx@outlook.com>"
6
6
  ],
7
- "version": "0.10.1",
7
+ "version": "0.10.2",
8
8
  "main": "lib/index.js",
9
9
  "typings": "lib/index.d.ts",
10
10
  "files": [
package/readme.md CHANGED
@@ -83,3 +83,4 @@ StarFreedomX机器人的小功能,自用
83
83
  | `0.9.0` | 添加白名单/黑名单模式,对每个功能做过滤 |
84
84
  | `0.10.0` | 添加随机数功能 |
85
85
  | `0.10.1` | 修复随机数骰子功能输入负数报错的bug |
86
+ | `0.10.2` | 增加roll功能的人称变化 |