Compare commits
No commits in common. "76dfd825f35c0af6e046c7408632918c2347898e" and "9993e52e0d619585ad054f67a7275857866a40c0" have entirely different histories.
76dfd825f3
...
9993e52e0d
15
src/main.rs
15
src/main.rs
|
@ -4,7 +4,8 @@ mod utils;
|
|||
mod workers;
|
||||
use grammers_client::{types::chat::PackedChat, Client, Config, InputMessage, Update};
|
||||
use grammers_session::Session;
|
||||
use rand::{thread_rng, Rng};
|
||||
use grammers_tl_types::functions::Ping;
|
||||
use rand::{random, thread_rng, Rng};
|
||||
use regex::Regex;
|
||||
use reqwest::ClientBuilder;
|
||||
use std::collections::{HashSet, VecDeque};
|
||||
|
@ -59,6 +60,18 @@ async fn async_main() {
|
|||
eprintln!("Failed to save session: {:?}", err);
|
||||
}
|
||||
}
|
||||
{
|
||||
let tclient = tclient.clone();
|
||||
tokio::task::spawn(async move {
|
||||
loop {
|
||||
let ping_id = random();
|
||||
if let Err(err) = tclient.invoke(&Ping { ping_id }).await {
|
||||
eprintln!("Failed to ping Telegram: {:?}", err);
|
||||
}
|
||||
sleep(Duration::from_secs(60)).await;
|
||||
}
|
||||
});
|
||||
}
|
||||
if config::STORAGE_CHAT.is_none() {
|
||||
while let Some(update) = tclient
|
||||
.next_update()
|
||||
|
|
|
@ -679,40 +679,34 @@ pub async fn upload_worker(
|
|||
.mime_type("video/x-matroska")
|
||||
.file(uploaded);
|
||||
if let Err(err) = tclient.send_message(&chat, message).await {
|
||||
eprintln!("Failed to send video {}: {:?}", &video_id, err);
|
||||
eprintln!("Failed to send video: {:?}", err);
|
||||
if let Err(err) = tclient
|
||||
.send_message(
|
||||
&chat,
|
||||
InputMessage::text(&format!(
|
||||
"Failed to send video {}, see logs",
|
||||
&video_id
|
||||
)),
|
||||
InputMessage::text("Failed to send video, see logs"),
|
||||
)
|
||||
.await
|
||||
{
|
||||
eprintln!(
|
||||
"Failed to send message about failing to send video {}: {:?}",
|
||||
&video_id, err
|
||||
"Failed to send message about failing to send video: {:?}",
|
||||
err
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
success = false;
|
||||
eprintln!("Failed to upload video {}: {:?}", &video_id, err);
|
||||
eprintln!("Failed to upload video: {:?}", err);
|
||||
if let Err(err) = tclient
|
||||
.send_message(
|
||||
&chat,
|
||||
InputMessage::text(&format!(
|
||||
"Failed to upload video {}, see logs",
|
||||
&video_id
|
||||
)),
|
||||
InputMessage::text("Failed to upload video, see logs"),
|
||||
)
|
||||
.await
|
||||
{
|
||||
eprintln!(
|
||||
"Failed to send message about failing to upload video {}: {:?}",
|
||||
&video_id, err
|
||||
"Failed to send message about failing to upload video: {:?}",
|
||||
err
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue