koishi-plugin-starfx-bot 0.10.1 → 0.11.0
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 +4 -1
- package/lib/index.js +23 -5
- package/lib/utils.d.ts +6 -1
- package/package.json +1 -1
- package/readme.md +3 -0
package/lib/index.d.ts
CHANGED
|
@@ -9,7 +9,9 @@ export interface Config {
|
|
|
9
9
|
openSold: boolean;
|
|
10
10
|
bangdreamBorder: boolean;
|
|
11
11
|
record: boolean;
|
|
12
|
+
saveArchive: boolean;
|
|
12
13
|
roll: boolean;
|
|
14
|
+
undo: boolean;
|
|
13
15
|
atNotSay: boolean;
|
|
14
16
|
atNotSayProperty: number;
|
|
15
17
|
atNotSayOther: boolean;
|
|
@@ -19,7 +21,6 @@ export interface Config {
|
|
|
19
21
|
openRepeat: boolean;
|
|
20
22
|
minRepeatTimes: number;
|
|
21
23
|
repeatPossibility: number;
|
|
22
|
-
saveArchive: boolean;
|
|
23
24
|
featureControl: string;
|
|
24
25
|
}
|
|
25
26
|
export declare const Config: Schema<Schemastery.ObjectS<{
|
|
@@ -31,6 +32,7 @@ export declare const Config: Schema<Schemastery.ObjectS<{
|
|
|
31
32
|
saveArchive: Schema<boolean, boolean>;
|
|
32
33
|
}> | Schemastery.ObjectS<{
|
|
33
34
|
roll: Schema<boolean, boolean>;
|
|
35
|
+
undo: Schema<boolean, boolean>;
|
|
34
36
|
}> | Schemastery.ObjectS<{
|
|
35
37
|
atNotSay: Schema<boolean, boolean>;
|
|
36
38
|
atNotSayProperty: Schema<number, number>;
|
|
@@ -53,6 +55,7 @@ export declare const Config: Schema<Schemastery.ObjectS<{
|
|
|
53
55
|
saveArchive: boolean;
|
|
54
56
|
} & {
|
|
55
57
|
roll: boolean;
|
|
58
|
+
undo: boolean;
|
|
56
59
|
} & {
|
|
57
60
|
atNotSay: boolean;
|
|
58
61
|
atNotSayProperty: number;
|
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);
|
|
@@ -421,6 +426,12 @@ function getPoints(session, num, noodles) {
|
|
|
421
426
|
});
|
|
422
427
|
}
|
|
423
428
|
__name(getPoints, "getPoints");
|
|
429
|
+
async function undo(cfg, session) {
|
|
430
|
+
if (session?.quote?.id && session.quote.user.id === session.selfId && Date.now() - session.quote.timestamp < 2 * 60 * 1e3 - 5 * 1e3) {
|
|
431
|
+
await session.bot.deleteMessage(session.channelId || session.guildId, session.quote.id);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
__name(undo, "undo");
|
|
424
435
|
|
|
425
436
|
// src/index.ts
|
|
426
437
|
var name = "starfx-bot";
|
|
@@ -439,7 +450,8 @@ var Config2 = import_koishi2.Schema.intersect([
|
|
|
439
450
|
saveArchive: import_koishi2.Schema.boolean().default(false).description("开启入典功能").hidden()
|
|
440
451
|
}).description("语录记录功能"),
|
|
441
452
|
import_koishi2.Schema.object({
|
|
442
|
-
roll: import_koishi2.Schema.boolean().default(true).description("开启roll随机数功能")
|
|
453
|
+
roll: import_koishi2.Schema.boolean().default(true).description("开启roll随机数功能"),
|
|
454
|
+
undo: import_koishi2.Schema.boolean().default(true).description("机器人撤回消息功能")
|
|
443
455
|
}).description("指令小功能"),
|
|
444
456
|
import_koishi2.Schema.object({
|
|
445
457
|
atNotSay: import_koishi2.Schema.boolean().default(true).description("开启‘艾特我又不说话’功能"),
|
|
@@ -532,6 +544,12 @@ function apply(ctx, cfg) {
|
|
|
532
544
|
if (!session.quote) return "请引用合并转发聊天记录进行入典";
|
|
533
545
|
});
|
|
534
546
|
}
|
|
547
|
+
if (cfg.undo) {
|
|
548
|
+
ctx.command("undo").alias("撤回").action(async ({ session }) => {
|
|
549
|
+
if (detectControl(controlJson, session.guildId, "undo"))
|
|
550
|
+
await undo(cfg, session);
|
|
551
|
+
});
|
|
552
|
+
}
|
|
535
553
|
ctx.middleware(async (session, next) => {
|
|
536
554
|
const elements = session.elements;
|
|
537
555
|
if (cfg.openRepeat && detectControl(controlJson, session.guildId, "repeat")) {
|
package/lib/utils.d.ts
CHANGED
|
@@ -129,5 +129,10 @@ 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
|
-
|
|
132
|
+
/**
|
|
133
|
+
* qq撤回功能(其他平台不知道w
|
|
134
|
+
* @param cfg config
|
|
135
|
+
* @param session session
|
|
136
|
+
*/
|
|
137
|
+
export declare function undo(cfg: Config, session: Session): Promise<void>;
|
|
133
138
|
export {};
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -50,6 +50,7 @@ StarFreedomX机器人的小功能,自用
|
|
|
50
50
|
| `iLoveYou` | “我也喜欢你”系列功能 |
|
|
51
51
|
| `bdbd` | BanG Dream! 边框功能(对应 `bangdreamBorder`) |
|
|
52
52
|
| `roll` | 随机数功能 |
|
|
53
|
+
| `undo` | 撤回功能 |
|
|
53
54
|
|
|
54
55
|
---
|
|
55
56
|
|
|
@@ -83,3 +84,5 @@ StarFreedomX机器人的小功能,自用
|
|
|
83
84
|
| `0.9.0` | 添加白名单/黑名单模式,对每个功能做过滤 |
|
|
84
85
|
| `0.10.0` | 添加随机数功能 |
|
|
85
86
|
| `0.10.1` | 修复随机数骰子功能输入负数报错的bug |
|
|
87
|
+
| `0.10.2` | 增加roll功能的人称变化 |
|
|
88
|
+
| `0.11.0` | 增加适配于onebot(主要是qq)的撤回功能 |
|