From 635c18142a63a3c4f9a934ea03213bcebdf5cc6e Mon Sep 17 00:00:00 2001
From: p0lunin <dmytro.polunin@gmail.com>
Date: Sat, 11 Dec 2021 13:11:25 +0200
Subject: [PATCH] 1. Bump futures to 0.3.15 version (Abortable::is_aborted()).
 2. Fix simple_commands_bot example.

---
 Cargo.toml                               |  2 +-
 examples/simple_commands_bot/src/main.rs | 20 ++++++++++++--------
 src/lib.rs                               |  2 +-
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index d829bd11..bea6a71e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -93,7 +93,7 @@ mime = "0.3"
 derive_more = "0.99"
 thiserror = "1.0"
 async-trait = "0.1"
-futures = "0.3"
+futures = "0.3.15"
 pin-project = "1.0"
 serde_with_macros = "1.4"
 
diff --git a/examples/simple_commands_bot/src/main.rs b/examples/simple_commands_bot/src/main.rs
index 5c459402..9f008a43 100644
--- a/examples/simple_commands_bot/src/main.rs
+++ b/examples/simple_commands_bot/src/main.rs
@@ -1,6 +1,7 @@
 use teloxide::{prelude::*, utils::command::BotCommand};
 
 use std::error::Error;
+use std::sync::Arc;
 
 #[derive(BotCommand)]
 #[command(rename = "lowercase", description = "These commands are supported:")]
@@ -14,16 +15,19 @@ enum Command {
 }
 
 async fn answer(
-    cx: UpdateWithCx<AutoSend<Bot>, Message>,
-    command: Command,
+    bot: Arc<AutoSend<Bot>>,
+    message: Arc<Message>,
+    command: Arc<Command>,
 ) -> Result<(), Box<dyn Error + Send + Sync>> {
-    match command {
-        Command::Help => cx.answer(Command::descriptions()).await?,
+    match command.as_ref() {
+        Command::Help => {
+            bot.send_message(message.chat.id, Command::descriptions()).await?
+        }
         Command::Username(username) => {
-            cx.answer(format!("Your username is @{}.", username)).await?
+            bot.send_message(message.chat.id, format!("Your username is @{}.", username)).await?
         }
         Command::UsernameAndAge { username, age } => {
-            cx.answer(format!("Your username is @{} and age is {}.", username, age)).await?
+            bot.send_message(message.chat.id, format!("Your username is @{} and age is {}.", username, age)).await?
         }
     };
 
@@ -41,6 +45,6 @@ async fn run() {
 
     let bot = Bot::from_env().auto_send();
 
-    let bot_name: String = panic!("Your bot's name here");
-    teloxide::commands_repl(bot, bot_name, answer).await;
+    let bot_name: String = "".into();// panic!("Your bot's name here");
+    teloxide::commands_repl(bot, bot_name, answer, Command::ty()).await;
 }
diff --git a/src/lib.rs b/src/lib.rs
index f19d398b..b0a8de2f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -67,7 +67,7 @@ pub use dispatching::repls::{
 };
 
 #[cfg(not(feature = "old_dispatching"))]
-pub use dispatching2::repls::{repl, repl_with_listener};
+pub use dispatching2::repls::{repl, repl_with_listener, commands_repl, commands_repl_with_listener};
 
 mod logging;