use tracing::warn;
use super::{DynamicBot, DynamicBotStore};
pub async fn check_bot_exists(
state: &dyn DynamicBotStore,
channel_type: &str,
bot_token: &str,
) -> Result<bool, String> {
match state.get_dynamic_bots().await {
Ok(bots) => Ok(bots
.iter()
.any(|b| b.channel_type == channel_type && b.bot_token == bot_token)),
Err(e) => {
warn!("Failed to check existing bots: {}", e);
Ok(false)
}
}
}
pub async fn persist_dynamic_bot(
state: &dyn DynamicBotStore,
new_bot: &DynamicBot,
) -> Result<i64, String> {
state
.add_dynamic_bot(new_bot)
.await
.map_err(|e| format!("Failed to save bot configuration: {}", e))
}
pub async fn list_dynamic_bots(state: &dyn DynamicBotStore) -> Result<Vec<DynamicBot>, String> {
state
.get_dynamic_bots()
.await
.map_err(|e| format!("Failed to list bots: {}", e))
}