mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +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::{
|
use teloxide::{
|
||||||
payloads::SendMessageSetters,
|
payloads::SendMessageSetters,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
|
sugar::bot::BotMessagesExt,
|
||||||
types::{
|
types::{
|
||||||
InlineKeyboardButton, InlineKeyboardMarkup, InlineQueryResultArticle, InputMessageContent,
|
InlineKeyboardButton, InlineKeyboardMarkup, InlineQueryResultArticle, InputMessageContent,
|
||||||
InputMessageContentText, Me,
|
InputMessageContentText, Me,
|
||||||
|
@ -107,17 +108,17 @@ async fn inline_query_handler(
|
||||||
/// **IMPORTANT**: do not send privacy-sensitive data this way!!!
|
/// **IMPORTANT**: do not send privacy-sensitive data this way!!!
|
||||||
/// Anyone can read data stored in the callback button.
|
/// Anyone can read data stored in the callback button.
|
||||||
async fn callback_handler(bot: Bot, q: CallbackQuery) -> Result<(), Box<dyn Error + Send + Sync>> {
|
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}");
|
let text = format!("You chose: {version}");
|
||||||
|
|
||||||
// Tell telegram that we've seen this query, to remove 🕑 icons from the
|
// Tell telegram that we've seen this query, to remove 🕑 icons from the
|
||||||
// clients. You could also use `answer_callback_query`'s optional
|
// clients. You could also use `answer_callback_query`'s optional
|
||||||
// parameters to tweak what happens on the client side.
|
// 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
|
// Edit text of the message to which the buttons were attached
|
||||||
if let Some(message) = q.message {
|
if let Some(message) = q.regular_message() {
|
||||||
bot.edit_message_text(message.chat().id, message.id(), text).await?;
|
bot.edit_text(message, text).await?;
|
||||||
} else if let Some(id) = q.inline_message_id {
|
} else if let Some(id) = q.inline_message_id {
|
||||||
bot.edit_message_text_inline(id, text).await?;
|
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)
|
self.forward_message(to_chat_id, message.chat.id, message.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn edit_live_location(
|
fn edit_live_location(
|
||||||
&self,
|
&self,
|
||||||
message: &Message,
|
message: &Message,
|
||||||
|
|
Loading…
Reference in a new issue