koishi-plugin-starfx-bot 0.2.0 → 0.3.1
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 +2 -0
- package/lib/index.js +31 -9
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export interface Config {
|
|
|
6
6
|
openLock: boolean;
|
|
7
7
|
openSold: boolean;
|
|
8
8
|
atNotSay: boolean;
|
|
9
|
+
replyBot: boolean;
|
|
10
|
+
iLoveYou: boolean;
|
|
9
11
|
}
|
|
10
12
|
export declare const Config: Schema<Config>;
|
|
11
13
|
export declare const usage = "StarFreedomX\u7684\u81EA\u7528\u63D2\u4EF6 \u653E\u4E86\u4E00\u4E9B\u5C0F\u529F\u80FD";
|
package/lib/index.js
CHANGED
|
@@ -50,7 +50,9 @@ var assetsDir;
|
|
|
50
50
|
var Config = import_koishi.Schema.object({
|
|
51
51
|
openLock: import_koishi.Schema.boolean().default(true).description("开启明日方舟封印功能"),
|
|
52
52
|
openSold: import_koishi.Schema.boolean().default(true).description('开启闲鱼"卖掉了"功能'),
|
|
53
|
-
atNotSay: import_koishi.Schema.boolean().default(true).description("
|
|
53
|
+
atNotSay: import_koishi.Schema.boolean().default(true).description("开启‘艾特我/他又不说话’功能"),
|
|
54
|
+
replyBot: import_koishi.Schema.boolean().default(true).description("开启回复‘机器人’功能"),
|
|
55
|
+
iLoveYou: import_koishi.Schema.boolean().default(true).description("开启‘我喜欢你’功能")
|
|
54
56
|
});
|
|
55
57
|
var usage = "StarFreedomX的自用插件 放了一些小功能";
|
|
56
58
|
function apply(ctx, cfg) {
|
|
@@ -74,15 +76,35 @@ function apply(ctx, cfg) {
|
|
|
74
76
|
return await drawSold(await getImageSrc(session, param));
|
|
75
77
|
});
|
|
76
78
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
ctx.middleware(async (session, next) => {
|
|
80
|
+
const elements = session.elements;
|
|
81
|
+
console.log(elements);
|
|
82
|
+
if (cfg.atNotSay) {
|
|
83
|
+
if (elements.length === 1 && elements[0].type === "at") {
|
|
84
|
+
if (elements[0].attrs.id === session.selfId) {
|
|
85
|
+
await session.send("艾特我又不说话");
|
|
86
|
+
} else {
|
|
87
|
+
await session.send("艾特他又不说话");
|
|
88
|
+
}
|
|
82
89
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
90
|
+
}
|
|
91
|
+
if (cfg.replyBot) {
|
|
92
|
+
const bots = ["bot", "机器人", "Bot", "BOT", "机器人!", "机器人!"];
|
|
93
|
+
const texts = elements?.filter((e) => e.type === "text").map((e) => e?.attrs?.content?.trim());
|
|
94
|
+
const ats = elements?.filter((e) => e.type === "at").map((e) => e?.attrs?.id);
|
|
95
|
+
const mentionedBot = texts?.some((t) => bots.includes(t));
|
|
96
|
+
const atMe = ats?.includes(session.selfId);
|
|
97
|
+
if (elements?.length === 1 && mentionedBot || elements?.length === 2 && mentionedBot && atMe) {
|
|
98
|
+
await session.send("我才不是机器人!");
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (cfg.iLoveYou) {
|
|
102
|
+
if (elements?.length === 2 && elements.some((e) => e.type === "at" && e?.attrs?.id === session.selfId) && elements.some((e) => e.type === "text" && e?.attrs?.content?.trim() === "我喜欢你")) {
|
|
103
|
+
await session.send(`${import_koishi.h.quote(session.messageId)}${import_koishi.h.at(session.userId)} 我也喜欢你`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return next();
|
|
107
|
+
});
|
|
86
108
|
}
|
|
87
109
|
__name(apply, "apply");
|
|
88
110
|
async function getImageSrc(session, param) {
|