save chat ref

This commit is contained in:
Izzy Swart 2021-07-05 20:09:18 -07:00
parent 7c5c2033a8
commit 57d25a2653
1 changed files with 11 additions and 4 deletions

View File

@ -7,7 +7,7 @@ use mammut::{
Mastodon, Registration,
};
use rand::Rng;
use telegram_bot::{Api, ChatRef};
use telegram_bot::{Api, ChatId, ChatRef, ToChatRef};
use crate::{
publish::MastodonPublisher,
@ -69,9 +69,16 @@ async fn main() -> Result<(), Box<dyn Error>> {
let api = Arc::new(Api::new(cfg.bot_token.clone()));
let chat = get_chat_ref(api.clone(), None)
.await
.expect("could not get chat ref");
let chat = get_chat_ref(
api.clone(),
if ChatId::new(0) == cfg.chat_ref {
None
} else {
Some(cfg.chat_ref.clone().to_chat_ref())
},
)
.await
.expect("could not get chat ref");
let chat_ref = chat.lock().await.clone();