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