Compare commits
No commits in common. "9029d4397a743b13b673a91b0178edb56dd76b74" and "c387c0497abdc1e70ea76e1902371f21229078f1" have entirely different histories.
9029d4397a
...
c387c0497a
|
@ -5,7 +5,7 @@ overflow-checks = false
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "dorya"
|
name = "dorya"
|
||||||
version = "0.2.0"
|
version = "0.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# 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;
|
sleep(DurationSleep::from_millis(delay)).await;
|
||||||
|
|
||||||
let user_id: i64 = match user.get_id() {
|
let user_id: i64 = user.get_id().unwrap();
|
||||||
Some(id) => id,
|
|
||||||
None => return Ok(EventReturn::Skip)
|
|
||||||
};
|
|
||||||
|
|
||||||
let callback = || async { bot.send(BanChatMember::new(chat_id, user_id)).await };
|
let callback = || async { bot.send(BanChatMember::new(chat_id, user_id)).await };
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,7 @@ pub async fn mute_member(
|
||||||
) -> HandlerResult {
|
) -> HandlerResult {
|
||||||
let (bot, message, mut sender_builder): ExtractedEntityData = handler_entity.extract();
|
let (bot, message, mut sender_builder): ExtractedEntityData = handler_entity.extract();
|
||||||
|
|
||||||
let user_id: i64 = match user.get_id() {
|
let user_id: i64 = user.get_id().unwrap();
|
||||||
Some(id) => id,
|
|
||||||
None => return Ok(EventReturn::Skip)
|
|
||||||
};
|
|
||||||
|
|
||||||
sleep(Duration::from_millis(time.1)).await;
|
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());
|
let target = TargetUser::Reply(handler_entity.message_reciever.clone());
|
||||||
|
|
||||||
|
handler_entity
|
||||||
|
.message_sender_builder
|
||||||
|
.set_text("Нет ответа на сообщение пользователя.");
|
||||||
|
|
||||||
match emoji {
|
match emoji {
|
||||||
"🎲" => {
|
"🎲" => {
|
||||||
mute_member(handler_entity, chat_id, target, (mute_time, DICE_DELAY_MS)).await?;
|
mute_member(handler_entity, chat_id, target, (mute_time, DICE_DELAY_MS)).await?;
|
||||||
|
|
|
@ -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}, EventReturn},
|
event::telegram::{HandlerRequest, HandlerResponse},
|
||||||
middlewares::{InnerMiddleware, Next}, types::Message,
|
middlewares::{InnerMiddleware, Next},
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::Error as Reject;
|
use anyhow::Error as Reject;
|
||||||
|
@ -24,11 +24,6 @@ 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();
|
||||||
|
@ -39,13 +34,12 @@ impl InnerMiddleware for AdminCheck {
|
||||||
let response = next(request).await?;
|
let response = next(request).await?;
|
||||||
return Ok(response);
|
return Ok(response);
|
||||||
} else {
|
} else {
|
||||||
if is_replying_dice.is_some() {
|
MessageSender::builder(chat_id)
|
||||||
MessageSender::builder(chat_id)
|
|
||||||
.text("Недостаточно прав для использования данной команды.")
|
.text("Недостаточно прав для использования данной команды.")
|
||||||
.build().send(&bot)
|
.build()
|
||||||
|
.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