Compare commits
No commits in common. "9029d4397a743b13b673a91b0178edb56dd76b74" and "c387c0497abdc1e70ea76e1902371f21229078f1" have entirely different histories.
9029d4397a
...
c387c0497a
|
@ -5,7 +5,7 @@ overflow-checks = false
|
|||
|
||||
[package]
|
||||
name = "dorya"
|
||||
version = "0.2.0"
|
||||
version = "0.2"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
|
|
@ -24,10 +24,7 @@ pub async fn ban_member(
|
|||
|
||||
sleep(DurationSleep::from_millis(delay)).await;
|
||||
|
||||
let user_id: i64 = match user.get_id() {
|
||||
Some(id) => id,
|
||||
None => return Ok(EventReturn::Skip)
|
||||
};
|
||||
let user_id: i64 = user.get_id().unwrap();
|
||||
|
||||
let callback = || async { bot.send(BanChatMember::new(chat_id, user_id)).await };
|
||||
|
||||
|
|
|
@ -25,10 +25,7 @@ pub async fn mute_member(
|
|||
) -> HandlerResult {
|
||||
let (bot, message, mut sender_builder): ExtractedEntityData = handler_entity.extract();
|
||||
|
||||
let user_id: i64 = match user.get_id() {
|
||||
Some(id) => id,
|
||||
None => return Ok(EventReturn::Skip)
|
||||
};
|
||||
let user_id: i64 = user.get_id().unwrap();
|
||||
|
||||
sleep(Duration::from_millis(time.1)).await;
|
||||
|
||||
|
|
|
@ -25,6 +25,10 @@ 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}, EventReturn},
|
||||
middlewares::{InnerMiddleware, Next}, types::Message,
|
||||
event::telegram::{HandlerRequest, HandlerResponse},
|
||||
middlewares::{InnerMiddleware, Next},
|
||||
};
|
||||
|
||||
use anyhow::Error as Reject;
|
||||
|
@ -24,11 +24,6 @@ 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();
|
||||
|
@ -39,13 +34,12 @@ impl InnerMiddleware for AdminCheck {
|
|||
let response = next(request).await?;
|
||||
return Ok(response);
|
||||
} else {
|
||||
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