mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 07:25:36 +01:00
Add sequences to search books
This commit is contained in:
@@ -69,7 +69,7 @@ pub struct StartDownloadData {
|
||||
|
||||
impl ToString for StartDownloadData {
|
||||
fn to_string(&self) -> String {
|
||||
let id = self.id;
|
||||
let StartDownloadData { id } = self;
|
||||
format!("/d_{id}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,6 +153,22 @@ impl Format for SearchBook {
|
||||
"".to_string()
|
||||
};
|
||||
|
||||
let sequences = match !self.sequences.is_empty() {
|
||||
true => {
|
||||
let formated_sequences: String = self
|
||||
.sequences
|
||||
.clone()[..min(5, self.sequences.len())]
|
||||
.into_iter()
|
||||
.map(|sequence| sequence.format())
|
||||
.collect::<Vec<String>>()
|
||||
.join("\n");
|
||||
|
||||
let post_fix = if self.sequences.len() > 5 { "\nи др." } else { "" };
|
||||
format!("Серии:\n{formated_sequences}{post_fix}\n\n")
|
||||
}
|
||||
false => "".to_string(),
|
||||
};
|
||||
|
||||
let translators = if !self.translators.is_empty() {
|
||||
let formated_translators = self
|
||||
.translators
|
||||
@@ -171,7 +187,7 @@ impl Format for SearchBook {
|
||||
let download_command = (StartDownloadData { id: self.id }).to_string();
|
||||
let download_links = format!("Скачать:\n📥{download_command}");
|
||||
|
||||
format!("{book_title}{annotations}{authors}{translators}{download_links}")
|
||||
format!("{book_title}{annotations}{authors}{translators}{sequences}{download_links}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -139,6 +139,7 @@ pub struct SearchBook {
|
||||
pub annotation_exists: bool,
|
||||
pub authors: Vec<BookAuthor>,
|
||||
pub translators: Vec<BookAuthor>,
|
||||
pub sequences: Vec<Sequence>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone)]
|
||||
|
||||
Reference in New Issue
Block a user