save chat ref
This commit is contained in:
parent
7c5c2033a8
commit
57d25a2653
15
src/main.rs
15
src/main.rs
|
@ -7,7 +7,7 @@ use mammut::{
|
||||||
Mastodon, Registration,
|
Mastodon, Registration,
|
||||||
};
|
};
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use telegram_bot::{Api, ChatRef};
|
use telegram_bot::{Api, ChatId, ChatRef, ToChatRef};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
publish::MastodonPublisher,
|
publish::MastodonPublisher,
|
||||||
|
@ -69,9 +69,16 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
let api = Arc::new(Api::new(cfg.bot_token.clone()));
|
let api = Arc::new(Api::new(cfg.bot_token.clone()));
|
||||||
|
|
||||||
let chat = get_chat_ref(api.clone(), None)
|
let chat = get_chat_ref(
|
||||||
.await
|
api.clone(),
|
||||||
.expect("could not get chat ref");
|
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();
|
let chat_ref = chat.lock().await.clone();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue