mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 15:35:35 +01:00
Fixes
This commit is contained in:
25
src/bots/approved_bot/services/donation_notifications.rs
Normal file
25
src/bots/approved_bot/services/donation_notifications.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
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 super::user_settings::{is_need_donate_notifications, mark_donate_notification_sent};
|
||||
|
||||
|
||||
pub async fn send_donation_notification(
|
||||
bot: CacheMe<Throttle<Bot>>,
|
||||
message: Message,
|
||||
) -> BotHandlerInternal {
|
||||
if CHAT_DONATION_NOTIFICATIONS_CACHE.get(&message.chat.id).is_some() {
|
||||
return Ok(());
|
||||
} else if !is_need_donate_notifications(message.chat.id).await? {
|
||||
CHAT_DONATION_NOTIFICATIONS_CACHE.insert(message.chat.id, ()).await;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
CHAT_DONATION_NOTIFICATIONS_CACHE.insert(message.chat.id, ()).await;
|
||||
mark_donate_notification_sent(message.chat.id).await?;
|
||||
|
||||
support_command_handler(message, bot).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user