koishi-plugin-starfx-bot 0.10.0 → 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.d.ts CHANGED
@@ -19,6 +19,7 @@ export interface Config {
19
19
  openRepeat: boolean;
20
20
  minRepeatTimes: number;
21
21
  repeatPossibility: number;
22
+ saveArchive: boolean;
22
23
  featureControl: string;
23
24
  }
24
25
  export declare const Config: Schema<Schemastery.ObjectS<{
@@ -27,6 +28,7 @@ export declare const Config: Schema<Schemastery.ObjectS<{
27
28
  bangdreamBorder: Schema<boolean, boolean>;
28
29
  }> | Schemastery.ObjectS<{
29
30
  record: Schema<boolean, boolean>;
31
+ saveArchive: Schema<boolean, boolean>;
30
32
  }> | Schemastery.ObjectS<{
31
33
  roll: Schema<boolean, boolean>;
32
34
  }> | Schemastery.ObjectS<{
@@ -48,6 +50,7 @@ export declare const Config: Schema<Schemastery.ObjectS<{
48
50
  bangdreamBorder: boolean;
49
51
  } & import("cosmokit").Dict & {
50
52
  record: boolean;
53
+ saveArchive: boolean;
51
54
  } & {
52
55
  roll: boolean;
53
56
  } & {
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);
@@ -411,7 +416,7 @@ function handleRoll(session) {
411
416
  }
412
417
  __name(handleRoll, "handleRoll");
413
418
  function getPoints(session, num, noodles) {
414
- if (isNaN(num) || isNaN(noodles)) return session.text(".invalid");
419
+ if (!Number.isInteger(num) || !Number.isInteger(noodles) || num < 0 || noodles > 0) return session.text(".invalid");
415
420
  if (num > 20 || noodles > 1e8) return session.text(".too-many");
416
421
  const points = Array(num).fill(0).map(() => Math.floor(Math.random() * noodles + 1));
417
422
  return session.text(".noodles", {
@@ -435,8 +440,8 @@ var Config2 = import_koishi2.Schema.intersect([
435
440
  bangdreamBorder: import_koishi2.Schema.boolean().default(true).description("开启BanG Dream!边框功能")
436
441
  }).description("绘图功能"),
437
442
  import_koishi2.Schema.object({
438
- record: import_koishi2.Schema.boolean().default(true).description("开启群语录功能")
439
- //saveArchive: Schema.boolean().default(false).description('开启入典功能').hidden(),
443
+ record: import_koishi2.Schema.boolean().default(true).description("开启群语录功能"),
444
+ saveArchive: import_koishi2.Schema.boolean().default(false).description("开启入典功能").hidden()
440
445
  }).description("语录记录功能"),
441
446
  import_koishi2.Schema.object({
442
447
  roll: import_koishi2.Schema.boolean().default(true).description("开启roll随机数功能")
@@ -527,6 +532,11 @@ function apply(ctx, cfg) {
527
532
  }
528
533
  });
529
534
  }
535
+ if (cfg.saveArchive) {
536
+ ctx.command("入典").action(async ({ session }) => {
537
+ if (!session.quote) return "请引用合并转发聊天记录进行入典";
538
+ });
539
+ }
530
540
  ctx.middleware(async (session, next) => {
531
541
  const elements = session.elements;
532
542
  if (cfg.openRepeat && detectControl(controlJson, session.guildId, "repeat")) {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "contributors": [
5
5
  "StarFreedomX <starfreedomx@outlook.com>"
6
6
  ],
7
- "version": "0.10.0",
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
@@ -82,3 +82,5 @@ StarFreedomX机器人的小功能,自用
82
82
  | `0.8.0` | 将各个工具函数封装在utils.ts中,更改语录的触发方式 |
83
83
  | `0.9.0` | 添加白名单/黑名单模式,对每个功能做过滤 |
84
84
  | `0.10.0` | 添加随机数功能 |
85
+ | `0.10.1` | 修复随机数骰子功能输入负数报错的bug |
86
+ | `0.10.2` | 增加roll功能的人称变化 |