mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 01:52:44 +00:00
This commit is contained in:
@@ -358,9 +358,13 @@ export async function preflightDiscordMessage(
|
||||
);
|
||||
const hasAnyMention = Boolean(
|
||||
!isDirectMessage &&
|
||||
(message.mentionedEveryone ||
|
||||
(message.mentionedUsers?.length ?? 0) > 0 ||
|
||||
(message.mentionedRoles?.length ?? 0) > 0),
|
||||
((message.mentionedUsers?.length ?? 0) > 0 ||
|
||||
(message.mentionedRoles?.length ?? 0) > 0 ||
|
||||
(message.mentionedEveryone && (!author.bot || sender.isPluralKit))),
|
||||
);
|
||||
const hasUserOrRoleMention = Boolean(
|
||||
!isDirectMessage &&
|
||||
((message.mentionedUsers?.length ?? 0) > 0 || (message.mentionedRoles?.length ?? 0) > 0),
|
||||
);
|
||||
|
||||
if (
|
||||
@@ -429,7 +433,7 @@ export async function preflightDiscordMessage(
|
||||
const channelMatchMeta = formatAllowlistMatchMeta(channelConfig);
|
||||
if (shouldLogVerbose()) {
|
||||
const channelConfigSummary = channelConfig
|
||||
? `allowed=${channelConfig.allowed} enabled=${channelConfig.enabled ?? "unset"} requireMention=${channelConfig.requireMention ?? "unset"} matchKey=${channelConfig.matchKey ?? "none"} matchSource=${channelConfig.matchSource ?? "none"} users=${channelConfig.users?.length ?? 0} roles=${channelConfig.roles?.length ?? 0} skills=${channelConfig.skills?.length ?? 0}`
|
||||
? `allowed=${channelConfig.allowed} enabled=${channelConfig.enabled ?? "unset"} requireMention=${channelConfig.requireMention ?? "unset"} ignoreOtherMentions=${channelConfig.ignoreOtherMentions ?? "unset"} matchKey=${channelConfig.matchKey ?? "none"} matchSource=${channelConfig.matchSource ?? "none"} users=${channelConfig.users?.length ?? 0} roles=${channelConfig.roles?.length ?? 0} skills=${channelConfig.skills?.length ?? 0}`
|
||||
: "none";
|
||||
logDebug(
|
||||
`[discord-preflight] channelConfig=${channelConfigSummary} channelMatchMeta=${channelMatchMeta} channelId=${messageChannelId}`,
|
||||
@@ -644,6 +648,28 @@ export async function preflightDiscordMessage(
|
||||
}
|
||||
}
|
||||
|
||||
const ignoreOtherMentions =
|
||||
channelConfig?.ignoreOtherMentions ?? guildInfo?.ignoreOtherMentions ?? false;
|
||||
if (
|
||||
isGuildMessage &&
|
||||
ignoreOtherMentions &&
|
||||
hasUserOrRoleMention &&
|
||||
!wasMentioned &&
|
||||
!implicitMention
|
||||
) {
|
||||
logDebug(`[discord-preflight] drop: other-mention`);
|
||||
logVerbose(
|
||||
`discord: drop guild message (another user/role mentioned, ignoreOtherMentions=true, botId=${botId})`,
|
||||
);
|
||||
recordPendingHistoryEntryIfEnabled({
|
||||
historyMap: params.guildHistories,
|
||||
historyKey: messageChannelId,
|
||||
limit: params.historyLimit,
|
||||
entry: historyEntry ?? null,
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isGuildMessage && hasAccessRestrictions && !memberAllowed) {
|
||||
logDebug(`[discord-preflight] drop: member not allowed`);
|
||||
logVerbose(`Blocked discord guild sender ${sender.id} (not in users/roles allowlist)`);
|
||||
|
||||
Reference in New Issue
Block a user