mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +01:00
Merge pull request #708 from teloxide/fix_buttons_example
Fix command parsing in `examples/button.rs`
Former-commit-id: 550982b7fe
This commit is contained in:
commit
7a3257a5f4
1 changed files with 3 additions and 2 deletions
|
@ -4,7 +4,7 @@ use teloxide::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
types::{
|
types::{
|
||||||
InlineKeyboardButton, InlineKeyboardMarkup, InlineQueryResultArticle, InputMessageContent,
|
InlineKeyboardButton, InlineKeyboardMarkup, InlineQueryResultArticle, InputMessageContent,
|
||||||
InputMessageContentText,
|
InputMessageContentText, Me,
|
||||||
},
|
},
|
||||||
utils::command::BotCommands,
|
utils::command::BotCommands,
|
||||||
};
|
};
|
||||||
|
@ -61,9 +61,10 @@ fn make_keyboard() -> InlineKeyboardMarkup {
|
||||||
async fn message_handler(
|
async fn message_handler(
|
||||||
m: Message,
|
m: Message,
|
||||||
bot: AutoSend<Bot>,
|
bot: AutoSend<Bot>,
|
||||||
|
me: Me,
|
||||||
) -> Result<(), Box<dyn Error + Send + Sync>> {
|
) -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||||
if let Some(text) = m.text() {
|
if let Some(text) = m.text() {
|
||||||
match BotCommands::parse(text, "buttons") {
|
match BotCommands::parse(text, me.username()) {
|
||||||
Ok(Command::Help) => {
|
Ok(Command::Help) => {
|
||||||
// Just send the description of all commands.
|
// Just send the description of all commands.
|
||||||
bot.send_message(m.chat.id, Command::descriptions().to_string()).await?;
|
bot.send_message(m.chat.id, Command::descriptions().to_string()).await?;
|
||||||
|
|
Loading…
Reference in a new issue