From 239ff94c0e203dca60bdb0ca7ec9063e2659b8e6 Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Sat, 13 Mar 2021 23:35:48 +0600 Subject: [PATCH] Fix this fucking bullshit --- README.md | 22 +++++++++++----------- src/dispatching/dialogue/mod.rs | 10 +++++----- src/lib.rs | 6 +++--- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 71066c35..8d02f42a 100644 --- a/README.md +++ b/README.md @@ -102,11 +102,11 @@ async fn main() { teloxide::enable_logging!(); log::info!("Starting dices_bot..."); - let bot = Bot::from_env(); + let bot = Bot::from_env().auto_send(); teloxide::repl(bot, |message| async move { - message.answer_dice().send().await?; - ResponseResult::<()>::Ok(()) + message.answer_dice().await?; + respond(()) }) .await; } @@ -143,7 +143,7 @@ enum Command { UsernameAndAge { username: String, age: u8 }, } -async fn answer(cx: UpdateWithCx, command: Command) -> ResponseResult<()> { +async fn answer(cx: UpdateWithCx, Message>, command: Command) -> ResponseResult<()> { match command { Command::Help => cx.answer(Command::descriptions()).send().await?, Command::Username(username) => { @@ -162,7 +162,7 @@ async fn main() { teloxide::enable_logging!(); log::info!("Starting simple_commands_bot..."); - let bot = Bot::from_env(); + 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; @@ -213,7 +213,7 @@ When a user sends a message to our bot and such a dialogue does not exist yet, a pub struct StartState; #[teloxide(subtransition)] -async fn start(_state: StartState, cx: TransitionIn, _ans: String) -> TransitionOut { +async fn start(_state: StartState, cx: TransitionIn>, _ans: String) -> TransitionOut { cx.answer_str("Let's start! What's your full name?").await?; next(ReceiveFullNameState) } @@ -234,7 +234,7 @@ pub struct ReceiveFullNameState; #[teloxide(subtransition)] async fn receive_full_name( state: ReceiveFullNameState, - cx: TransitionIn, + cx: TransitionIn>, ans: String, ) -> TransitionOut { cx.answer_str("How old are you?").await?; @@ -259,7 +259,7 @@ pub struct ReceiveAgeState { #[teloxide(subtransition)] async fn receive_age_state( state: ReceiveAgeState, - cx: TransitionIn, + cx: TransitionIn>, ans: String, ) -> TransitionOut { match ans.parse::() { @@ -293,7 +293,7 @@ pub struct ReceiveLocationState { #[teloxide(subtransition)] async fn receive_location( state: ReceiveLocationState, - cx: TransitionIn, + cx: TransitionIn>, ans: String, ) -> TransitionOut { cx.answer_str(format!("Full name: {}\nAge: {}\nLocation: {}", state.full_name, state.age, ans)) @@ -317,7 +317,7 @@ async fn main() { teloxide::enable_logging!(); log::info!("Starting dialogue_bot..."); - let bot = Bot::from_env(); + let bot = Bot::from_env().auto_send(); teloxide::dialogues_repl(bot, |message, dialogue| async move { handle_message(message, dialogue).await.expect("Something wrong with the bot!") @@ -325,7 +325,7 @@ async fn main() { .await; } -async fn handle_message(cx: UpdateWithCx, dialogue: Dialogue) -> TransitionOut { +async fn handle_message(cx: UpdateWithCx, Message>, dialogue: Dialogue) -> TransitionOut { match cx.update.text_owned() { None => { cx.answer_str("Send me a text message.").await?; diff --git a/src/dispatching/dialogue/mod.rs b/src/dispatching/dialogue/mod.rs index a8cdddc7..bf919e94 100644 --- a/src/dispatching/dialogue/mod.rs +++ b/src/dispatching/dialogue/mod.rs @@ -42,17 +42,17 @@ //! type Out = TransitionOut; //! //! #[teloxide(subtransition)] -//! async fn _1_transition(_state: _1State, _cx: TransitionIn) -> Out { +//! async fn _1_transition(_state: _1State, _cx: TransitionIn>) -> Out { //! todo!() //! } //! //! #[teloxide(subtransition)] -//! async fn _2_transition(_state: _2State, _cx: TransitionIn) -> Out { +//! async fn _2_transition(_state: _2State, _cx: TransitionIn>) -> Out { //! todo!() //! } //! //! #[teloxide(subtransition)] -//! async fn _3_transition(_state: _3State, _cx: TransitionIn) -> Out { +//! async fn _3_transition(_state: _3State, _cx: TransitionIn>) -> Out { //! todo!() //! } //! @@ -69,7 +69,7 @@ //! } //! } //! -//! type In = DialogueWithCx; +//! type In = DialogueWithCx, Message, D, Infallible>; //! //! #[tokio::main] //! async fn main() { @@ -80,7 +80,7 @@ //! teloxide::enable_logging!(); //! log::info!("Starting dialogue_bot!"); //! -//! let bot = Bot::from_env(); +//! let bot = Bot::from_env().auto_send(); //! //! Dispatcher::new(bot) //! .messages_handler(DialogueDispatcher::new( diff --git a/src/lib.rs b/src/lib.rs index 47f37e90..e5c27cd0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,11 +13,11 @@ //! teloxide::enable_logging!(); //! log::info!("Starting dices_bot..."); //! -//! let bot = Bot::from_env(); +//! let bot = Bot::from_env().auto_send(); //! //! teloxide::repl(bot, |message| async move { -//! message.answer_dice().send().await?; -//! ResponseResult::<()>::Ok(()) +//! message.answer_dice().await?; +//! respond(()) //! }) //! .await; //! # }