mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +01:00
Prettify examples/dialogues_bot a little bit
This commit is contained in:
parent
01dc7a0d42
commit
c9393aa5d6
2 changed files with 6 additions and 19 deletions
|
@ -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;
|
||||
|
|
|
@ -17,5 +17,6 @@ pub use crate::{
|
|||
};
|
||||
|
||||
pub use tokio::sync::mpsc::UnboundedReceiver;
|
||||
pub use frunk::Coproduct;
|
||||
|
||||
pub use futures::StreamExt;
|
||||
|
|
Loading…
Reference in a new issue