feat(message-capture): add bot exclusion logic for message capture
This commit is contained in:
@@ -35,6 +35,13 @@ export interface MessageLocationInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const EXCLUDED_CHANNEL_IDS = new Set(config.EXCLUDED_CHANNEL_IDS);
|
const EXCLUDED_CHANNEL_IDS = new Set(config.EXCLUDED_CHANNEL_IDS);
|
||||||
|
const BOT_EXCLUDED_CHANNEL_IDS = new Set(config.BOT_EXCLUDED_CHANNEL_IDS);
|
||||||
|
|
||||||
|
function isBotExcludedChannel(message: Message): boolean {
|
||||||
|
if (!message.author?.bot) return false;
|
||||||
|
const id = getParentChannelId(message) ?? message.channelId;
|
||||||
|
return id != null && BOT_EXCLUDED_CHANNEL_IDS.has(id);
|
||||||
|
}
|
||||||
const EXCLUDED_THREAD_IDS = new Set(config.EXCLUDED_THREAD_IDS);
|
const EXCLUDED_THREAD_IDS = new Set(config.EXCLUDED_THREAD_IDS);
|
||||||
|
|
||||||
function isExcludedThread(message: {
|
function isExcludedThread(message: {
|
||||||
@@ -274,6 +281,7 @@ export function registerMessageCapture(client: Client): void {
|
|||||||
|
|
||||||
client.on("messageCreate", async (message) => {
|
client.on("messageCreate", async (message) => {
|
||||||
if (!shouldCaptureForAnyTarget(message, targets)) return;
|
if (!shouldCaptureForAnyTarget(message, targets)) return;
|
||||||
|
if (isBotExcludedChannel(message)) return;
|
||||||
if (isAgeRestrictedMessage(message)) return;
|
if (isAgeRestrictedMessage(message)) return;
|
||||||
if (isExcludedThread(message)) return;
|
if (isExcludedThread(message)) return;
|
||||||
|
|
||||||
@@ -292,6 +300,7 @@ export function registerMessageCapture(client: Client): void {
|
|||||||
|
|
||||||
client.on("messageUpdate", async (_oldMessage, newMessage) => {
|
client.on("messageUpdate", async (_oldMessage, newMessage) => {
|
||||||
if (!shouldCaptureForAnyTarget(newMessage, targets)) return;
|
if (!shouldCaptureForAnyTarget(newMessage, targets)) return;
|
||||||
|
if (isBotExcludedChannel(newMessage as Message)) return;
|
||||||
if (isAgeRestrictedMessage(newMessage as Message)) return;
|
if (isAgeRestrictedMessage(newMessage as Message)) return;
|
||||||
if (isExcludedThread(newMessage)) return;
|
if (isExcludedThread(newMessage)) return;
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,13 @@ export const configSchema = z
|
|||||||
.default("")
|
.default("")
|
||||||
.transform((v) => v.split(",").filter(Boolean))
|
.transform((v) => v.split(",").filter(Boolean))
|
||||||
.describe("Thread IDs to exclude from capture"),
|
.describe("Thread IDs to exclude from capture"),
|
||||||
|
BOT_EXCLUDED_CHANNEL_IDS: z
|
||||||
|
.string()
|
||||||
|
.default("1206269771340058694")
|
||||||
|
.transform((v) => v.split(",").filter(Boolean))
|
||||||
|
.describe(
|
||||||
|
"Channel IDs where bot messages are NOT captured/analyzed (bot detection stays on everywhere else)",
|
||||||
|
),
|
||||||
|
|
||||||
// ── Legacy voice ─────────────────────────────────────────────────────
|
// ── Legacy voice ─────────────────────────────────────────────────────
|
||||||
VOICE_GUILD_ID: z.string().min(1).optional(),
|
VOICE_GUILD_ID: z.string().min(1).optional(),
|
||||||
|
|||||||
Reference in New Issue
Block a user