mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 07:25:36 +01:00
Fixes
This commit is contained in:
6
.github/workflows/build_docker_image.yml
vendored
6
.github/workflows/build_docker_image.yml
vendored
@@ -13,12 +13,6 @@ jobs:
|
|||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
-
|
|
||||||
name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
with:
|
|
||||||
platforms: arm64
|
|
||||||
|
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|||||||
38
Cargo.lock
generated
38
Cargo.lock
generated
@@ -172,9 +172,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64"
|
name = "base64"
|
||||||
version = "0.21.3"
|
version = "0.21.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53"
|
checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
@@ -287,15 +287,14 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chrono"
|
name = "chrono"
|
||||||
version = "0.4.28"
|
version = "0.4.30"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "95ed24df0632f708f5f6d8082675bef2596f7084dee3dd55f632290bf35bfe0f"
|
checksum = "defd4e7873dbddba6c7c91e199c7fcb946abc4a6a4ac3195400bcfb01b5de877"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android-tzdata",
|
"android-tzdata",
|
||||||
"iana-time-zone",
|
"iana-time-zone",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"time 0.1.45",
|
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"windows-targets",
|
"windows-targets",
|
||||||
]
|
]
|
||||||
@@ -688,7 +687,7 @@ checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
"wasi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1050,7 +1049,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2"
|
checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
"wasi",
|
||||||
"windows-sys",
|
"windows-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1369,7 +1368,7 @@ dependencies = [
|
|||||||
"mach2",
|
"mach2",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"raw-cpuid",
|
"raw-cpuid",
|
||||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
"wasi",
|
||||||
"web-sys",
|
"web-sys",
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
@@ -1746,7 +1745,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"time 0.3.28",
|
"time",
|
||||||
"url",
|
"url",
|
||||||
"uuid",
|
"uuid",
|
||||||
]
|
]
|
||||||
@@ -1773,9 +1772,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.105"
|
version = "1.0.107"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360"
|
checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
"ryu",
|
"ryu",
|
||||||
@@ -2107,17 +2106,6 @@ dependencies = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "time"
|
|
||||||
version = "0.1.45"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"wasi 0.10.0+wasi-snapshot-preview1",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.3.28"
|
version = "0.3.28"
|
||||||
@@ -2502,12 +2490,6 @@ dependencies = [
|
|||||||
"try-lock",
|
"try-lock",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasi"
|
|
||||||
version = "0.10.0+wasi-snapshot-preview1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasi"
|
name = "wasi"
|
||||||
version = "0.11.0+wasi-snapshot-preview1"
|
version = "0.11.0+wasi-snapshot-preview1"
|
||||||
|
|||||||
@@ -9,18 +9,18 @@ edition = "2021"
|
|||||||
tokio = { version = "1.32.0", features = ["rt-multi-thread", "macros"] }
|
tokio = { version = "1.32.0", features = ["rt-multi-thread", "macros"] }
|
||||||
reqwest = { version = "0.11.20", features = ["json"] }
|
reqwest = { version = "0.11.20", features = ["json"] }
|
||||||
serde = { version = "1.0.188", features = ["derive"] }
|
serde = { version = "1.0.188", features = ["derive"] }
|
||||||
serde_json = "1.0.105"
|
serde_json = "1.0.107"
|
||||||
teloxide = { git = "https://github.com/teloxide/teloxide.git", branch="master", features = ["macros", "webhooks-axum", "cache-me", "throttle"] }
|
teloxide = { git = "https://github.com/teloxide/teloxide.git", branch="master", features = ["macros", "webhooks-axum", "cache-me", "throttle"] }
|
||||||
url = "2.4.1"
|
url = "2.4.1"
|
||||||
ctrlc = { version = "3.4.1", features = ["termination"] }
|
ctrlc = { version = "3.4.1", features = ["termination"] }
|
||||||
strum = "0.25.0"
|
strum = "0.25.0"
|
||||||
strum_macros = "0.25.2"
|
strum_macros = "0.25.2"
|
||||||
futures = "0.3.28"
|
futures = "0.3.28"
|
||||||
base64 = "0.21.3"
|
base64 = "0.21.4"
|
||||||
tokio-util = { version = "0.7.8", features = ["compat"] }
|
tokio-util = { version = "0.7.8", features = ["compat"] }
|
||||||
textwrap = "0.16.0"
|
textwrap = "0.16.0"
|
||||||
regex = "1.9.5"
|
regex = "1.9.5"
|
||||||
chrono = "0.4.28"
|
chrono = "0.4.30"
|
||||||
dateparser = "0.2.0"
|
dateparser = "0.2.0"
|
||||||
sentry = { version = "0.31.6", features = ["debug-images"] }
|
sentry = { version = "0.31.6", features = ["debug-images"] }
|
||||||
moka = { version = "0.11.3", features = ["future"] }
|
moka = { version = "0.11.3", features = ["future"] }
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use crate::{bots::approved_bot::services::user_settings::create_or_update_user_s
|
|||||||
use self::{
|
use self::{
|
||||||
modules::{
|
modules::{
|
||||||
annotations::get_annotations_handler, book::get_book_handler,
|
annotations::get_annotations_handler, book::get_book_handler,
|
||||||
download::get_download_hander, help::get_help_handler, random::get_random_hander,
|
download::get_download_handler, help::get_help_handler, random::get_random_handler,
|
||||||
search::get_search_handler, settings::get_settings_handler, support::get_support_handler,
|
search::get_search_handler, settings::get_settings_handler, support::get_support_handler,
|
||||||
update_history::get_update_log_handler,
|
update_history::get_update_log_handler,
|
||||||
},
|
},
|
||||||
@@ -81,8 +81,8 @@ pub fn get_approved_handler() -> (BotHandler, BotCommands) {
|
|||||||
.branch(get_help_handler())
|
.branch(get_help_handler())
|
||||||
.branch(get_settings_handler())
|
.branch(get_settings_handler())
|
||||||
.branch(get_support_handler())
|
.branch(get_support_handler())
|
||||||
.branch(get_random_hander())
|
.branch(get_random_handler())
|
||||||
.branch(get_download_hander())
|
.branch(get_download_handler())
|
||||||
.branch(get_annotations_handler())
|
.branch(get_annotations_handler())
|
||||||
.branch(get_book_handler())
|
.branch(get_book_handler())
|
||||||
.branch(get_update_log_handler())
|
.branch(get_update_log_handler())
|
||||||
|
|||||||
@@ -15,23 +15,21 @@ impl FromStr for AnnotationCallbackData {
|
|||||||
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> {
|
||||||
let re = Regex::new(r"^(?P<an_type>a|b)_an_(?P<id>\d+)_(?P<page>\d+)$").unwrap();
|
Regex::new(r"^(?P<an_type>[ab])_an_(?P<id>\d+)_(?P<page>\d+)$")
|
||||||
|
.unwrap_or_else(|_| panic!("Broken AnnotationCallbackData regex pattern!"))
|
||||||
let caps = re.captures(s);
|
.captures(s)
|
||||||
let caps = match caps {
|
.ok_or(strum::ParseError::VariantNotFound)
|
||||||
Some(v) => v,
|
.map(|caps| (
|
||||||
None => return Err(strum::ParseError::VariantNotFound),
|
caps["an_type"].to_string(),
|
||||||
};
|
caps["id"].parse::<u32>().unwrap(),
|
||||||
|
caps["page"].parse::<u32>().unwrap()
|
||||||
let annotation_type = &caps["an_type"];
|
))
|
||||||
let id = caps["id"].parse::<u32>().unwrap();
|
.map(|(annotation_type, id, page)|
|
||||||
let page = caps["page"].parse::<u32>().unwrap();
|
match annotation_type.as_str() {
|
||||||
|
"a" => AnnotationCallbackData::Author { id, page },
|
||||||
match annotation_type {
|
"b" => AnnotationCallbackData::Book { id, page },
|
||||||
"a" => Ok(AnnotationCallbackData::Author { id, page }),
|
_ => panic!("Unknown AnnotationCallbackData type: {}!", annotation_type),
|
||||||
"b" => Ok(AnnotationCallbackData::Book { id, page }),
|
})
|
||||||
_ => Err(strum::ParseError::VariantNotFound),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ pub enum AnnotationCommand {
|
|||||||
|
|
||||||
impl CommandParse<Self> for AnnotationCommand {
|
impl CommandParse<Self> for AnnotationCommand {
|
||||||
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"^/(?P<an_type>a|b)_an_(?P<id>\d+)$")
|
let re = Regex::new(r"^/(?P<an_type>[ab])_an_(?P<id>\d+)$")
|
||||||
.unwrap_or_else(|_| panic!("Can't create AnnotationCommand regexp!"));
|
.unwrap_or_else(|_| panic!("Can't create AnnotationCommand regexp!"));
|
||||||
|
|
||||||
let full_bot_name = format!("@{bot_name}");
|
let full_bot_name = format!("@{bot_name}");
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
pub mod commands;
|
pub mod commands;
|
||||||
pub mod callback_data;
|
pub mod callback_data;
|
||||||
pub mod formater;
|
pub mod formatter;
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
|
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
@@ -21,7 +21,7 @@ use crate::bots::{
|
|||||||
BotHandlerInternal,
|
BotHandlerInternal,
|
||||||
};
|
};
|
||||||
|
|
||||||
use self::{commands::AnnotationCommand, formater::AnnotationFormat, callback_data::AnnotationCallbackData, errors::AnnotationError};
|
use self::{commands::AnnotationCommand, formatter::AnnotationFormat, callback_data::AnnotationCallbackData, errors::AnnotationError};
|
||||||
|
|
||||||
use super::utils::{filter_command, split_text_to_chunks};
|
use super::utils::{filter_command, split_text_to_chunks};
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ impl FromStr for BookCallbackData {
|
|||||||
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> {
|
||||||
let re = Regex::new(r"^b(?P<an_type>a|t|s)_(?P<id>\d+)_(?P<page>\d+)$").unwrap();
|
let re = Regex::new(r"^b(?P<an_type>[ats])_(?P<id>\d+)_(?P<page>\d+)$").unwrap();
|
||||||
|
|
||||||
let caps = re.captures(s);
|
let caps = re.captures(s);
|
||||||
let caps = match caps {
|
let caps = match caps {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ pub enum BookCommand {
|
|||||||
|
|
||||||
impl CommandParse<Self> for BookCommand {
|
impl CommandParse<Self> for BookCommand {
|
||||||
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"^/(?P<an_type>a|t|s)_(?P<id>\d+)$").unwrap();
|
let re = Regex::new(r"^/(?P<an_type>[ats])_(?P<id>\d+)$").unwrap();
|
||||||
|
|
||||||
let full_bot_name = format!("@{bot_name}");
|
let full_bot_name = format!("@{bot_name}");
|
||||||
let after_replace = s.replace(&full_bot_name, "");
|
let after_replace = s.replace(&full_bot_name, "");
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use tracing::log;
|
|||||||
use crate::bots::approved_bot::{
|
use crate::bots::approved_bot::{
|
||||||
services::{
|
services::{
|
||||||
book_library::{
|
book_library::{
|
||||||
formaters::{Format, FormatTitle}, get_author_books, get_sequence_books, get_translator_books,
|
formatters::{Format, FormatTitle}, get_author_books, get_sequence_books, get_translator_books,
|
||||||
types::Page,
|
types::Page,
|
||||||
},
|
},
|
||||||
user_settings::get_user_or_default_lang_codes,
|
user_settings::get_user_or_default_lang_codes,
|
||||||
@@ -79,7 +79,7 @@ where
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
|
|
||||||
let formated_page = items_page.format(1, 4096);
|
let formatted_page = items_page.format(1, 4096);
|
||||||
|
|
||||||
let callback_data = match command {
|
let callback_data = match command {
|
||||||
BookCommand::Author { id } => BookCallbackData::Author { id, page: 1 },
|
BookCommand::Author { id } => BookCallbackData::Author { id, page: 1 },
|
||||||
@@ -90,7 +90,7 @@ where
|
|||||||
let keyboard = generic_get_pagination_keyboard(1, items_page.pages, callback_data, true);
|
let keyboard = generic_get_pagination_keyboard(1, items_page.pages, callback_data, true);
|
||||||
|
|
||||||
bot
|
bot
|
||||||
.send_message(chat_id, formated_page)
|
.send_message(chat_id, formatted_page)
|
||||||
.reply_markup(keyboard)
|
.reply_markup(keyboard)
|
||||||
.send()
|
.send()
|
||||||
.await?;
|
.await?;
|
||||||
@@ -166,12 +166,12 @@ where
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let formated_page = items_page.format(page, 4096);
|
let formatted_page = items_page.format(page, 4096);
|
||||||
|
|
||||||
let keyboard = generic_get_pagination_keyboard(page, items_page.pages, callback_data, true);
|
let keyboard = generic_get_pagination_keyboard(page, items_page.pages, callback_data, true);
|
||||||
|
|
||||||
bot
|
bot
|
||||||
.edit_message_text(chat_id, message_id, formated_page)
|
.edit_message_text(chat_id, message_id, formatted_page)
|
||||||
.reply_markup(keyboard)
|
.reply_markup(keyboard)
|
||||||
.send()
|
.send()
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ impl FromStr for DownloadArchiveQueryData {
|
|||||||
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> {
|
||||||
let re = Regex::new(r"^da_(?P<obj_type>[s|a|t])_(?P<id>\d+)_(?P<file_type>\w+)$").unwrap();
|
let re = Regex::new(r"^da_(?P<obj_type>[sat])_(?P<id>\d+)_(?P<file_type>\w+)$").unwrap();
|
||||||
|
|
||||||
let caps = re.captures(s);
|
let caps = re.captures(s);
|
||||||
let caps = match caps {
|
let caps = match caps {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ impl ToString for DownloadArchiveCommand {
|
|||||||
|
|
||||||
impl CommandParse<Self> for DownloadArchiveCommand {
|
impl CommandParse<Self> for DownloadArchiveCommand {
|
||||||
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"^/da_(?P<type>[s|a|t])_(?P<id>\d+)$").unwrap();
|
let re = Regex::new(r"^/da_(?P<type>[sat])_(?P<id>\d+)$").unwrap();
|
||||||
|
|
||||||
let full_bot_name = format!("@{bot_name}");
|
let full_bot_name = format!("@{bot_name}");
|
||||||
let after_replace = s.replace(&full_bot_name, "");
|
let after_replace = s.replace(&full_bot_name, "");
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
pub mod commads;
|
pub mod commands;
|
||||||
pub mod callback_data;
|
pub mod callback_data;
|
||||||
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
@@ -27,7 +27,7 @@ use crate::{
|
|||||||
types::{CachedMessage, DownloadFile}, download_file_by_link, get_download_link,
|
types::{CachedMessage, DownloadFile}, download_file_by_link, get_download_link,
|
||||||
},
|
},
|
||||||
book_library::{get_book, get_author_books_available_types, get_translator_books_available_types, get_sequence_books_available_types},
|
book_library::{get_book, get_author_books_available_types, get_translator_books_available_types, get_sequence_books_available_types},
|
||||||
donation_notificatioins::send_donation_notification, user_settings::get_user_or_default_lang_codes, batch_downloader::{TaskObjectType, CreateTaskData},
|
donation_notifications::send_donation_notification, user_settings::get_user_or_default_lang_codes, batch_downloader::{TaskObjectType, CreateTaskData},
|
||||||
batch_downloader::{create_task, get_task, TaskStatus}
|
batch_downloader::{create_task, get_task, TaskStatus}
|
||||||
|
|
||||||
},
|
},
|
||||||
@@ -38,7 +38,7 @@ use crate::{
|
|||||||
bots_manager::BotCache,
|
bots_manager::BotCache,
|
||||||
};
|
};
|
||||||
|
|
||||||
use self::{callback_data::{CheckArchiveStatus, DownloadQueryData}, commads::{StartDownloadCommand, DownloadArchiveCommand}};
|
use self::{callback_data::{CheckArchiveStatus, DownloadQueryData}, commands::{StartDownloadCommand, DownloadArchiveCommand}};
|
||||||
|
|
||||||
use super::utils::filter_command;
|
use super::utils::filter_command;
|
||||||
|
|
||||||
@@ -179,7 +179,6 @@ async fn send_download_link(
|
|||||||
.reply_markup(InlineKeyboardMarkup {
|
.reply_markup(InlineKeyboardMarkup {
|
||||||
inline_keyboard: vec![],
|
inline_keyboard: vec![],
|
||||||
})
|
})
|
||||||
.send()
|
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -400,7 +399,6 @@ async fn wait_archive(
|
|||||||
.reply_markup(InlineKeyboardMarkup {
|
.reply_markup(InlineKeyboardMarkup {
|
||||||
inline_keyboard: vec![],
|
inline_keyboard: vec![],
|
||||||
})
|
})
|
||||||
.send()
|
|
||||||
.await;
|
.await;
|
||||||
log::error!("{:?}", err);
|
log::error!("{:?}", err);
|
||||||
return Err(err);
|
return Err(err);
|
||||||
@@ -459,7 +457,7 @@ async fn download_archive(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_download_hander() -> crate::bots::BotHandler {
|
pub fn get_download_handler() -> crate::bots::BotHandler {
|
||||||
dptree::entry()
|
dptree::entry()
|
||||||
.branch(
|
.branch(
|
||||||
Update::filter_message()
|
Update::filter_message()
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ pub async fn help_handler(message: Message, bot: CacheMe<Throttle<Bot>>) -> BotH
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
.parse_mode(ParseMode::Html)
|
.parse_mode(ParseMode::Html)
|
||||||
.send()
|
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use teloxide::{
|
|||||||
use crate::bots::{
|
use crate::bots::{
|
||||||
approved_bot::{
|
approved_bot::{
|
||||||
services::{
|
services::{
|
||||||
book_library::{self, formaters::Format},
|
book_library::{self, formatters::Format},
|
||||||
user_settings::get_user_or_default_lang_codes,
|
user_settings::get_user_or_default_lang_codes,
|
||||||
},
|
},
|
||||||
tools::filter_callback_query, modules::random::callback_data::RandomCallbackData,
|
tools::filter_callback_query, modules::random::callback_data::RandomCallbackData,
|
||||||
@@ -247,7 +247,7 @@ async fn get_random_book_by_genre(
|
|||||||
get_random_item_handler_internal(cq, bot, item).await
|
get_random_item_handler_internal(cq, bot, item).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_random_hander() -> crate::bots::BotHandler {
|
pub fn get_random_handler() -> crate::bots::BotHandler {
|
||||||
dptree::entry()
|
dptree::entry()
|
||||||
.branch(
|
.branch(
|
||||||
Update::filter_message()
|
Update::filter_message()
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ impl FromStr for SearchCallbackData {
|
|||||||
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> {
|
||||||
let re = Regex::new(r"^(?P<search_type>s[a|b|s|t])_(?P<page>\d+)$").unwrap();
|
let re = Regex::new(r"^(?P<search_type>s[abst])_(?P<page>\d+)$").unwrap();
|
||||||
|
|
||||||
let caps = re.captures(s);
|
let caps = re.captures(s);
|
||||||
let caps = match caps {
|
let caps = match caps {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use crate::bots::{
|
|||||||
approved_bot::{
|
approved_bot::{
|
||||||
services::{
|
services::{
|
||||||
book_library::{
|
book_library::{
|
||||||
formaters::{Format, FormatTitle}, search_author, search_book, search_sequence, search_translator,
|
formatters::{Format, FormatTitle}, search_author, search_book, search_sequence, search_translator,
|
||||||
types::Page,
|
types::Page,
|
||||||
},
|
},
|
||||||
user_settings::get_user_or_default_lang_codes,
|
user_settings::get_user_or_default_lang_codes,
|
||||||
|
|||||||
@@ -118,9 +118,9 @@ async fn update_log_pagination_handler(
|
|||||||
let page = update_callback_data.page;
|
let page = update_callback_data.page;
|
||||||
let total_pages = items_page.pages;
|
let total_pages = items_page.pages;
|
||||||
|
|
||||||
let formated_page = items_page.format(page, 4096);
|
let formatted_page = items_page.format(page, 4096);
|
||||||
|
|
||||||
let message_text = format!("{header}{formated_page}");
|
let message_text = format!("{header}{formatted_page}");
|
||||||
|
|
||||||
let keyboard = generic_get_pagination_keyboard(page, total_pages, update_callback_data, true);
|
let keyboard = generic_get_pagination_keyboard(page, total_pages, update_callback_data, true);
|
||||||
bot
|
bot
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ pub enum TaskStatus {
|
|||||||
InProgress,
|
InProgress,
|
||||||
Archiving,
|
Archiving,
|
||||||
Complete,
|
Complete,
|
||||||
Failled
|
Failed
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
|
|
||||||
use crate::bots::approved_bot::modules::download::commads::{StartDownloadCommand, DownloadArchiveCommand};
|
use crate::bots::approved_bot::modules::download::commands::{StartDownloadCommand, DownloadArchiveCommand};
|
||||||
|
|
||||||
use super::types::{
|
use super::types::{
|
||||||
Author, AuthorBook, Book, BookAuthor, BookGenre, SearchBook, Sequence, Translator,
|
Author, AuthorBook, Book, BookAuthor, BookGenre, SearchBook, Sequence, Translator,
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
pub mod formaters;
|
pub mod formatters;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
use smartstring::alias::String as SmartString;
|
use smartstring::alias::String as SmartString;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use core::fmt::Debug;
|
|||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
use super::formaters::{Format, FormatResult, FormatTitle};
|
use super::formatters::{Format, FormatResult, FormatTitle};
|
||||||
|
|
||||||
|
|
||||||
#[derive(Default, Deserialize, Debug, Clone)]
|
#[derive(Default, Deserialize, Debug, Clone)]
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use teloxide::{types::Message, adaptors::{CacheMe, Throttle}, Bot};
|
|||||||
|
|
||||||
use crate::{bots::{BotHandlerInternal, approved_bot::modules::support::support_command_handler}, bots_manager::CHAT_DONATION_NOTIFICATIONS_CACHE};
|
use crate::{bots::{BotHandlerInternal, approved_bot::modules::support::support_command_handler}, bots_manager::CHAT_DONATION_NOTIFICATIONS_CACHE};
|
||||||
|
|
||||||
use super::user_settings::{is_need_donate_notifications, mark_donate_notification_sended};
|
use super::user_settings::{is_need_donate_notifications, mark_donate_notification_sent};
|
||||||
|
|
||||||
|
|
||||||
pub async fn send_donation_notification(
|
pub async fn send_donation_notification(
|
||||||
@@ -17,7 +17,7 @@ pub async fn send_donation_notification(
|
|||||||
}
|
}
|
||||||
|
|
||||||
CHAT_DONATION_NOTIFICATIONS_CACHE.insert(message.chat.id, ()).await;
|
CHAT_DONATION_NOTIFICATIONS_CACHE.insert(message.chat.id, ()).await;
|
||||||
mark_donate_notification_sended(message.chat.id).await?;
|
mark_donate_notification_sent(message.chat.id).await?;
|
||||||
|
|
||||||
support_command_handler(message, bot).await?;
|
support_command_handler(message, bot).await?;
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
pub mod book_cache;
|
pub mod book_cache;
|
||||||
pub mod book_library;
|
pub mod book_library;
|
||||||
pub mod user_settings;
|
pub mod user_settings;
|
||||||
pub mod donation_notificatioins;
|
pub mod donation_notifications;
|
||||||
pub mod batch_downloader;
|
pub mod batch_downloader;
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ pub async fn is_need_donate_notifications(chat_id: ChatId) -> Result<bool, Box<d
|
|||||||
Ok(response.json::<bool>().await?)
|
Ok(response.json::<bool>().await?)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn mark_donate_notification_sended(chat_id: ChatId) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
pub async fn mark_donate_notification_sent(chat_id: ChatId) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||||
reqwest::Client::new()
|
reqwest::Client::new()
|
||||||
.post(format!("{}/donate_notifications/{chat_id}", &config::CONFIG.user_settings_url))
|
.post(format!("{}/donate_notifications/{chat_id}", &config::CONFIG.user_settings_url))
|
||||||
.header("Authorization", &config::CONFIG.user_settings_api_key)
|
.header("Authorization", &config::CONFIG.user_settings_api_key)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ mod bots;
|
|||||||
mod bots_manager;
|
mod bots_manager;
|
||||||
mod config;
|
mod config;
|
||||||
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
|
|||||||
Reference in New Issue
Block a user