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,
|
||||
bot: CacheMe<Throttle<Bot>>,
|
||||
download_data: DownloadQueryData,
|
||||
donation_notification_cache: Cache<ChatId, bool>,
|
||||
donation_notification_cache: Cache<ChatId, ()>,
|
||||
need_delete_message: bool,
|
||||
) -> BotHandlerInternal {
|
||||
if let Ok(v) = get_cached_message(&download_data).await {
|
||||
@@ -233,7 +233,7 @@ async fn _send_downloaded_file(
|
||||
message: &Message,
|
||||
bot: CacheMe<Throttle<Bot>>,
|
||||
downloaded_data: DownloadFile,
|
||||
donation_notification_cache: Cache<ChatId, bool>,
|
||||
donation_notification_cache: Cache<ChatId, ()>,
|
||||
) -> BotHandlerInternal {
|
||||
let DownloadFile {
|
||||
response,
|
||||
@@ -263,7 +263,7 @@ async fn send_with_download_from_channel(
|
||||
message: Message,
|
||||
bot: CacheMe<Throttle<Bot>>,
|
||||
download_data: DownloadQueryData,
|
||||
donation_notification_cache: Cache<ChatId, bool>,
|
||||
donation_notification_cache: Cache<ChatId, ()>,
|
||||
need_delete_message: bool,
|
||||
) -> BotHandlerInternal {
|
||||
match download_file(&download_data).await {
|
||||
@@ -285,7 +285,7 @@ async fn download_handler(
|
||||
bot: CacheMe<Throttle<Bot>>,
|
||||
cache: BotCache,
|
||||
download_data: DownloadQueryData,
|
||||
donation_notification_cache: Cache<ChatId, bool>,
|
||||
donation_notification_cache: Cache<ChatId, ()>,
|
||||
need_delete_message: bool,
|
||||
) -> BotHandlerInternal {
|
||||
match cache {
|
||||
|
||||
@@ -9,16 +9,16 @@ use super::user_settings::{is_need_donate_notifications, mark_donate_notificatio
|
||||
pub async fn send_donation_notification(
|
||||
bot: CacheMe<Throttle<Bot>>,
|
||||
message: Message,
|
||||
donation_notification_cache: Cache<ChatId, bool>,
|
||||
donation_notification_cache: Cache<ChatId, ()>,
|
||||
) -> BotHandlerInternal {
|
||||
if donation_notification_cache.get(&message.chat.id).is_some() {
|
||||
return Ok(());
|
||||
} 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(());
|
||||
}
|
||||
|
||||
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?;
|
||||
|
||||
support_command_handler(message, bot).await?;
|
||||
|
||||
@@ -26,7 +26,7 @@ use crate::config;
|
||||
pub struct AppState {
|
||||
pub user_activity_cache: Cache<UserId, bool>,
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user