Skip to content

Commit

Permalink
private hook close updated
Browse files Browse the repository at this point in the history
  • Loading branch information
orzklv committed Nov 22, 2023
1 parent 061f9e6 commit 07b414c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
7 changes: 2 additions & 5 deletions src/functions/about.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 2 additions & 5 deletions src/functions/roadmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 2 additions & 5 deletions src/functions/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions src/hooks/is_private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> {
if msg.chat.is_private() {
return Ok(true);
}

match bot.delete_message(msg.chat.id, msg.id).await {
Ok(_) => {}
Err(_) => {}
Expand All @@ -30,5 +34,5 @@ pub async fn is_private(bot: &Bot, msg: &Message) -> ResponseResult<()> {

delete_timer(bot, &message, 10).await?;

Ok(())
Ok(false)
}

0 comments on commit 07b414c

Please sign in to comment.