mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 15:35:35 +01:00
Add download archive command handler
This commit is contained in:
@@ -2,7 +2,7 @@ use base64::{engine::general_purpose, Engine};
|
||||
use reqwest::StatusCode;
|
||||
use std::fmt;
|
||||
|
||||
use crate::{bots::approved_bot::modules::download::DownloadDataCommand, config};
|
||||
use crate::{config, bots::approved_bot::modules::download::DownloadQueryData};
|
||||
|
||||
use self::types::{CachedMessage, DownloadFile};
|
||||
|
||||
@@ -22,9 +22,9 @@ impl fmt::Display for DownloadError {
|
||||
impl std::error::Error for DownloadError {}
|
||||
|
||||
pub async fn get_cached_message(
|
||||
download_data: &DownloadDataCommand,
|
||||
download_data: &DownloadQueryData,
|
||||
) -> Result<CachedMessage, Box<dyn std::error::Error + Send + Sync>> {
|
||||
let DownloadDataCommand { format, id } = download_data;
|
||||
let DownloadQueryData::DownloadData { book_id: id, file_type: format } = download_data;
|
||||
|
||||
let client = reqwest::Client::new();
|
||||
let response = client
|
||||
@@ -47,9 +47,9 @@ pub async fn get_cached_message(
|
||||
}
|
||||
|
||||
pub async fn download_file(
|
||||
download_data: &DownloadDataCommand,
|
||||
download_data: &DownloadQueryData,
|
||||
) -> Result<DownloadFile, Box<dyn std::error::Error + Send + Sync>> {
|
||||
let DownloadDataCommand { format, id } = download_data;
|
||||
let DownloadQueryData::DownloadData { book_id: id, file_type: format } = download_data;
|
||||
|
||||
let response = reqwest::Client::new()
|
||||
.get(format!(
|
||||
|
||||
Reference in New Issue
Block a user