refactor: add imports, format code and etc

This commit is contained in:
doryan 2025-04-03 12:16:17 +04:00
parent 51ec37b766
commit 59222bc4c6
2 changed files with 12 additions and 16 deletions

View File

@ -21,10 +21,7 @@ pub async fn unmute_member(
if let Some(id) = user.get_id() { if let Some(id) = user.get_id() {
user_id = id; user_id = id;
} else { } else {
sender_builder sender_builder.build().send(&bot).await?;
.build()
.send(&bot)
.await?;
return Ok(EventReturn::Cancel); return Ok(EventReturn::Cancel);
} }

View File

@ -1,8 +1,10 @@
use async_trait::async_trait; use async_trait::async_trait;
use telers::{ use telers::{
errors::{EventErrorKind, HandlerError}, errors::{EventErrorKind, HandlerError},
event::telegram::{HandlerRequest, HandlerResponse}, event::telegram::HandlerResponse,
middlewares::{InnerMiddleware, Next}, types::Message, middlewares::{InnerMiddleware, Next},
types::Message,
Request,
}; };
use anyhow::Error as Reject; use anyhow::Error as Reject;
@ -17,16 +19,12 @@ pub struct AdminCheck {}
#[async_trait] #[async_trait]
impl InnerMiddleware for AdminCheck { impl InnerMiddleware for AdminCheck {
async fn call( async fn call(&self, request: Request, next: Next) -> Result<HandlerResponse, EventErrorKind> {
&self,
request: HandlerRequest,
next: Next,
) -> Result<HandlerResponse, EventErrorKind> {
let (bot, message) = (request.clone().bot, request.clone().update); let (bot, message) = (request.clone().bot, request.clone().update);
let is_replying_dice: Option<Message> = match message.kind().message().unwrap() { let is_replying_dice: Option<Message> = match message.kind().message().unwrap() {
Message::Dice(dice) => dice.reply_to_message.clone(), Message::Dice(dice) => dice.reply_to_message.clone(),
_ => None _ => None,
}; };
let admins_list = get_all_admins(&bot, message.chat().unwrap().id()) let admins_list = get_all_admins(&bot, message.chat().unwrap().id())
@ -41,10 +39,11 @@ impl InnerMiddleware for AdminCheck {
} else { } else {
if is_replying_dice.is_some() { if is_replying_dice.is_some() {
MessageSender::builder(chat_id) MessageSender::builder(chat_id)
.text("Недостаточно прав для использования данной команды.") .text("Недостаточно прав для использования данной команды.")
.build().send(&bot) .build()
.await .send(&bot)
.unwrap(); .await
.unwrap();
} }
return Err(EventErrorKind::Handler(HandlerError::new(Reject::msg( return Err(EventErrorKind::Handler(HandlerError::new(Reject::msg(