use std::sync::Arc;
use slack_morphism::prelude::SlackHyperClient;
use super::SlackState;
impl SlackState {
pub async fn set_connected(
&self,
client: Arc<SlackHyperClient>,
bot_token: String,
channel_id: Option<String>,
) {
*self.client.lock().await = Some(client);
*self.bot_token.lock().await = Some(bot_token);
if let Some(id) = channel_id {
*self.owner_channel_id.lock().await = Some(id);
}
}
pub async fn set_owner_channel(&self, channel_id: String) {
*self.owner_channel_id.lock().await = Some(channel_id);
}
pub async fn client(&self) -> Option<Arc<SlackHyperClient>> {
self.client.lock().await.clone()
}
pub async fn bot_token(&self) -> Option<String> {
self.bot_token.lock().await.clone()
}
pub async fn owner_channel_id(&self) -> Option<String> {
self.owner_channel_id.lock().await.clone()
}
pub async fn is_connected(&self) -> bool {
self.client.lock().await.is_some()
}
}