use telers::{ event::{telegram::HandlerResult, EventReturn}, types::{Dice, Message}, Bot, }; use crate::{ handlers::actions::{ban::ban, mute::mute}, types::{ enums::time_metrics::TimeMetrics, structs::{handler_entity::HandlerEntity, message_sender::MessageSender}, }, }; const DICE_DELAY_MS: u64 = 4000u64; const CASINO_DELAY_MS: u64 = 1500u64; pub async fn dice_handler(bot: Bot, message: Message) -> HandlerResult { let (chat_id, dice): (i64, Dice) = (message.chat().id(), message.dice().unwrap().clone()); let handler_entity: HandlerEntity = HandlerEntity { bot_instance: bot, message_reciever: message, message_sender_builder: MessageSender::builder(chat_id), }; let (mute_time, emoji): (TimeMetrics, &str) = (TimeMetrics::Days(dice.value), &dice.emoji); match emoji { "🎲" => { mute(handler_entity, chat_id, (mute_time, DICE_DELAY_MS)).await?; } "🎰" => { if dice.value == 64 { ban(handler_entity, chat_id, CASINO_DELAY_MS).await?; } else { mute(handler_entity, chat_id, (mute_time, CASINO_DELAY_MS)).await?; } } _ => { handler_entity .message_sender_builder .text("Π’Π°ΠΊΠΎΠΉ эмодзи Π½Π΅ ΠΈΠΌΠ΅Π΅Ρ‚ привязки ΠΊ ΠΊΠ°ΠΊΠΎΠΌΡƒ Π»ΠΈΠ±ΠΎ Π΄Π΅ΠΉΡΡ‚Π²ΠΈΡŽ Π±ΠΎΡ‚Π°.") .build() .send(&handler_entity.bot_instance) .await?; } } Ok(EventReturn::Finish) }