Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/discord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,10 @@ impl Handler {
};

// Both cached → skip fetch entirely
if cached_involved && cached_multibot {
return (true, true);
}
// Involved cached + not MultibotMentions mode → don't need other_bot info
if cached_involved && self.allow_user_messages != AllowUsers::MultibotMentions {
return (true, false);
// With early detection from msg.author, multibot_threads is populated
// eagerly — no need to fetch just to check for other bots.
if cached_involved {
return (true, cached_multibot);
}

// Fetch recent messages
Expand Down Expand Up @@ -321,6 +319,14 @@ impl EventHandler for Handler {
return;
}

// Early multibot detection: if the current message is from another bot,
// this thread is multi-bot. Cache it now — no fetch needed.
if in_thread && msg.author.bot && msg.author.id != bot_id {
let key = msg.channel_id.to_string();
let mut cache = self.multibot_threads.lock().await;
cache.entry(key).or_insert_with(tokio::time::Instant::now);
}

// User message gating (mirrors Slack's AllowUsers logic).
// Mentions: always require @mention, even in bot's own threads.
// Involved (default): skip @mention if the bot owns the thread
Expand Down
Loading