2023-05-03 18:08:14 +00:00
|
|
|
use sea_orm::prelude::*;
|
|
|
|
use teloxide::{adaptors::Throttle, prelude::*};
|
|
|
|
|
2023-05-06 17:20:33 +00:00
|
|
|
use crate::{
|
|
|
|
errors::NoMessageText,
|
2023-05-07 16:04:48 +00:00
|
|
|
handlers::{markups::deletion_markup, utils::validate_field, MainDialogue, PackagedHandler},
|
2023-05-06 17:20:33 +00:00
|
|
|
};
|
2023-05-03 18:08:14 +00:00
|
|
|
|
2023-05-09 17:27:58 +00:00
|
|
|
/// Function to handle GetPassword state
|
2023-05-03 18:08:14 +00:00
|
|
|
pub async fn get_password(
|
|
|
|
bot: Throttle<Bot>,
|
|
|
|
msg: Message,
|
|
|
|
db: DatabaseConnection,
|
|
|
|
dialogue: MainDialogue,
|
|
|
|
next: PackagedHandler<String>,
|
|
|
|
) -> crate::Result<()> {
|
2023-05-06 17:20:33 +00:00
|
|
|
let text = msg.text().ok_or(NoMessageText)?.trim().to_owned();
|
2023-05-03 18:08:14 +00:00
|
|
|
super::generic::generic(
|
|
|
|
bot,
|
|
|
|
text,
|
|
|
|
msg,
|
|
|
|
db,
|
|
|
|
dialogue,
|
2023-05-07 16:04:48 +00:00
|
|
|
|bot, msg, _, password| {
|
|
|
|
Box::pin(async move {
|
|
|
|
let is_valid = validate_field(password);
|
|
|
|
if !is_valid {
|
|
|
|
bot.send_message(msg.chat.id, "Invalid password")
|
|
|
|
.reply_markup(deletion_markup())
|
|
|
|
.await?;
|
|
|
|
}
|
|
|
|
Ok(is_valid)
|
|
|
|
})
|
|
|
|
},
|
2023-05-03 18:08:14 +00:00
|
|
|
next,
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
}
|