Fix getFile timeouts

This commit is contained in:
2024-05-08 20:36:20 +02:00
parent b944a9e724
commit bd62f1b076

View File

@@ -1,7 +1,7 @@
use std::sync::{
use std::{sync::{
atomic::{AtomicUsize, Ordering},
Arc,
};
}, time::Duration};
use once_cell::sync::Lazy;
use teloxide::Bot;
@@ -23,8 +23,18 @@ impl RoundRobinBot {
pub fn get_bot(&self) -> Bot {
let index = self.current_index.fetch_add(1, Ordering::Relaxed) % self.bot_tokens.len();
Bot::new(self.bot_tokens[index].clone())
.set_api_url(reqwest::Url::parse(CONFIG.telegram_api_url.as_str()).unwrap())
let client = reqwest::Client::builder()
.connect_timeout(Duration::from_secs(5))
.timeout(Duration::from_secs(5 * 60))
.tcp_nodelay(true)
.build()
.unwrap();
Bot::with_client(
self.bot_tokens[index].clone(),
client
).set_api_url(reqwest::Url::parse(CONFIG.telegram_api_url.as_str()).unwrap())
}
}