Add pre-commit

This commit is contained in:
2023-09-24 22:37:40 +02:00
parent 0afe3acfcd
commit 452040e83a
51 changed files with 771 additions and 596 deletions

View File

@@ -1,22 +1,36 @@
use teloxide::{types::Message, adaptors::{CacheMe, Throttle}, Bot};
use teloxide::{
adaptors::{CacheMe, Throttle},
types::Message,
Bot,
};
use crate::{bots::{BotHandlerInternal, approved_bot::modules::support::support_command_handler}, bots_manager::CHAT_DONATION_NOTIFICATIONS_CACHE};
use crate::{
bots::{approved_bot::modules::support::support_command_handler, BotHandlerInternal},
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).await.is_some() {
if CHAT_DONATION_NOTIFICATIONS_CACHE
.get(&message.chat.id)
.await
.is_some()
{
return Ok(());
} else if !is_need_donate_notifications(message.chat.id).await? {
CHAT_DONATION_NOTIFICATIONS_CACHE.insert(message.chat.id, ()).await;
CHAT_DONATION_NOTIFICATIONS_CACHE
.insert(message.chat.id, ())
.await;
return Ok(());
}
CHAT_DONATION_NOTIFICATIONS_CACHE.insert(message.chat.id, ()).await;
CHAT_DONATION_NOTIFICATIONS_CACHE
.insert(message.chat.id, ())
.await;
mark_donate_notification_sent(message.chat.id).await?;
support_command_handler(message, bot).await?;