Files
daily_bot/src/bot/define.rs
T
2026-04-07 09:33:56 +08:00

55 lines
1.3 KiB
Rust

use tokio::task::JoinHandle;
use anyhow::Result;
use async_trait::async_trait;
#[async_trait]
pub trait Sender {
async fn send(&self, message: OutboundMessage) -> Result<String>;
}
#[async_trait]
pub trait Receiver {
async fn recv(&self, msg: InboundMessage) -> Result<()>;
}
#[derive(Debug, Clone)]
pub struct OutboundMessage {
pub channel_id: String,
pub text: String,
pub reply_to_event_id: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct InboundMessage {
pub event_id: String,
pub channel_id: String,
pub user_id: String,
pub text: String,
pub timestamp_ms: u64,
}
#[derive(Debug, Clone, Default)]
pub struct InputBatch {
pub messages: Vec<InboundMessage>,
pub next_cursor: Option<String>,
}
#[async_trait]
pub trait AttendanceHandler {
async fn handle_commands(&self) -> Result<JoinHandle<()>>;
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum MessageEnum {
MatrixMessage(InboundMessage),
TelegramMessage(InboundMessage),
StopMessage,
}
#[async_trait]
pub trait Bot {
async fn start(&self) -> Result<()>;
async fn join_rooms(&self) -> Result<()>;
async fn send_raw_message(&self, room_id: &str, message: &OutboundMessage) -> Result<String>;
}