feat(dice): skip only dice message
This commit is contained in:
parent
2c7abf251f
commit
613b4f10ce
|
@ -1,8 +1,8 @@
|
|||
use async_trait::async_trait;
|
||||
use telers::{
|
||||
errors::{EventErrorKind, HandlerError},
|
||||
event::telegram::{HandlerRequest, HandlerResponse},
|
||||
middlewares::{InnerMiddleware, Next},
|
||||
event::{telegram::{HandlerRequest, HandlerResponse}, EventReturn},
|
||||
middlewares::{InnerMiddleware, Next}, types::Message,
|
||||
};
|
||||
|
||||
use anyhow::Error as Reject;
|
||||
|
@ -24,6 +24,11 @@ impl InnerMiddleware for AdminCheck {
|
|||
) -> 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
|
||||
};
|
||||
|
||||
let admins_list = get_all_admins(&bot, message.chat().unwrap().id())
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -34,12 +39,13 @@ impl InnerMiddleware for AdminCheck {
|
|||
let response = next(request).await?;
|
||||
return Ok(response);
|
||||
} else {
|
||||
MessageSender::builder(chat_id)
|
||||
if is_replying_dice.is_some() {
|
||||
MessageSender::builder(chat_id)
|
||||
.text("Недостаточно прав для использования данной команды.")
|
||||
.build()
|
||||
.send(&bot)
|
||||
.build().send(&bot)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
return Err(EventErrorKind::Handler(HandlerError::new(Reject::msg(
|
||||
"User isn't admin.".to_string(),
|
||||
|
|
Loading…
Reference in New Issue