koishi-plugin-onebot-verifier 1.2.1 → 1.2.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 +8 -6
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -88,7 +88,7 @@ var Config = import_koishi.Schema.intersect([
|
|
|
88
88
|
}).description("加群请求配置"),
|
|
89
89
|
import_koishi.Schema.object({
|
|
90
90
|
voteInSitu: import_koishi.Schema.boolean().description("[投票]原群投票模式").default(true),
|
|
91
|
-
voteRatio: import_koishi.Schema.string().description("[投票]支持/反对人数").default("
|
|
91
|
+
voteRatio: import_koishi.Schema.string().description("[投票]支持/反对人数").default("5:1"),
|
|
92
92
|
captchaDiff: import_koishi.Schema.union([
|
|
93
93
|
import_koishi.Schema.const("simple").description("简单"),
|
|
94
94
|
import_koishi.Schema.const("medium").description("中等"),
|
|
@@ -133,7 +133,7 @@ function apply(ctx, config) {
|
|
|
133
133
|
return false;
|
|
134
134
|
}
|
|
135
135
|
}, "executeAction");
|
|
136
|
-
const sendNotice = /* @__PURE__ */ __name(async (session, kind, status = "waiting", overrideTarget) => {
|
|
136
|
+
const sendNotice = /* @__PURE__ */ __name(async (session, kind, status = "waiting", overrideTarget, specialMode) => {
|
|
137
137
|
const notifyConfig = overrideTarget || config.notifyTarget || "";
|
|
138
138
|
const [targetType, targetId] = notifyConfig.split(":");
|
|
139
139
|
if (!targetId || !session.bot) return [];
|
|
@@ -152,7 +152,10 @@ function apply(ctx, config) {
|
|
|
152
152
|
if (adminId) infoLines.push(`管理:${adminInfo?.name ? `${adminInfo.name}(${adminId})` : adminId}`);
|
|
153
153
|
if (session.guildId) infoLines.push(`群组:${groupInfo?.name ? `${groupInfo.name}(${session.guildId})` : session.guildId}`);
|
|
154
154
|
if (eventData.comment) infoLines.push(`验证信息:${eventData.comment}`);
|
|
155
|
-
if (status === "waiting" && kind !== "removed")
|
|
155
|
+
if (status === "waiting" && kind !== "removed") {
|
|
156
|
+
if (specialMode === "vote") infoLines.push(`[投票模式]需${config.voteRatio.split(":")[0]}人同意或${config.voteRatio.split(":")[1]}人拒绝`);
|
|
157
|
+
infoLines.push(`使用"y/n"回复本消息以处理该请求`);
|
|
158
|
+
}
|
|
156
159
|
const content = infoLines.join("\n");
|
|
157
160
|
const msgIds = await (targetType === "private" ? session.bot.sendPrivateMessage(targetId, content) : session.bot.sendMessage(targetId, content)) || [];
|
|
158
161
|
return msgIds;
|
|
@@ -165,7 +168,7 @@ function apply(ctx, config) {
|
|
|
165
168
|
const timeoutCfg = kind === "member" ? config.memberTimeout : config.friendTimeout;
|
|
166
169
|
let targetStr = config.notifyTarget || "";
|
|
167
170
|
if (useInSitu && kind === "member" && session.guildId) targetStr = `guild:${session.guildId}`;
|
|
168
|
-
const msgIds = await sendNotice(session, kind, "waiting", targetStr);
|
|
171
|
+
const msgIds = await sendNotice(session, kind, "waiting", targetStr, specialMode);
|
|
169
172
|
if (!msgIds?.length) return;
|
|
170
173
|
const task = { session, kind, messages: msgIds, specialMode, inSitu: useInSitu };
|
|
171
174
|
if (specialMode === "vote") {
|
|
@@ -324,8 +327,7 @@ function apply(ctx, config) {
|
|
|
324
327
|
if (task.timer) clearTimeout(task.timer);
|
|
325
328
|
task.messages.forEach((msg) => activeTasks.delete(msg));
|
|
326
329
|
const isSuccess = await executeAction(task.session, task.kind, finalVerdict, finalVerdict ? "" : extraInfo);
|
|
327
|
-
|
|
328
|
-
await session.send(replyText).catch(() => {
|
|
330
|
+
if (!task.inSitu) await session.send(isSuccess ? `已${finalVerdict ? "通过" : "拒绝"}该投票` : `处理投票失败`).catch(() => {
|
|
329
331
|
});
|
|
330
332
|
}, "handleSpecialVote");
|
|
331
333
|
ctx.on("friend-request", hookEvent("friend"));
|
package/package.json
CHANGED