koishi-plugin-onebot-verifier 1.0.1 → 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.d.ts +3 -0
- package/lib/index.js +5 -6
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Context, Schema } from 'koishi';
|
|
2
2
|
export declare const name = "onebot-verifier";
|
|
3
|
+
export declare const inject: {
|
|
4
|
+
optional: string[];
|
|
5
|
+
};
|
|
3
6
|
export declare const usage = "\n<div style=\"border-radius: 10px; border: 1px solid #ddd; padding: 16px; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);\">\n <h2 style=\"margin-top: 0; color: #4a6ee0;\">\uD83D\uDCCC \u63D2\u4EF6\u8BF4\u660E</h2>\n <p>\uD83D\uDCD6 <strong>\u4F7F\u7528\u6587\u6863</strong>\uFF1A\u8BF7\u70B9\u51FB\u5DE6\u4E0A\u89D2\u7684 <strong>\u63D2\u4EF6\u4E3B\u9875</strong> \u67E5\u770B\u63D2\u4EF6\u4F7F\u7528\u6587\u6863</p>\n <p>\uD83D\uDD0D <strong>\u66F4\u591A\u63D2\u4EF6</strong>\uFF1A\u53EF\u8BBF\u95EE <a href=\"https://github.com/YisRime\" style=\"color:#4a6ee0;text-decoration:none;\">\u82E1\u6DDE\u7684 GitHub</a> \u67E5\u770B\u672C\u4EBA\u7684\u6240\u6709\u63D2\u4EF6</p>\n</div>\n<div style=\"border-radius: 10px; border: 1px solid #ddd; padding: 16px; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);\">\n <h2 style=\"margin-top: 0; color: #e0574a;\">\u2764\uFE0F \u652F\u6301\u4E0E\u53CD\u9988</h2>\n <p>\uD83C\uDF1F \u559C\u6B22\u8FD9\u4E2A\u63D2\u4EF6\uFF1F\u8BF7\u5728 <a href=\"https://github.com/YisRime\" style=\"color:#e0574a;text-decoration:none;\">GitHub</a> \u4E0A\u7ED9\u6211\u4E00\u4E2A Star\uFF01</p>\n <p>\uD83D\uDC1B \u9047\u5230\u95EE\u9898\uFF1F\u8BF7\u901A\u8FC7 <strong>Issues</strong> \u63D0\u4EA4\u53CD\u9988\uFF0C\u6216\u52A0\u5165 QQ \u7FA4 <a href=\"https://qm.qq.com/q/PdLMx9Jowq\" style=\"color:#e0574a;text-decoration:none;\"><strong>855571375</strong></a> \u8FDB\u884C\u4EA4\u6D41</p>\n</div>\n";
|
|
4
7
|
export interface Config {
|
|
5
8
|
notifyTarget?: string;
|
package/lib/index.js
CHANGED
|
@@ -22,12 +22,14 @@ var src_exports = {};
|
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
Config: () => Config,
|
|
24
24
|
apply: () => apply,
|
|
25
|
+
inject: () => inject,
|
|
25
26
|
name: () => name,
|
|
26
27
|
usage: () => usage
|
|
27
28
|
});
|
|
28
29
|
module.exports = __toCommonJS(src_exports);
|
|
29
30
|
var import_koishi = require("koishi");
|
|
30
31
|
var name = "onebot-verifier";
|
|
32
|
+
var inject = { optional: ["database"] };
|
|
31
33
|
var usage = `
|
|
32
34
|
<div style="border-radius: 10px; border: 1px solid #ddd; padding: 16px; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);">
|
|
33
35
|
<h2 style="margin-top: 0; color: #4a6ee0;">📌 插件说明</h2>
|
|
@@ -131,15 +133,11 @@ function apply(ctx, config = {}) {
|
|
|
131
133
|
const rawText = session.event?._data?.comment || "";
|
|
132
134
|
const cleanLines = rawText.split(/[\r\n]+/).map((s) => s.trim()).filter((s) => /^(回答)[::]/i.test(s)).map((s) => s.replace(/^(回答)[::]\s*/i, ""));
|
|
133
135
|
const verifyText = cleanLines.length > 0 ? cleanLines.join("\n") : rawText;
|
|
134
|
-
const toRegex = /* @__PURE__ */ __name((text) => {
|
|
135
|
-
const match = text.match(/^\/(.+)\/([a-z]*)$/);
|
|
136
|
-
return match ? new RegExp(match[1], match[2]) : new RegExp(text, "i");
|
|
137
|
-
}, "toRegex");
|
|
138
136
|
if (kind === "member") {
|
|
139
137
|
const groupRule = config.verifyRules?.find((r) => r.guildId === session.guildId);
|
|
140
138
|
if (!groupRule) return false;
|
|
141
139
|
try {
|
|
142
|
-
if (groupRule.keyword && !
|
|
140
|
+
if (groupRule.keyword && !new RegExp(groupRule.keyword, "i").test(verifyText)) return false;
|
|
143
141
|
const limitLevel = groupRule.minLevel ?? -1;
|
|
144
142
|
if (limitLevel >= 0 && session.onebot && session.userId) {
|
|
145
143
|
const stats = await session.onebot.getStrangerInfo(session.userId, true);
|
|
@@ -152,7 +150,7 @@ function apply(ctx, config = {}) {
|
|
|
152
150
|
}
|
|
153
151
|
if (kind === "friend") {
|
|
154
152
|
try {
|
|
155
|
-
if (config.friendRegex &&
|
|
153
|
+
if (config.friendRegex && new RegExp(config.friendRegex, "i").test(verifyText)) return true;
|
|
156
154
|
const limitLevel = config.friendLevel ?? -1;
|
|
157
155
|
if (limitLevel >= 0 && session.onebot && session.userId) {
|
|
158
156
|
const stats = await session.onebot.getStrangerInfo(session.userId, true);
|
|
@@ -271,6 +269,7 @@ __name(apply, "apply");
|
|
|
271
269
|
0 && (module.exports = {
|
|
272
270
|
Config,
|
|
273
271
|
apply,
|
|
272
|
+
inject,
|
|
274
273
|
name,
|
|
275
274
|
usage
|
|
276
275
|
});
|