use telers::{ event::{telegram::HandlerResult, EventReturn}, types::{Dice, Message}, Bot, }; use crate::{ handlers::actions::{ban::ban, mute::mute}, types::{ enums::time_metrics::TimeMetrics, structs::{bot_entity::BotEntity, 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 bot_entity: BotEntity = BotEntity { bot_instance: bot, receive_message: message, message_sender: MessageSender::new(chat_id), }; let (mute_time, emoji): (TimeMetrics, &str) = (TimeMetrics::Days(dice.value), &dice.emoji); match emoji { "🎲" => { mute(bot_entity, (mute_time, DICE_DELAY_MS)).await?; } "🎰" => { if dice.value == 64 { ban(bot_entity, CASINO_DELAY_MS).await?; } else { mute(bot_entity, (mute_time, CASINO_DELAY_MS)).await?; } } _ => { bot_entity .message_sender .text("Π’Π°ΠΊΠΎΠΉ эмодзи Π½Π΅ ΠΈΠΌΠ΅Π΅Ρ‚ привязки ΠΊ ΠΊΠ°ΠΊΠΎΠΌΡƒ Π»ΠΈΠ±ΠΎ Π΄Π΅ΠΉΡΡ‚Π²ΠΈΡŽ Π±ΠΎΡ‚Π°.") .send(&bot_entity.bot_instance) .await?; } } Ok(EventReturn::Finish) }