now changing state in set_master_pass by using change_state macro
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
use crate::prelude::*;
|
||||
use crate::{change_state, prelude::*};
|
||||
use tokio::task::spawn_blocking;
|
||||
|
||||
/// Actually sets the master password
|
||||
@ -41,13 +41,12 @@ pub async fn set_master_pass(
|
||||
let previous = bot
|
||||
.send_message(msg.chat.id, "Send new master password")
|
||||
.await?;
|
||||
dialogue
|
||||
.update(State::GetNewMasterPass(Handler::new(
|
||||
|bot, msg, db, dialogue, ids, master_pass| {
|
||||
Box::pin(get_master_pass(bot, msg, db, dialogue, ids, master_pass))
|
||||
},
|
||||
MessageIds::from(&previous),
|
||||
)))
|
||||
.await?;
|
||||
Ok(())
|
||||
|
||||
change_state!(
|
||||
dialogue,
|
||||
previous,
|
||||
(),
|
||||
State::GetNewMasterPass,
|
||||
get_master_pass
|
||||
)
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#[macro_export]
|
||||
macro_rules! change_state {
|
||||
($dialogue: expr, $previous: expr, ($($param: ident),*), $message: literal, $next_state: expr, $next_func: ident) => {{
|
||||
($dialogue: expr, $previous: expr, ($($param: ident),*), $next_state: expr, $next_func: ident) => {{
|
||||
$dialogue
|
||||
.update($next_state(Handler::new(
|
||||
move |bot, msg, db, dialogue, ids, param| Box::pin($next_func(bot, msg, db, dialogue, ids, $($param,)* param)),
|
||||
@ -22,7 +22,7 @@ macro_rules! first_handler {
|
||||
) -> $crate::Result<()> {
|
||||
let previous = bot.send_message(msg.chat.id, $message).await?;
|
||||
|
||||
$crate::change_state!(dialogue, previous, (), $message, $next_state, $next_func)
|
||||
$crate::change_state!(dialogue, previous, (), $next_state, $next_func)
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -44,7 +44,7 @@ macro_rules! handler {
|
||||
|
||||
let previous = bot.send_message(msg.chat.id, $message).await?;
|
||||
|
||||
$crate::change_state!(dialogue, previous, ($($param),*), $message, $next_state, $next_func)
|
||||
$crate::change_state!(dialogue, previous, ($($param),*), $next_state, $next_func)
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -72,14 +72,7 @@ macro_rules! ask_name_handler {
|
||||
.reply_markup(markup)
|
||||
.await?;
|
||||
|
||||
$crate::change_state!(
|
||||
dialogue,
|
||||
previous,
|
||||
(),
|
||||
$message,
|
||||
State::GetExistingName,
|
||||
$next_func
|
||||
)
|
||||
$crate::change_state!(dialogue, previous, (), State::GetExistingName, $next_func)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user