mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 15:35:35 +01:00
Add sequences to books by author and translator
This commit is contained in:
@@ -241,10 +241,26 @@ impl Format for AuthorBook {
|
|||||||
false => "".to_string(),
|
false => "".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 download_command = (StartDownloadData { id: self.id }).to_string();
|
let download_command = (StartDownloadData { id: self.id }).to_string();
|
||||||
let download_links = format!("Скачать:\n📥{download_command}");
|
let download_links = format!("Скачать:\n📥{download_command}");
|
||||||
|
|
||||||
format!("{book_title}{annotations}{translators}{download_links}")
|
format!("{book_title}{annotations}{translators}{sequences}{download_links}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,9 +293,25 @@ impl Format for TranslatorBook {
|
|||||||
false => "".to_string(),
|
false => "".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 download_command = (StartDownloadData { id: self.id }).to_string();
|
let download_command = (StartDownloadData { id: self.id }).to_string();
|
||||||
let download_links = format!("Скачать:\n📥{download_command}");
|
let download_links = format!("Скачать:\n📥{download_command}");
|
||||||
|
|
||||||
format!("{book_title}{annotations}{authors}{download_links}")
|
format!("{book_title}{annotations}{authors}{sequences}{download_links}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ pub struct AuthorBook {
|
|||||||
// uploaded: String,
|
// uploaded: String,
|
||||||
pub annotation_exists: bool,
|
pub annotation_exists: bool,
|
||||||
pub translators: Vec<BookAuthor>,
|
pub translators: Vec<BookAuthor>,
|
||||||
|
pub sequences: Vec<Sequence>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
@@ -180,4 +181,5 @@ pub struct TranslatorBook {
|
|||||||
// uploaded: String,
|
// uploaded: String,
|
||||||
pub annotation_exists: bool,
|
pub annotation_exists: bool,
|
||||||
pub authors: Vec<BookAuthor>,
|
pub authors: Vec<BookAuthor>,
|
||||||
|
pub sequences: Vec<Sequence>,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user