use crate::account::AccountInfo;
use crate::adapter::{AdapterApi, AdapterInfo, Result, SendMsgType};
use crate::contact::ContactType;
use crate::element::Message;
#[derive(Clone)]
pub enum BotId {
Index(u64),
SelfId(String),
}
impl From<u64> for BotId {
fn from(index: u64) -> Self {
Self::Index(index)
}
}
impl From<&str> for BotId {
fn from(self_id: &str) -> Self {
Self::SelfId(self_id.to_string())
}
}
impl From<String> for BotId {
fn from(self_id: String) -> Self {
Self::SelfId(self_id)
}
}
#[derive(Clone)]
pub struct Bot {
pub adapter: AdapterInfo,
pub api: &'static dyn AdapterApi,
pub account: AccountInfo,
}
impl Bot {
pub async fn send_msg(&self, contact: ContactType, message: Message) -> Result<SendMsgType> {
self.api.send_msg(contact, message).await
}
}