diff --git a/examples/dialogue_bot/src/main.rs b/examples/dialogue_bot/src/main.rs index 8ac6a7d2..d59759cb 100644 --- a/examples/dialogue_bot/src/main.rs +++ b/examples/dialogue_bot/src/main.rs @@ -98,13 +98,10 @@ type Dialogue = Coprod!( ReceiveFavouriteMusicState ); -wrap_dialogue!(Wrapper, Dialogue); - -impl Default for Wrapper { - fn default() -> Self { - Self(Dialogue::inject(StartState)) - } -} +wrap_dialogue!( + Wrapper(Dialogue), + default { Self(Dialogue::inject(StartState)) } +); // ============================================================================ // [Control a dialogue] diff --git a/src/dispatching/dialogue/mod.rs b/src/dispatching/dialogue/mod.rs index 803bedda..4c31be5b 100644 --- a/src/dispatching/dialogue/mod.rs +++ b/src/dispatching/dialogue/mod.rs @@ -79,7 +79,7 @@ macro_rules! dispatch { #[macro_export] macro_rules! wrap_dialogue { - ($name:ident, $dialogue:ident) => { + ($name:ident($dialogue:ident), default {$default_block:expr}) => { struct $name($dialogue); impl teloxide::dispatching::dialogue::DialogueWrapper<$dialogue> @@ -89,6 +89,12 @@ macro_rules! wrap_dialogue { $name(d) } } + + impl Default for $name { + fn default() -> $name { + $default_block + } + } }; }