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() {
user_id = id;
} else {
sender_builder
.build()
.send(&bot)
.await?;
sender_builder.build().send(&bot).await?;
return Ok(EventReturn::Cancel);
}

View File

@ -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<HandlerResponse, EventErrorKind> {
async fn call(&self, request: Request, next: Next) -> Result<HandlerResponse, EventErrorKind> {
let (bot, message) = (request.clone().bot, request.clone().update);
let is_replying_dice: Option<Message> = 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(