mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-03 09:49:07 +01:00
Properly handle callback queries in examples/buttons.rs
Former-commit-id: 376ffc85f9
This commit is contained in:
parent
7a3257a5f4
commit
f10bb5c3e0
1 changed files with 11 additions and 9 deletions
|
@ -112,15 +112,17 @@ async fn callback_handler(
|
||||||
if let Some(version) = q.data {
|
if let Some(version) = q.data {
|
||||||
let text = format!("You chose: {version}");
|
let text = format!("You chose: {version}");
|
||||||
|
|
||||||
match q.message {
|
// Tell telegram that we've seen this query, to remove 🕑 icons from the
|
||||||
Some(Message { id, chat, .. }) => {
|
//
|
||||||
bot.edit_message_text(chat.id, id, text).await?;
|
// clients. You could also use `answer_callback_query`'s optional
|
||||||
}
|
// parameters to tweak what happens on the client side.
|
||||||
None => {
|
bot.answer_callback_query(q.id).await?;
|
||||||
if let Some(id) = q.inline_message_id {
|
|
||||||
bot.edit_message_text_inline(id, text).await?;
|
// Edit text of the message to which the buttons were attached
|
||||||
}
|
if let Some(Message { id, chat, .. }) = q.message {
|
||||||
}
|
bot.edit_message_text(chat.id, id, text).await?;
|
||||||
|
} else if let Some(id) = q.inline_message_id {
|
||||||
|
bot.edit_message_text_inline(id, text).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!("You chose: {}", version);
|
log::info!("You chose: {}", version);
|
||||||
|
|
Loading…
Reference in a new issue