mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 15:35:35 +01:00
Enable new download pipeline
This commit is contained in:
@@ -67,6 +67,13 @@ pub struct StartDownloadData {
|
|||||||
pub id: u32,
|
pub id: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ToString for StartDownloadData {
|
||||||
|
fn to_string(&self) -> String {
|
||||||
|
let id = self.id;
|
||||||
|
format!("/d_{id}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl CommandParse<Self> for StartDownloadData {
|
impl CommandParse<Self> for StartDownloadData {
|
||||||
fn parse(s: &str, bot_name: &str) -> Result<Self, strum::ParseError> {
|
fn parse(s: &str, bot_name: &str) -> Result<Self, strum::ParseError> {
|
||||||
let re = Regex::new(r"^/d_(?P<book_id>\d+)$").unwrap();
|
let re = Regex::new(r"^/d_(?P<book_id>\d+)$").unwrap();
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
|
|
||||||
|
use crate::bots::approved_bot::modules::download::StartDownloadData;
|
||||||
|
|
||||||
use super::types::{Author, AuthorBook, Book, SearchBook, Sequence, Translator, TranslatorBook};
|
use super::types::{Author, AuthorBook, Book, SearchBook, Sequence, Translator, TranslatorBook};
|
||||||
|
|
||||||
pub trait Format {
|
pub trait Format {
|
||||||
@@ -82,17 +84,8 @@ impl Format for Book {
|
|||||||
false => "".to_string(),
|
false => "".to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let links: String = self
|
let download_command = (StartDownloadData { id: self.id }).to_string();
|
||||||
.available_types
|
let download_links = format!("Скачать:\n📥{download_command}");
|
||||||
.clone()
|
|
||||||
.into_iter()
|
|
||||||
.map(|a_type| {
|
|
||||||
let Book { id, .. } = self;
|
|
||||||
format!("📥 {a_type}: /d_{a_type}_{id}")
|
|
||||||
})
|
|
||||||
.collect::<Vec<String>>()
|
|
||||||
.join("\n");
|
|
||||||
let download_links = format!("Скачать:\n{links}");
|
|
||||||
|
|
||||||
format!("{book_title}{pages_count}{annotations}{authors}{translators}{sequences}{genres}{download_links}")
|
format!("{book_title}{pages_count}{annotations}{authors}{translators}{sequences}{genres}{download_links}")
|
||||||
}
|
}
|
||||||
@@ -175,17 +168,8 @@ impl Format for SearchBook {
|
|||||||
"".to_string()
|
"".to_string()
|
||||||
};
|
};
|
||||||
|
|
||||||
let links: String = self
|
let download_command = (StartDownloadData { id: self.id }).to_string();
|
||||||
.available_types
|
let download_links = format!("Скачать:\n📥{download_command}");
|
||||||
.clone()
|
|
||||||
.into_iter()
|
|
||||||
.map(|a_type| {
|
|
||||||
let SearchBook { id, .. } = self;
|
|
||||||
format!("📥 {a_type}: /d_{a_type}_{id}")
|
|
||||||
})
|
|
||||||
.collect::<Vec<String>>()
|
|
||||||
.join("\n");
|
|
||||||
let download_links = format!("Скачать:\n{links}");
|
|
||||||
|
|
||||||
format!("{book_title}{annotations}{authors}{translators}{download_links}")
|
format!("{book_title}{annotations}{authors}{translators}{download_links}")
|
||||||
}
|
}
|
||||||
@@ -241,17 +225,8 @@ impl Format for AuthorBook {
|
|||||||
false => "".to_string(),
|
false => "".to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let links: String = self
|
let download_command = (StartDownloadData { id: self.id }).to_string();
|
||||||
.available_types
|
let download_links = format!("Скачать:\n📥{download_command}");
|
||||||
.clone()
|
|
||||||
.into_iter()
|
|
||||||
.map(|a_type| {
|
|
||||||
let AuthorBook { id, .. } = self;
|
|
||||||
format!("📥 {a_type}: /d_{a_type}_{id}")
|
|
||||||
})
|
|
||||||
.collect::<Vec<String>>()
|
|
||||||
.join("\n");
|
|
||||||
let download_links = format!("Скачать:\n{links}");
|
|
||||||
|
|
||||||
format!("{book_title}{annotations}{translators}{download_links}")
|
format!("{book_title}{annotations}{translators}{download_links}")
|
||||||
}
|
}
|
||||||
@@ -286,17 +261,8 @@ impl Format for TranslatorBook {
|
|||||||
false => "".to_string(),
|
false => "".to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let links: String = self
|
let download_command = (StartDownloadData { id: self.id }).to_string();
|
||||||
.available_types
|
let download_links = format!("Скачать:\n📥{download_command}");
|
||||||
.clone()
|
|
||||||
.into_iter()
|
|
||||||
.map(|a_type| {
|
|
||||||
let TranslatorBook { id, .. } = self;
|
|
||||||
format!("📥 {a_type}: /d_{a_type}_{id}")
|
|
||||||
})
|
|
||||||
.collect::<Vec<String>>()
|
|
||||||
.join("\n");
|
|
||||||
let download_links = format!("Скачать:\n{links}");
|
|
||||||
|
|
||||||
format!("{book_title}{annotations}{authors}{download_links}")
|
format!("{book_title}{annotations}{authors}{download_links}")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user