Prettify examples/dialogues_bot a little bit

This commit is contained in:
Temirkhan Myrzamadi 2020-05-24 17:36:20 +06:00
parent 01dc7a0d42
commit c9393aa5d6
2 changed files with 6 additions and 19 deletions

View file

@ -20,21 +20,15 @@
#[macro_use]
extern crate frunk;
use frunk::Coproduct;
use std::convert::Infallible;
use parse_display::{Display, FromStr};
use teloxide::{
prelude::*,
types::{KeyboardButton, ReplyKeyboardMarkup},
};
use parse_display::{Display, FromStr};
use teloxide::dispatching::dialogue::next;
// ============================================================================
// [Favourite music kinds]
// ============================================================================
#[derive(Copy, Clone, Display, FromStr)]
enum FavouriteMusic {
Rock,
@ -54,9 +48,7 @@ impl FavouriteMusic {
}
}
// ============================================================================
// [A type-safe finite automaton]
// ============================================================================
// Dialogue states.
struct StartState;
@ -103,9 +95,7 @@ wrap_dialogue!(
default { Self(Dialogue::inject(StartState)) }
);
// ============================================================================
// [Control a dialogue]
// ============================================================================
// Transition functions.
type Cx<State> = DialogueDispatcherHandlerCx<Message, State, Infallible>;
type Res = ResponseResult<DialogueStage<Wrapper>>;
@ -171,10 +161,6 @@ async fn favourite_music(cx: Cx<ReceiveFavouriteMusicState>) -> Res {
}
}
// ============================================================================
// [Run!]
// ============================================================================
#[tokio::main]
async fn main() {
run().await;

View file

@ -17,5 +17,6 @@ pub use crate::{
};
pub use tokio::sync::mpsc::UnboundedReceiver;
pub use frunk::Coproduct;
pub use futures::StreamExt;