mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 07:25:36 +01:00
Optimize
This commit is contained in:
@@ -208,7 +208,7 @@ async fn send_cached_message(
|
|||||||
message: Message,
|
message: Message,
|
||||||
bot: CacheMe<Throttle<Bot>>,
|
bot: CacheMe<Throttle<Bot>>,
|
||||||
download_data: DownloadQueryData,
|
download_data: DownloadQueryData,
|
||||||
donation_notification_cache: Cache<ChatId, bool>,
|
donation_notification_cache: Cache<ChatId, ()>,
|
||||||
need_delete_message: bool,
|
need_delete_message: bool,
|
||||||
) -> BotHandlerInternal {
|
) -> BotHandlerInternal {
|
||||||
if let Ok(v) = get_cached_message(&download_data).await {
|
if let Ok(v) = get_cached_message(&download_data).await {
|
||||||
@@ -233,7 +233,7 @@ async fn _send_downloaded_file(
|
|||||||
message: &Message,
|
message: &Message,
|
||||||
bot: CacheMe<Throttle<Bot>>,
|
bot: CacheMe<Throttle<Bot>>,
|
||||||
downloaded_data: DownloadFile,
|
downloaded_data: DownloadFile,
|
||||||
donation_notification_cache: Cache<ChatId, bool>,
|
donation_notification_cache: Cache<ChatId, ()>,
|
||||||
) -> BotHandlerInternal {
|
) -> BotHandlerInternal {
|
||||||
let DownloadFile {
|
let DownloadFile {
|
||||||
response,
|
response,
|
||||||
@@ -263,7 +263,7 @@ async fn send_with_download_from_channel(
|
|||||||
message: Message,
|
message: Message,
|
||||||
bot: CacheMe<Throttle<Bot>>,
|
bot: CacheMe<Throttle<Bot>>,
|
||||||
download_data: DownloadQueryData,
|
download_data: DownloadQueryData,
|
||||||
donation_notification_cache: Cache<ChatId, bool>,
|
donation_notification_cache: Cache<ChatId, ()>,
|
||||||
need_delete_message: bool,
|
need_delete_message: bool,
|
||||||
) -> BotHandlerInternal {
|
) -> BotHandlerInternal {
|
||||||
match download_file(&download_data).await {
|
match download_file(&download_data).await {
|
||||||
@@ -285,7 +285,7 @@ async fn download_handler(
|
|||||||
bot: CacheMe<Throttle<Bot>>,
|
bot: CacheMe<Throttle<Bot>>,
|
||||||
cache: BotCache,
|
cache: BotCache,
|
||||||
download_data: DownloadQueryData,
|
download_data: DownloadQueryData,
|
||||||
donation_notification_cache: Cache<ChatId, bool>,
|
donation_notification_cache: Cache<ChatId, ()>,
|
||||||
need_delete_message: bool,
|
need_delete_message: bool,
|
||||||
) -> BotHandlerInternal {
|
) -> BotHandlerInternal {
|
||||||
match cache {
|
match cache {
|
||||||
|
|||||||
@@ -9,16 +9,16 @@ use super::user_settings::{is_need_donate_notifications, mark_donate_notificatio
|
|||||||
pub async fn send_donation_notification(
|
pub async fn send_donation_notification(
|
||||||
bot: CacheMe<Throttle<Bot>>,
|
bot: CacheMe<Throttle<Bot>>,
|
||||||
message: Message,
|
message: Message,
|
||||||
donation_notification_cache: Cache<ChatId, bool>,
|
donation_notification_cache: Cache<ChatId, ()>,
|
||||||
) -> BotHandlerInternal {
|
) -> BotHandlerInternal {
|
||||||
if donation_notification_cache.get(&message.chat.id).is_some() {
|
if donation_notification_cache.get(&message.chat.id).is_some() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
} else if !is_need_donate_notifications(message.chat.id).await? {
|
} else if !is_need_donate_notifications(message.chat.id).await? {
|
||||||
donation_notification_cache.insert(message.chat.id, true).await;
|
donation_notification_cache.insert(message.chat.id, ()).await;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
donation_notification_cache.insert(message.chat.id, true).await;
|
donation_notification_cache.insert(message.chat.id, ()).await;
|
||||||
mark_donate_notification_sended(message.chat.id).await?;
|
mark_donate_notification_sended(message.chat.id).await?;
|
||||||
|
|
||||||
support_command_handler(message, bot).await?;
|
support_command_handler(message, bot).await?;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ use crate::config;
|
|||||||
pub struct AppState {
|
pub struct AppState {
|
||||||
pub user_activity_cache: Cache<UserId, bool>,
|
pub user_activity_cache: Cache<UserId, bool>,
|
||||||
pub user_langs_cache: Cache<UserId, Vec<String>>,
|
pub user_langs_cache: Cache<UserId, Vec<String>>,
|
||||||
pub chat_donation_notifications_cache: Cache<ChatId, bool>,
|
pub chat_donation_notifications_cache: Cache<ChatId, ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct BotsManager {
|
pub struct BotsManager {
|
||||||
|
|||||||
Reference in New Issue
Block a user