From 5ec8e2201c77ef286ea7e716096289f1ec01cabb Mon Sep 17 00:00:00 2001 From: Akulij Date: Thu, 1 May 2025 14:45:53 +0300 Subject: [PATCH] create GoHome callback --- src/main.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main.rs b/src/main.rs index 4c67b9c..eef5a18 100644 --- a/src/main.rs +++ b/src/main.rs @@ -84,6 +84,7 @@ pub enum State { pub enum Callback { MoreInfo, ProjectPage { id: u32 }, + GoHome, } type CallbackStore = CallbackInfo; @@ -239,6 +240,26 @@ async fn callback_handler(bot: Bot, mut db: DB, q: CallbackQuery) -> BotResult<( bot.send_message(q.from.id, format!("Some project No: {id}")) .await?; } + Callback::GoHome => { + let keyboard = make_start_buttons(&mut db).await?; + + replace_message( + &bot, + &mut db, + q.chat_id().map(|i| i.0).unwrap_or(q.from.id.0 as i64), + q.message.map_or_else( + || { + Err(BotError::MsgTooOld( + "Failed to get message id, probably message too old".to_string(), + )) + }, + |m| Ok(m.id().0), + )?, + "start", + Some(keyboard), + ) + .await? + } }; Ok(())