mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 15:35:35 +01:00
Add donation notifications
This commit is contained in:
27
src/bots/approved_bot/services/donation_notificatioins.rs
Normal file
27
src/bots/approved_bot/services/donation_notificatioins.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use moka::future::Cache;
|
||||
use teloxide::{types::{ChatId, Message}, adaptors::{CacheMe, Throttle}, Bot};
|
||||
|
||||
use crate::bots::{BotHandlerInternal, approved_bot::modules::support::support_command_handler};
|
||||
|
||||
use super::user_settings::{is_need_donate_notifications, mark_donate_notification_sended};
|
||||
|
||||
|
||||
pub async fn send_donation_notification(
|
||||
bot: CacheMe<Throttle<Bot>>,
|
||||
message: Message,
|
||||
donation_notification_cache: Cache<ChatId, bool>,
|
||||
) -> 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;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
donation_notification_cache.insert(message.chat.id, true).await;
|
||||
mark_donate_notification_sended(message.chat.id).await?;
|
||||
|
||||
support_command_handler(message, bot).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user