use crate::{Client, types::*};
#[derive(Clone)]
pub struct OfficialClient {
core: Client,
}
impl OfficialClient {
pub fn new(core: Client) -> Self {
Self { core }
}
pub fn message(&self) -> MessageApi {
MessageApi::new(self.core.clone())
}
}
pub struct MessageApi {
core: Client,
to_user: Option<String>,
msg_type: Option<String>,
content: Option<String>,
}
impl MessageApi {
pub fn new(core: Client) -> Self {
Self {
core,
to_user: None,
msg_type: None,
content: None,
}
}
pub fn to<S: Into<String>>(mut self, openid: S) -> Self {
self.to_user = Some(openid.into());
self
}
pub fn text<S: Into<String>>(mut self, text: S) -> Self {
self.msg_type = Some("text".to_string());
self.content = Some(text.into());
self
}
pub async fn send(self) -> crate::Result<()> {
tracing::info!("Sending message to {:?}: {:?}", self.to_user, self.content);
Ok(())
}
}