use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use tokio::sync::mpsc;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IncomingMessage {
pub id: String,
pub sender_id: String,
pub sender_name: Option<String>,
pub chat_id: String,
pub text: String,
pub is_group: bool,
pub reply_to: Option<String>,
pub timestamp: chrono::DateTime<chrono::Utc>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OutgoingMessage {
pub chat_id: String,
pub text: String,
pub reply_to: Option<String>,
}
#[async_trait]
pub trait Channel: Send + Sync {
fn name(&self) -> &str;
async fn start(&mut self) -> anyhow::Result<mpsc::Receiver<IncomingMessage>>;
async fn send(&self, message: OutgoingMessage) -> anyhow::Result<Option<String>>;
async fn send_typing(&self, _chat_id: &str) -> anyhow::Result<()> {
Ok(())
}
async fn edit(&self, _chat_id: &str, _message_id: &str, _new_text: &str) -> anyhow::Result<()> {
Ok(())
}
fn supports_draft_updates(&self) -> bool {
false
}
async fn send_draft(&self, _chat_id: &str, _text: &str) -> anyhow::Result<Option<String>> {
Ok(None)
}
async fn update_draft_progress(
&self,
_chat_id: &str,
_message_id: &str,
_text: &str,
) -> anyhow::Result<()> {
Ok(())
}
async fn finalize_draft(
&self,
_chat_id: &str,
_message_id: &str,
_text: &str,
) -> anyhow::Result<()> {
Ok(())
}
async fn stop(&mut self) -> anyhow::Result<()>;
}