Compare commits

..

No commits in common. "76dfd825f35c0af6e046c7408632918c2347898e" and "9993e52e0d619585ad054f67a7275857866a40c0" have entirely different histories.

2 changed files with 22 additions and 15 deletions

View File

@ -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()

View File

@ -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
);
}
}