mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 15:35:35 +01:00
Update archive downloading
This commit is contained in:
@@ -22,8 +22,7 @@ use crate::{
|
|||||||
approved_bot::{
|
approved_bot::{
|
||||||
modules::download::callback_data::DownloadArchiveQueryData,
|
modules::download::callback_data::DownloadArchiveQueryData,
|
||||||
services::{
|
services::{
|
||||||
batch_downloader::{create_task, get_task, Task, TaskStatus},
|
batch_downloader::{create_task, get_task, CreateTaskData, Task, TaskObjectType, TaskStatus},
|
||||||
batch_downloader::{CreateTaskData, TaskObjectType},
|
|
||||||
book_cache::{
|
book_cache::{
|
||||||
download_file, download_file_by_link, get_cached_message, get_download_link,
|
download_file, download_file_by_link, get_cached_message, get_download_link,
|
||||||
types::{CachedMessage, DownloadFile},
|
types::{CachedMessage, DownloadFile},
|
||||||
@@ -39,7 +38,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
BotHandlerInternal,
|
BotHandlerInternal,
|
||||||
},
|
},
|
||||||
bots_manager::BotCache,
|
bots_manager::BotCache, config,
|
||||||
};
|
};
|
||||||
|
|
||||||
use self::{
|
use self::{
|
||||||
@@ -339,13 +338,19 @@ async fn send_archive_link(
|
|||||||
message: Message,
|
message: Message,
|
||||||
task: Task,
|
task: Task,
|
||||||
) -> BotHandlerInternal {
|
) -> BotHandlerInternal {
|
||||||
|
let link = format!(
|
||||||
|
"{}/api/download/{}",
|
||||||
|
config::CONFIG.batch_downloader_url.clone(),
|
||||||
|
task.id
|
||||||
|
);
|
||||||
|
|
||||||
bot.edit_message_text(
|
bot.edit_message_text(
|
||||||
message.chat.id,
|
message.chat.id,
|
||||||
message.id,
|
message.id,
|
||||||
format!(
|
format!(
|
||||||
"Файл не может быть загружен в чат! \n \
|
"Файл не может быть загружен в чат! \n \
|
||||||
Вы можете скачать его <a href=\"{}\">по ссылке</a> (работает 3 часа)",
|
Вы можете скачать его <a href=\"{}\">по ссылке</a> (работает 3 часа)",
|
||||||
task.result_link.unwrap()
|
link
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.parse_mode(ParseMode::Html)
|
.parse_mode(ParseMode::Html)
|
||||||
@@ -407,9 +412,15 @@ async fn wait_archive(
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let link = format!(
|
||||||
|
"{}/api/download/{}",
|
||||||
|
config::CONFIG.batch_downloader_url.clone(),
|
||||||
|
task.id
|
||||||
|
);
|
||||||
|
|
||||||
let downloaded_data = match download_file_by_link(
|
let downloaded_data = match download_file_by_link(
|
||||||
task.clone().result_filename.unwrap(),
|
task.clone().result_filename.unwrap(),
|
||||||
task.result_internal_link.clone().unwrap(),
|
link,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,8 +37,6 @@ pub struct Task {
|
|||||||
pub status_description: String,
|
pub status_description: String,
|
||||||
pub error_message: Option<String>,
|
pub error_message: Option<String>,
|
||||||
pub result_filename: Option<String>,
|
pub result_filename: Option<String>,
|
||||||
pub result_link: Option<String>,
|
|
||||||
pub result_internal_link: Option<String>,
|
|
||||||
pub content_size: Option<u64>,
|
pub content_size: Option<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user