diff --git a/src/bots/approved_bot/modules/download.rs b/src/bots/approved_bot/modules/download.rs index 821e258..2c51e8f 100644 --- a/src/bots/approved_bot/modules/download.rs +++ b/src/bots/approved_bot/modules/download.rs @@ -128,23 +128,23 @@ impl FromStr for DownloadQueryData { } #[derive(Clone, EnumIter)] -pub enum DownloadArchiveCommands { - Sequence { id: u32, file_format: String }, - Author { id: u32, file_format: String }, - Translator { id: u32, file_format: String } +pub enum DownloadArchiveCommand { + Sequence { id: u32}, + Author { id: u32 }, + Translator { id: u32 } } -impl ToString for DownloadArchiveCommands { +impl ToString for DownloadArchiveCommand { fn to_string(&self) -> String { match self { - DownloadArchiveCommands::Sequence { id, file_format } => format!("da_s_{id}_{file_format}"), - DownloadArchiveCommands::Author { id, file_format } => format!("da_a_{id}_{file_format}"), - DownloadArchiveCommands::Translator { id, file_format } => format!("da_t_{id}_{file_format}"), + DownloadArchiveCommand::Sequence { id } => format!("da_s_{id}"), + DownloadArchiveCommand::Author { id } => format!("da_a_{id}"), + DownloadArchiveCommand::Translator { id } => format!("da_t_{id}"), } } } -impl FromStr for DownloadArchiveCommands { +impl FromStr for DownloadArchiveCommand { type Err = strum::ParseError; fn from_str(s: &str) -> Result { @@ -160,9 +160,9 @@ impl FromStr for DownloadArchiveCommands { let file_type: String = caps["file_type"].to_string(); match &caps["type"] { - "s" => Ok(DownloadArchiveCommands::Sequence { id: obj_id, file_format: file_type }), - "a" => Ok(DownloadArchiveCommands::Author { id: obj_id, file_format: file_type }), - "t" => Ok(DownloadArchiveCommands::Translator { id: obj_id, file_format: file_type }), + "s" => Ok(DownloadArchiveCommand::Sequence { id: obj_id }), + "a" => Ok(DownloadArchiveCommand::Author { id: obj_id }), + "t" => Ok(DownloadArchiveCommand::Translator { id: obj_id }), _ => Err(strum::ParseError::VariantNotFound) } } diff --git a/src/bots/approved_bot/services/book_library/formaters.rs b/src/bots/approved_bot/services/book_library/formaters.rs index 67a542c..c22b533 100644 --- a/src/bots/approved_bot/services/book_library/formaters.rs +++ b/src/bots/approved_bot/services/book_library/formaters.rs @@ -1,6 +1,6 @@ use std::cmp::min; -use crate::bots::approved_bot::modules::download::StartDownloadCommand; +use crate::bots::approved_bot::modules::download::{StartDownloadCommand, DownloadArchiveCommand}; use super::types::{ Author, AuthorBook, Book, BookAuthor, BookGenre, SearchBook, Sequence, Translator, @@ -48,7 +48,9 @@ impl FormatTitle for BookAuthor { return "".to_string() } - format!("👤 {last_name} {first_name} {middle_name}") + let command = (DownloadArchiveCommand::Author { id: *id }).to_string(); + + format!("👤 {last_name} {first_name} {middle_name}\n{command}") } } @@ -65,7 +67,9 @@ impl FormatTitle for BookTranslator { return "".to_string() } - format!("👤 {last_name} {first_name} {middle_name}") + let command = (DownloadArchiveCommand::Translator { id: *id }).to_string(); + + format!("👤 {last_name} {first_name} {middle_name}\n{command}") } } @@ -77,7 +81,9 @@ impl FormatTitle for Sequence { return "".to_string() } - format!("📚 {name}") + let command = (DownloadArchiveCommand::Sequence { id: *id }).to_string(); + + format!("📚 {name}\n{command}") } }