mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 06:25:10 +01:00
Added sugar to buttons.rs example
This commit is contained in:
parent
3b618a7b5a
commit
6e484382a9
2 changed files with 6 additions and 4 deletions
|
@ -2,6 +2,7 @@ use std::error::Error;
|
|||
use teloxide::{
|
||||
payloads::SendMessageSetters,
|
||||
prelude::*,
|
||||
sugar::bot::BotMessagesExt,
|
||||
types::{
|
||||
InlineKeyboardButton, InlineKeyboardMarkup, InlineQueryResultArticle, InputMessageContent,
|
||||
InputMessageContentText, Me,
|
||||
|
@ -107,17 +108,17 @@ async fn inline_query_handler(
|
|||
/// **IMPORTANT**: do not send privacy-sensitive data this way!!!
|
||||
/// Anyone can read data stored in the callback button.
|
||||
async fn callback_handler(bot: Bot, q: CallbackQuery) -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||
if let Some(version) = q.data {
|
||||
if let Some(ref version) = q.data {
|
||||
let text = format!("You chose: {version}");
|
||||
|
||||
// Tell telegram that we've seen this query, to remove 🕑 icons from the
|
||||
// clients. You could also use `answer_callback_query`'s optional
|
||||
// parameters to tweak what happens on the client side.
|
||||
bot.answer_callback_query(q.id).await?;
|
||||
bot.answer_callback_query(&q.id).await?;
|
||||
|
||||
// Edit text of the message to which the buttons were attached
|
||||
if let Some(message) = q.message {
|
||||
bot.edit_message_text(message.chat().id, message.id(), text).await?;
|
||||
if let Some(message) = q.regular_message() {
|
||||
bot.edit_text(message, text).await?;
|
||||
} else if let Some(id) = q.inline_message_id {
|
||||
bot.edit_message_text_inline(id, text).await?;
|
||||
}
|
||||
|
|
|
@ -125,6 +125,7 @@ impl BotMessagesExt for Bot {
|
|||
{
|
||||
self.forward_message(to_chat_id, message.chat.id, message.id)
|
||||
}
|
||||
|
||||
fn edit_live_location(
|
||||
&self,
|
||||
message: &Message,
|
||||
|
|
Loading…
Reference in a new issue