mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-18 15:20:15 +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),
|
ReceiveAge(ReceiveAgeState),
|
||||||
ReceiveLocation(ReceiveLocationState),
|
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))
|
([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"
|
pretty_env_logger = "0.4.0"
|
||||||
futures = "0.3.5"
|
futures = "0.3.5"
|
||||||
smart-default = "0.6.0"
|
|
||||||
derive_more = "0.99.9"
|
derive_more = "0.99.9"
|
||||||
teloxide = { path = "../../", features = ["frunk"] }
|
teloxide = { path = "../../", features = ["frunk"] }
|
||||||
teloxide-macros = { git = "http://github.com/teloxide/teloxide-macros", branch = "master" }
|
teloxide-macros = { git = "http://github.com/teloxide/teloxide-macros", branch = "master" }
|
||||||
|
|
|
@ -3,13 +3,19 @@ mod states;
|
||||||
use crate::dialogue::states::{
|
use crate::dialogue::states::{
|
||||||
ReceiveAgeState, ReceiveFullNameState, ReceiveLocationState, StartState,
|
ReceiveAgeState, ReceiveFullNameState, ReceiveLocationState, StartState,
|
||||||
};
|
};
|
||||||
|
use derive_more::From;
|
||||||
use teloxide_macros::Transition;
|
use teloxide_macros::Transition;
|
||||||
|
|
||||||
#[derive(Transition, SmartDefault, From)]
|
#[derive(Transition, From)]
|
||||||
pub enum Dialogue {
|
pub enum Dialogue {
|
||||||
#[default]
|
|
||||||
Start(StartState),
|
Start(StartState),
|
||||||
ReceiveFullName(ReceiveFullNameState),
|
ReceiveFullName(ReceiveFullNameState),
|
||||||
ReceiveAge(ReceiveAgeState),
|
ReceiveAge(ReceiveAgeState),
|
||||||
ReceiveLocation(ReceiveLocationState),
|
ReceiveLocation(ReceiveLocationState),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Dialogue {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::Start(StartState)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ use crate::dialogue::{
|
||||||
states::receive_location::ReceiveLocationState, Dialogue,
|
states::receive_location::ReceiveLocationState, Dialogue,
|
||||||
};
|
};
|
||||||
use teloxide::prelude::*;
|
use teloxide::prelude::*;
|
||||||
|
use teloxide_macros::teloxide;
|
||||||
|
|
||||||
#[derive(Generic)]
|
#[derive(Generic)]
|
||||||
pub struct ReceiveAgeState {
|
pub struct ReceiveAgeState {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::dialogue::{states::receive_age::ReceiveAgeState, Dialogue};
|
use crate::dialogue::{states::receive_age::ReceiveAgeState, Dialogue};
|
||||||
use teloxide::prelude::*;
|
use teloxide::prelude::*;
|
||||||
|
use teloxide_macros::teloxide;
|
||||||
|
|
||||||
#[derive(Generic)]
|
#[derive(Generic)]
|
||||||
pub struct ReceiveFullNameState;
|
pub struct ReceiveFullNameState;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::dialogue::Dialogue;
|
use crate::dialogue::Dialogue;
|
||||||
use teloxide::prelude::*;
|
use teloxide::prelude::*;
|
||||||
|
use teloxide_macros::teloxide;
|
||||||
|
|
||||||
#[derive(Generic)]
|
#[derive(Generic)]
|
||||||
pub struct ReceiveLocationState {
|
pub struct ReceiveLocationState {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::dialogue::{states::ReceiveFullNameState, Dialogue};
|
use crate::dialogue::{states::ReceiveFullNameState, Dialogue};
|
||||||
use teloxide::prelude::*;
|
use teloxide::prelude::*;
|
||||||
|
use teloxide_macros::teloxide;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct StartState;
|
pub struct StartState;
|
||||||
|
|
|
@ -17,15 +17,8 @@
|
||||||
#![allow(clippy::trivial_regex)]
|
#![allow(clippy::trivial_regex)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate smart_default;
|
|
||||||
#[macro_use]
|
|
||||||
extern crate derive_more;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate frunk;
|
extern crate frunk;
|
||||||
extern crate frunk_core;
|
|
||||||
#[macro_use]
|
|
||||||
extern crate teloxide_macros;
|
|
||||||
|
|
||||||
mod dialogue;
|
mod dialogue;
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,8 @@
|
||||||
//! // No panic because of std::convert::Infallible.
|
//! // No panic because of std::convert::Infallible.
|
||||||
//! let dialogue = dialogue.unwrap();
|
//! let dialogue = dialogue.unwrap();
|
||||||
//! dialogue
|
//! dialogue
|
||||||
//! .react(cx)
|
//! // Instead of () you can pass an arbitrary value, see below.
|
||||||
|
//! .react(cx, ())
|
||||||
//! .await
|
//! .await
|
||||||
//! .expect("Something wrong with the bot!")
|
//! .expect("Something wrong with the bot!")
|
||||||
//! },
|
//! },
|
||||||
|
@ -103,6 +104,10 @@
|
||||||
//! - `#[derive(Transition)]` implements [`Transition`] for `D`, if all the
|
//! - `#[derive(Transition)]` implements [`Transition`] for `D`, if all the
|
||||||
//! variants implement [`SubTransition`].
|
//! 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.
|
//! See [examples/dialogue_bot] as a real example.
|
||||||
//!
|
//!
|
||||||
//! [`Transition`]: crate::dispatching::dialogue::Transition
|
//! [`Transition`]: crate::dispatching::dialogue::Transition
|
||||||
|
|
Loading…
Reference in a new issue