From 57d25a26536fd9ee76836eacaa424dbf1629a9fa Mon Sep 17 00:00:00 2001 From: Izzy Swart Date: Mon, 5 Jul 2021 20:09:18 -0700 Subject: [PATCH] save chat ref --- src/main.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 049e6a0..77f0fc2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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> { 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();