Don't require spaceapi to be available immediately on startup
Important because homeassistant is slow as hell
This commit is contained in:
parent
ff505e98ae
commit
c2b4ab9383
1 changed files with 4 additions and 4 deletions
|
@ -89,7 +89,7 @@ pub struct Bot {
|
||||||
|
|
||||||
client: Client,
|
client: Client,
|
||||||
api: ItsApi,
|
api: ItsApi,
|
||||||
open_state: Mutex<OpenState>,
|
open_state: Mutex<Option<OpenState>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Bot {
|
impl Bot {
|
||||||
|
@ -123,7 +123,7 @@ impl Bot {
|
||||||
config.space.spaceping_url.clone(),
|
config.space.spaceping_url.clone(),
|
||||||
config.space.spaceping_token.clone(),
|
config.space.spaceping_token.clone(),
|
||||||
);
|
);
|
||||||
let open_state = get_open_state(&api).await?;
|
let open_state = get_open_state(&api).await.ok();
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
config,
|
config,
|
||||||
|
@ -146,7 +146,7 @@ impl Bot {
|
||||||
#[instrument(skip(self))]
|
#[instrument(skip(self))]
|
||||||
async fn update_open_state(&self) -> Result<OpenState> {
|
async fn update_open_state(&self) -> Result<OpenState> {
|
||||||
let new_state = get_open_state(&self.api).await?;
|
let new_state = get_open_state(&self.api).await?;
|
||||||
if new_state != *self.open_state.lock().unwrap() {
|
if *self.open_state.lock().unwrap() != Some(new_state) {
|
||||||
let message = if let OpenState::Open { .. } = new_state {
|
let message = if let OpenState::Open { .. } = new_state {
|
||||||
"opening IT-Syndikat - Ohai!"
|
"opening IT-Syndikat - Ohai!"
|
||||||
} else {
|
} else {
|
||||||
|
@ -159,7 +159,7 @@ impl Bot {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*self.open_state.lock().unwrap() = new_state;
|
*self.open_state.lock().unwrap() = Some(new_state);
|
||||||
Ok(new_state)
|
Ok(new_state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue