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 +3 -0
- package/lib/index.js +17 -7
- package/package.json +1 -1
- package/readme.md +2 -0
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
|
-
|
|
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("
|
|
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 (
|
|
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
|
-
|
|
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