Compare commits
4 Commits
c387c0497a
...
9029d4397a
Author | SHA1 | Date | |
---|---|---|---|
doryan | 9029d4397a | ||
doryan | 613b4f10ce | ||
doryan | 2c7abf251f | ||
doryan | f81bc8d3ce |
|
@ -5,7 +5,7 @@ overflow-checks = false
|
|||
|
||||
[package]
|
||||
name = "dorya"
|
||||
version = "0.2"
|
||||
version = "0.2.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
|
|
@ -24,7 +24,10 @@ pub async fn ban_member(
|
|||
|
||||
sleep(DurationSleep::from_millis(delay)).await;
|
||||
|
||||
let user_id: i64 = user.get_id().unwrap();
|
||||
let user_id: i64 = match user.get_id() {
|
||||
Some(id) => id,
|
||||
None => return Ok(EventReturn::Skip)
|
||||
};
|
||||
|
||||
let callback = || async { bot.send(BanChatMember::new(chat_id, user_id)).await };
|
||||
|
||||
|
|
|
@ -25,7 +25,10 @@ pub async fn mute_member(
|
|||
) -> HandlerResult {
|
||||
let (bot, message, mut sender_builder): ExtractedEntityData = handler_entity.extract();
|
||||
|
||||
let user_id: i64 = user.get_id().unwrap();
|
||||
let user_id: i64 = match user.get_id() {
|
||||
Some(id) => id,
|
||||
None => return Ok(EventReturn::Skip)
|
||||
};
|
||||
|
||||
sleep(Duration::from_millis(time.1)).await;
|
||||
|
||||
|
|
|
@ -25,10 +25,6 @@ pub async fn dice_handler(bot: Bot, message: Message) -> HandlerResult {
|
|||
|
||||
let target = TargetUser::Reply(handler_entity.message_reciever.clone());
|
||||
|
||||
handler_entity
|
||||
.message_sender_builder
|
||||
.set_text("Нет ответа на сообщение пользователя.");
|
||||
|
||||
match emoji {
|
||||
"🎲" => {
|
||||
mute_member(handler_entity, chat_id, target, (mute_time, DICE_DELAY_MS)).await?;
|
||||
|
|
|
@ -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