From 59222bc4c61f46c1f1c1983459968831a546ee3b Mon Sep 17 00:00:00 2001 From: doryan Date: Thu, 3 Apr 2025 12:16:17 +0400 Subject: [PATCH] refactor: add imports, format code and etc --- src/actions/unmute.rs | 5 +---- src/middlewares/admin_check_middleware.rs | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/actions/unmute.rs b/src/actions/unmute.rs index f3b2db6..09f8be7 100644 --- a/src/actions/unmute.rs +++ b/src/actions/unmute.rs @@ -21,10 +21,7 @@ pub async fn unmute_member( if let Some(id) = user.get_id() { user_id = id; } else { - sender_builder - .build() - .send(&bot) - .await?; + sender_builder.build().send(&bot).await?; return Ok(EventReturn::Cancel); } diff --git a/src/middlewares/admin_check_middleware.rs b/src/middlewares/admin_check_middleware.rs index 7be8778..cf0b160 100644 --- a/src/middlewares/admin_check_middleware.rs +++ b/src/middlewares/admin_check_middleware.rs @@ -1,8 +1,10 @@ use async_trait::async_trait; use telers::{ errors::{EventErrorKind, HandlerError}, - event::telegram::{HandlerRequest, HandlerResponse}, - middlewares::{InnerMiddleware, Next}, types::Message, + event::telegram::HandlerResponse, + middlewares::{InnerMiddleware, Next}, + types::Message, + Request, }; use anyhow::Error as Reject; @@ -17,16 +19,12 @@ pub struct AdminCheck {} #[async_trait] impl InnerMiddleware for AdminCheck { - async fn call( - &self, - request: HandlerRequest, - next: Next, - ) -> Result { + async fn call(&self, request: Request, next: Next) -> Result { let (bot, message) = (request.clone().bot, request.clone().update); let is_replying_dice: Option = match message.kind().message().unwrap() { Message::Dice(dice) => dice.reply_to_message.clone(), - _ => None + _ => None, }; let admins_list = get_all_admins(&bot, message.chat().unwrap().id()) @@ -41,10 +39,11 @@ impl InnerMiddleware for AdminCheck { } else { if is_replying_dice.is_some() { MessageSender::builder(chat_id) - .text("Недостаточно прав для использования данной команды.") - .build().send(&bot) - .await - .unwrap(); + .text("Недостаточно прав для использования данной команды.") + .build() + .send(&bot) + .await + .unwrap(); } return Err(EventErrorKind::Handler(HandlerError::new(Reject::msg(