mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-03 09:49:07 +01:00
Fix the docs
This commit is contained in:
parent
8b7a6e019f
commit
f9c192aad0
9 changed files with 24 additions and 11 deletions
|
@ -203,6 +203,12 @@ pub enum Dialogue {
|
|||
ReceiveAge(ReceiveAgeState),
|
||||
ReceiveLocation(ReceiveLocationState),
|
||||
}
|
||||
|
||||
impl Default for Dialogue {
|
||||
fn default() -> Self {
|
||||
Self::Start(StartState)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
([dialogue_bot/src/dialogue/states/start.rs](https://github.com/teloxide/teloxide/blob/master/examples/dialogue_bot/src/dialogue/states/start.rs))
|
||||
|
|
|
@ -15,7 +15,6 @@ frunk-core = { git = "https://github.com/Hirrolot/frunk", branch = "append-to-hl
|
|||
|
||||
pretty_env_logger = "0.4.0"
|
||||
futures = "0.3.5"
|
||||
smart-default = "0.6.0"
|
||||
derive_more = "0.99.9"
|
||||
teloxide = { path = "../../", features = ["frunk"] }
|
||||
teloxide-macros = { git = "http://github.com/teloxide/teloxide-macros", branch = "master" }
|
||||
|
|
|
@ -3,13 +3,19 @@ mod states;
|
|||
use crate::dialogue::states::{
|
||||
ReceiveAgeState, ReceiveFullNameState, ReceiveLocationState, StartState,
|
||||
};
|
||||
use derive_more::From;
|
||||
use teloxide_macros::Transition;
|
||||
|
||||
#[derive(Transition, SmartDefault, From)]
|
||||
#[derive(Transition, From)]
|
||||
pub enum Dialogue {
|
||||
#[default]
|
||||
Start(StartState),
|
||||
ReceiveFullName(ReceiveFullNameState),
|
||||
ReceiveAge(ReceiveAgeState),
|
||||
ReceiveLocation(ReceiveLocationState),
|
||||
}
|
||||
|
||||
impl Default for Dialogue {
|
||||
fn default() -> Self {
|
||||
Self::Start(StartState)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ use crate::dialogue::{
|
|||
states::receive_location::ReceiveLocationState, Dialogue,
|
||||
};
|
||||
use teloxide::prelude::*;
|
||||
use teloxide_macros::teloxide;
|
||||
|
||||
#[derive(Generic)]
|
||||
pub struct ReceiveAgeState {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::dialogue::{states::receive_age::ReceiveAgeState, Dialogue};
|
||||
use teloxide::prelude::*;
|
||||
use teloxide_macros::teloxide;
|
||||
|
||||
#[derive(Generic)]
|
||||
pub struct ReceiveFullNameState;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::dialogue::Dialogue;
|
||||
use teloxide::prelude::*;
|
||||
use teloxide_macros::teloxide;
|
||||
|
||||
#[derive(Generic)]
|
||||
pub struct ReceiveLocationState {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::dialogue::{states::ReceiveFullNameState, Dialogue};
|
||||
use teloxide::prelude::*;
|
||||
use teloxide_macros::teloxide;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct StartState;
|
||||
|
|
|
@ -17,15 +17,8 @@
|
|||
#![allow(clippy::trivial_regex)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate smart_default;
|
||||
#[macro_use]
|
||||
extern crate derive_more;
|
||||
#[macro_use]
|
||||
extern crate frunk;
|
||||
extern crate frunk_core;
|
||||
#[macro_use]
|
||||
extern crate teloxide_macros;
|
||||
|
||||
mod dialogue;
|
||||
|
||||
|
|
|
@ -88,7 +88,8 @@
|
|||
//! // No panic because of std::convert::Infallible.
|
||||
//! let dialogue = dialogue.unwrap();
|
||||
//! dialogue
|
||||
//! .react(cx)
|
||||
//! // Instead of () you can pass an arbitrary value, see below.
|
||||
//! .react(cx, ())
|
||||
//! .await
|
||||
//! .expect("Something wrong with the bot!")
|
||||
//! },
|
||||
|
@ -103,6 +104,10 @@
|
|||
//! - `#[derive(Transition)]` implements [`Transition`] for `D`, if all the
|
||||
//! variants implement [`SubTransition`].
|
||||
//!
|
||||
//! `()` in `.react(cx, ())` is an arbitrary value, which you can pass into
|
||||
//! subtransitions. Just append `ans: T` to the parameters of the
|
||||
//! subtransitions to pass a differen type.
|
||||
//!
|
||||
//! See [examples/dialogue_bot] as a real example.
|
||||
//!
|
||||
//! [`Transition`]: crate::dispatching::dialogue::Transition
|
||||
|
|
Loading…
Reference in a new issue