koishi-plugin-onebot-verifier 1.0.2 → 1.0.3
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 +2 -6
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -133,15 +133,11 @@ function apply(ctx, config = {}) {
|
|
|
133
133
|
const rawText = session.event?._data?.comment || "";
|
|
134
134
|
const cleanLines = rawText.split(/[\r\n]+/).map((s) => s.trim()).filter((s) => /^(回答)[::]/i.test(s)).map((s) => s.replace(/^(回答)[::]\s*/i, ""));
|
|
135
135
|
const verifyText = cleanLines.length > 0 ? cleanLines.join("\n") : rawText;
|
|
136
|
-
const toRegex = /* @__PURE__ */ __name((text) => {
|
|
137
|
-
const match = text.match(/^\/(.+)\/([a-z]*)$/);
|
|
138
|
-
return match ? new RegExp(match[1], match[2]) : new RegExp(text, "i");
|
|
139
|
-
}, "toRegex");
|
|
140
136
|
if (kind === "member") {
|
|
141
137
|
const groupRule = config.verifyRules?.find((r) => r.guildId === session.guildId);
|
|
142
138
|
if (!groupRule) return false;
|
|
143
139
|
try {
|
|
144
|
-
if (groupRule.keyword && !
|
|
140
|
+
if (groupRule.keyword && !new RegExp(groupRule.keyword, "i").test(verifyText)) return false;
|
|
145
141
|
const limitLevel = groupRule.minLevel ?? -1;
|
|
146
142
|
if (limitLevel >= 0 && session.onebot && session.userId) {
|
|
147
143
|
const stats = await session.onebot.getStrangerInfo(session.userId, true);
|
|
@@ -154,7 +150,7 @@ function apply(ctx, config = {}) {
|
|
|
154
150
|
}
|
|
155
151
|
if (kind === "friend") {
|
|
156
152
|
try {
|
|
157
|
-
if (config.friendRegex &&
|
|
153
|
+
if (config.friendRegex && new RegExp(config.friendRegex, "i").test(verifyText)) return true;
|
|
158
154
|
const limitLevel = config.friendLevel ?? -1;
|
|
159
155
|
if (limitLevel >= 0 && session.onebot && session.userId) {
|
|
160
156
|
const stats = await session.onebot.getStrangerInfo(session.userId, true);
|