refactor(instagram): organize files

This commit is contained in:
2025-09-19 18:26:36 +03:00
parent bae194b2bf
commit a7e5d43423
8 changed files with 354 additions and 162 deletions

28
src/handlers/mod.rs Normal file
View File

@@ -0,0 +1,28 @@
mod instagram;
use crate::error::Result;
use teloxide::{Bot, types::ChatId};
#[async_trait::async_trait]
pub trait SocialHandler: Send + Sync {
/// Short name used for logging etc.
fn name(&self) -> &'static str;
/// Try to extract a platform-specific identifier (shortcode, id, url)
/// from arbitrary text. Return `Some` if the handler should handle this message.
fn try_extract(&self, text: &str) -> Option<String>;
/// Do the heavy-lifting: fetch media and send to `chat_id`.
async fn handle(&self, bot: &Bot, chat_id: ChatId, id: String) -> Result<()>;
/// Clone a boxed handler.
fn box_clone(&self) -> Box<dyn SocialHandler>;
}
impl Clone for Box<dyn SocialHandler> {
fn clone(&self) -> Self {
self.box_clone()
}
}
pub use instagram::InstagramHandler;