use sea_orm::prelude::*; use teloxide::{adaptors::Throttle, prelude::*}; use crate::{utils::validate_field, MainDialogue}; /// Function to handle GetPassword state pub async fn get_password( bot: Throttle, msg: Message, db: DatabaseConnection, dialogue: MainDialogue, next: super::PackagedHandler, ) -> crate::Result<()> { super::generic::generic( bot, msg, db, dialogue, |bot, msg, _, password| { Box::pin(async move { let is_valid = validate_field(password); if !is_valid { let msg = bot .send_message(msg.chat.id, "Invalid password. Try again") .await?; return Ok(Some(msg)); } Ok(None) }) }, "Couldn't get the text of the message. Send the password again", next, ) .await }