diff --git a/src/functions/about.rs b/src/functions/about.rs index db7fb63..3005fba 100644 --- a/src/functions/about.rs +++ b/src/functions/about.rs @@ -15,11 +15,8 @@ Bizning botimiz aktiv tarzda shakllantirib boriladi. Buning ustida esa bir necha "#; pub async fn command(bot: &Bot, msg: &Message) -> ResponseResult<()> { - if !msg.chat.is_private() { - return { - hooks::is_private(bot, msg).await.unwrap(); - Ok(()) - }; + if !hooks::is_private(bot, msg).await.unwrap() { + return Ok(()); } bot.send_message_tf(msg.chat.id, TEXT, msg) diff --git a/src/functions/roadmap.rs b/src/functions/roadmap.rs index af4e01d..87fc0a5 100644 --- a/src/functions/roadmap.rs +++ b/src/functions/roadmap.rs @@ -22,11 +22,8 @@ static LINKS: &[(&str, &str)] = &[ ]; pub async fn command(bot: &Bot, msg: &Message) -> ResponseResult<()> { - if !msg.chat.is_private() { - return { - hooks::is_private(bot, msg).await.unwrap(); - Ok(()) - }; + if !hooks::is_private(bot, msg).await.unwrap() { + return Ok(()); } bot.send_message(msg.chat.id, ROADMAP) diff --git a/src/functions/rules.rs b/src/functions/rules.rs index c5da183..a811539 100644 --- a/src/functions/rules.rs +++ b/src/functions/rules.rs @@ -20,11 +20,8 @@ Iltimos qoidalarga oz bo'lsada vaqt ajratishni unutmang, bu muhim! Ushbu guruhda "#; pub async fn command(bot: &Bot, msg: &Message) -> ResponseResult<()> { - if !msg.chat.is_private() { - return { - hooks::is_private(bot, msg).await.unwrap(); - Ok(()) - }; + if !hooks::is_private(bot, msg).await.unwrap() { + return Ok(()); } bot.send_message(msg.chat.id, TEXT) diff --git a/src/hooks/is_private.rs b/src/hooks/is_private.rs index c04d289..4843501 100644 --- a/src/hooks/is_private.rs +++ b/src/hooks/is_private.rs @@ -16,7 +16,11 @@ pub fn keyboard() -> InlineKeyboardMarkup { keyboard.url("Shaxsiy Chat", "https://t.me/rustinabot") } -pub async fn is_private(bot: &Bot, msg: &Message) -> ResponseResult<()> { +pub async fn is_private(bot: &Bot, msg: &Message) -> ResponseResult { + if msg.chat.is_private() { + return Ok(true); + } + match bot.delete_message(msg.chat.id, msg.id).await { Ok(_) => {} Err(_) => {} @@ -30,5 +34,5 @@ pub async fn is_private(bot: &Bot, msg: &Message) -> ResponseResult<()> { delete_timer(bot, &message, 10).await?; - Ok(()) + Ok(false) }