create GoHome callback

This commit is contained in:
Akulij 2025-05-01 14:45:53 +03:00
parent 7ec9c540e5
commit 5ec8e2201c

View File

@ -84,6 +84,7 @@ pub enum State {
pub enum Callback {
MoreInfo,
ProjectPage { id: u32 },
GoHome,
}
type CallbackStore = CallbackInfo<Callback>;
@ -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(())