Add download archive command handler

This commit is contained in:
2023-06-07 17:28:56 +02:00
parent bdd7c9b2d8
commit fcc4b9dfe2
4 changed files with 69 additions and 81 deletions

View File

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