koishi-plugin-lili-hub 0.2.0 → 0.2.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.js +31 -5
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -747,8 +747,20 @@ ${import_koishi.segment.at(targetId)} \u5DF2\u88AB\u89E3\u9664\u7981\u8A00\u3002
|
|
|
747
747
|
const plainText = session.elements ? session.elements.filter((el) => el.type === "text").map((el) => el.attrs?.content || "").join("").trim() : content.replace(/<[^>]+>/g, "").trim();
|
|
748
748
|
const normalizedText = normalizeText(plainText);
|
|
749
749
|
const textLen = normalizedText.length;
|
|
750
|
+
const botId = session.bot.userId || session.bot.selfId;
|
|
751
|
+
if (botId && String(session.userId) === String(botId)) return next();
|
|
750
752
|
if (config.dedup.enabled && isGroupAllowed(gid, config.dedup.groups)) {
|
|
751
|
-
|
|
753
|
+
const isFwd = isForwardMessage(session);
|
|
754
|
+
dbg("\u67E5\u91CD-\u4E2D\u95F4\u4EF6\u5165\u53E3", {
|
|
755
|
+
gid,
|
|
756
|
+
userId: session.userId,
|
|
757
|
+
textLen,
|
|
758
|
+
dedupEnabled: true,
|
|
759
|
+
isForward: isFwd,
|
|
760
|
+
contentPreview: normalizedText.substring(0, 50),
|
|
761
|
+
elementTypes: session.elements?.map((e) => e.type) || []
|
|
762
|
+
});
|
|
763
|
+
if (isFwd) {
|
|
752
764
|
const forwardTexts = extractForwardTexts(session);
|
|
753
765
|
const sevenDaysAgo = Date.now() - 7 * 24 * 60 * 60 * 1e3;
|
|
754
766
|
dbg("\u67E5\u91CD\u68C0\u6D4B", { gid, forwardTextsCount: forwardTexts.length });
|
|
@@ -798,19 +810,33 @@ ${import_koishi.segment.at(targetId)} \u5DF2\u88AB\u89E3\u9664\u7981\u8A00\u3002
|
|
|
798
810
|
}
|
|
799
811
|
}
|
|
800
812
|
}
|
|
801
|
-
const botId = session.bot.userId || session.bot.selfId;
|
|
802
|
-
if (botId && String(session.userId) === String(botId)) return next();
|
|
803
813
|
const imitationGroups = parseGroupList(config.imitation.groups);
|
|
804
814
|
const dedupGroups = parseGroupList(config.dedup.groups);
|
|
805
815
|
const foldGroups = config.fold.enabled ? parseGroupList(config.fold.groups) : [];
|
|
806
|
-
const
|
|
816
|
+
const dedupInGroup = config.dedup.enabled && isGroupAllowed(gid, config.dedup.groups);
|
|
817
|
+
const foldInGroup = config.fold.enabled && isGroupAllowed(gid, config.fold.groups);
|
|
818
|
+
const shouldRecordAll = foldInGroup || dedupInGroup;
|
|
807
819
|
const shouldRecordLimited = textLen >= 15 && textLen <= 60 && normalizedText;
|
|
808
820
|
const recordGroups = /* @__PURE__ */ new Set([...imitationGroups, ...dedupGroups, ...foldGroups]);
|
|
809
821
|
const shouldRecord = shouldRecordAll || shouldRecordLimited && (recordGroups.size === 0 || recordGroups.has(gid));
|
|
822
|
+
dbg("\u8BB0\u5F55\u6D88\u606F\u5224\u5B9A", {
|
|
823
|
+
gid,
|
|
824
|
+
userId: session.userId,
|
|
825
|
+
textLen,
|
|
826
|
+
normalizedText: normalizedText.substring(0, 30),
|
|
827
|
+
shouldRecordAll,
|
|
828
|
+
foldInGroup,
|
|
829
|
+
dedupInGroup,
|
|
830
|
+
shouldRecordLimited,
|
|
831
|
+
inRecordGroups: recordGroups.size === 0 || recordGroups.has(gid),
|
|
832
|
+
shouldRecord
|
|
833
|
+
});
|
|
810
834
|
if (shouldRecord && normalizedText) {
|
|
811
835
|
try {
|
|
812
836
|
await ctx.database.create("lili_message", { gid, userId: session.userId, userName: session.username || session.userId, content: normalizedText, timestamp: Date.now(), messageId: session.messageId || "" });
|
|
813
|
-
|
|
837
|
+
dbg("\u6D88\u606F\u5DF2\u5165\u5E93", { gid, userId: session.userId, contentLen: normalizedText.length, messageId: session.messageId });
|
|
838
|
+
} catch (e) {
|
|
839
|
+
dbg("\u6D88\u606F\u5165\u5E93\u5931\u8D25", { gid, error: String(e) });
|
|
814
840
|
}
|
|
815
841
|
}
|
|
816
842
|
if (config.imitation.enabled && isGroupAllowed(gid, config.imitation.groups)) {
|