mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 15:35:35 +01:00
Add commands to title
This commit is contained in:
@@ -128,23 +128,23 @@ impl FromStr for DownloadQueryData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, EnumIter)]
|
#[derive(Clone, EnumIter)]
|
||||||
pub enum DownloadArchiveCommands {
|
pub enum DownloadArchiveCommand {
|
||||||
Sequence { id: u32, file_format: String },
|
Sequence { id: u32},
|
||||||
Author { id: u32, file_format: String },
|
Author { id: u32 },
|
||||||
Translator { id: u32, file_format: String }
|
Translator { id: u32 }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToString for DownloadArchiveCommands {
|
impl ToString for DownloadArchiveCommand {
|
||||||
fn to_string(&self) -> String {
|
fn to_string(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
DownloadArchiveCommands::Sequence { id, file_format } => format!("da_s_{id}_{file_format}"),
|
DownloadArchiveCommand::Sequence { id } => format!("da_s_{id}"),
|
||||||
DownloadArchiveCommands::Author { id, file_format } => format!("da_a_{id}_{file_format}"),
|
DownloadArchiveCommand::Author { id } => format!("da_a_{id}"),
|
||||||
DownloadArchiveCommands::Translator { id, file_format } => format!("da_t_{id}_{file_format}"),
|
DownloadArchiveCommand::Translator { id } => format!("da_t_{id}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for DownloadArchiveCommands {
|
impl FromStr for DownloadArchiveCommand {
|
||||||
type Err = strum::ParseError;
|
type Err = strum::ParseError;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
@@ -160,9 +160,9 @@ impl FromStr for DownloadArchiveCommands {
|
|||||||
let file_type: String = caps["file_type"].to_string();
|
let file_type: String = caps["file_type"].to_string();
|
||||||
|
|
||||||
match &caps["type"] {
|
match &caps["type"] {
|
||||||
"s" => Ok(DownloadArchiveCommands::Sequence { id: obj_id, file_format: file_type }),
|
"s" => Ok(DownloadArchiveCommand::Sequence { id: obj_id }),
|
||||||
"a" => Ok(DownloadArchiveCommands::Author { id: obj_id, file_format: file_type }),
|
"a" => Ok(DownloadArchiveCommand::Author { id: obj_id }),
|
||||||
"t" => Ok(DownloadArchiveCommands::Translator { id: obj_id, file_format: file_type }),
|
"t" => Ok(DownloadArchiveCommand::Translator { id: obj_id }),
|
||||||
_ => Err(strum::ParseError::VariantNotFound)
|
_ => Err(strum::ParseError::VariantNotFound)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
|
|
||||||
use crate::bots::approved_bot::modules::download::StartDownloadCommand;
|
use crate::bots::approved_bot::modules::download::{StartDownloadCommand, DownloadArchiveCommand};
|
||||||
|
|
||||||
use super::types::{
|
use super::types::{
|
||||||
Author, AuthorBook, Book, BookAuthor, BookGenre, SearchBook, Sequence, Translator,
|
Author, AuthorBook, Book, BookAuthor, BookGenre, SearchBook, Sequence, Translator,
|
||||||
@@ -48,7 +48,9 @@ impl FormatTitle for BookAuthor {
|
|||||||
return "".to_string()
|
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()
|
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()
|
return "".to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
format!("📚 {name}")
|
let command = (DownloadArchiveCommand::Sequence { id: *id }).to_string();
|
||||||
|
|
||||||
|
format!("📚 {name}\n{command}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user