mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 07:25:36 +01:00
28 lines
924 B
Rust
28 lines
924 B
Rust
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, ()>,
|
|
) -> 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, ()).await;
|
|
return Ok(());
|
|
}
|
|
|
|
donation_notification_cache.insert(message.chat.id, ()).await;
|
|
mark_donate_notification_sended(message.chat.id).await?;
|
|
|
|
support_command_handler(message, bot).await?;
|
|
|
|
Ok(())
|
|
}
|