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 +9 -4
- package/lib/utils.d.ts +0 -1
- package/package.json +1 -1
- package/readme.md +1 -0
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);
|
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
package/readme.md
CHANGED