Add donation notifications

This commit is contained in:
2023-05-24 21:30:21 +02:00
parent f9723361a0
commit 10b063ac25
6 changed files with 86 additions and 16 deletions

View 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(())
}