diff --git a/src/commands/bot.rs b/src/commands/bot.rs index 7f20dc5..73f69a0 100644 --- a/src/commands/bot.rs +++ b/src/commands/bot.rs @@ -517,6 +517,12 @@ async fn poll_once( new_items.reverse(); for notif in &new_items { + // Mark as processed immediately to prevent duplicate replies + state.processed.insert(notif.uri.clone()); + if let Err(e) = save_state(state) { + eprintln!("bot: failed to save state: {}", e); + } + eprintln!( "bot: processing notification from @{}: {}", notif.author_handle, @@ -568,10 +574,6 @@ async fn poll_once( { Ok(result) => { eprintln!("bot: replied -> {}", result.uri); - state.processed.insert(notif.uri.clone()); - if let Err(e) = save_state(state) { - eprintln!("bot: failed to save state: {}", e); - } } Err(e) => { eprintln!("bot: reply failed for {}: {}", notif.uri, e); diff --git a/src/rules/bot.md b/src/rules/bot.md index 5a19ac8..5f5b7e5 100644 --- a/src/rules/bot.md +++ b/src/rules/bot.md @@ -37,3 +37,4 @@ After replying to a conversation, you may post your own thoughts using the `post - Stay in character. The post should sound like you, not a summary. - Keep posts short (under 300 characters). - Do NOT repeat or quote the user's message. Share your own perspective. +- Call post_create only ONCE. Never call it twice.