now changing state in set_master_pass by using change_state macro
This commit is contained in:
parent
22c754a256
commit
426a4736ce
16
Cargo.lock
generated
16
Cargo.lock
generated
@ -1903,9 +1903,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls-webpki"
|
name = "rustls-webpki"
|
||||||
version = "0.101.1"
|
version = "0.101.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "15f36a6828982f422756984e47912a7a51dcbc2a197aa791158f8ca61cd8204e"
|
checksum = "513722fd73ad80a71f72b61009ea1b584bcfa1483ca93949c8f290298837fa59"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ring",
|
"ring",
|
||||||
"untrusted",
|
"untrusted",
|
||||||
@ -2118,18 +2118,18 @@ checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.175"
|
version = "1.0.176"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5d25439cd7397d044e2748a6fe2432b5e85db703d6d097bd014b3c0ad1ebff0b"
|
checksum = "76dc28c9523c5d70816e393136b86d48909cfb27cecaa902d338c19ed47164dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.175"
|
version = "1.0.176"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b23f7ade6f110613c0d63858ddb8b94c1041f550eab58a16b371bdf2c9c80ab4"
|
checksum = "a4e7b8c5dc823e3b90651ff1d3808419cd14e5ad76de04feaf37da114e7a306f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -2138,9 +2138,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.103"
|
version = "1.0.104"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d03b412469450d4404fe8499a268edd7f8b79fecb074b0d812ad64ca21f4031b"
|
checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
"ryu",
|
"ryu",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::prelude::*;
|
use crate::{change_state, prelude::*};
|
||||||
use tokio::task::spawn_blocking;
|
use tokio::task::spawn_blocking;
|
||||||
|
|
||||||
/// Actually sets the master password
|
/// Actually sets the master password
|
||||||
@ -41,13 +41,12 @@ pub async fn set_master_pass(
|
|||||||
let previous = bot
|
let previous = bot
|
||||||
.send_message(msg.chat.id, "Send new master password")
|
.send_message(msg.chat.id, "Send new master password")
|
||||||
.await?;
|
.await?;
|
||||||
dialogue
|
|
||||||
.update(State::GetNewMasterPass(Handler::new(
|
change_state!(
|
||||||
|bot, msg, db, dialogue, ids, master_pass| {
|
dialogue,
|
||||||
Box::pin(get_master_pass(bot, msg, db, dialogue, ids, master_pass))
|
previous,
|
||||||
},
|
(),
|
||||||
MessageIds::from(&previous),
|
State::GetNewMasterPass,
|
||||||
)))
|
get_master_pass
|
||||||
.await?;
|
)
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! change_state {
|
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
|
$dialogue
|
||||||
.update($next_state(Handler::new(
|
.update($next_state(Handler::new(
|
||||||
move |bot, msg, db, dialogue, ids, param| Box::pin($next_func(bot, msg, db, dialogue, ids, $($param,)* param)),
|
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<()> {
|
) -> $crate::Result<()> {
|
||||||
let previous = bot.send_message(msg.chat.id, $message).await?;
|
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?;
|
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)
|
.reply_markup(markup)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
$crate::change_state!(
|
$crate::change_state!(dialogue, previous, (), State::GetExistingName, $next_func)
|
||||||
dialogue,
|
|
||||||
previous,
|
|
||||||
(),
|
|
||||||
$message,
|
|
||||||
State::GetExistingName,
|
|
||||||
$next_func
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user