Switched to inline buttons when getting the account name, finished decrypt and delete Callback commands
This commit is contained in:
@ -1,60 +0,0 @@
|
||||
use crate::prelude::*;
|
||||
|
||||
/// Function to handle GetExistingName state
|
||||
pub async fn get_existing_name(
|
||||
bot: Throttle<Bot>,
|
||||
msg: Message,
|
||||
db: DatabaseConnection,
|
||||
dialogue: MainDialogue,
|
||||
next: PackagedHandler<String>,
|
||||
) -> crate::Result<()> {
|
||||
let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
|
||||
|
||||
let mut handler = next.lock().await;
|
||||
if handler.func.is_none() {
|
||||
let _ = dialogue.exit().await;
|
||||
return Err(HandlerUsed.into());
|
||||
}
|
||||
|
||||
let text = match msg.text() {
|
||||
Some(text) => text.trim(),
|
||||
None => {
|
||||
let msg = bot
|
||||
.send_message(
|
||||
msg.chat.id,
|
||||
"Couldn't get the text of the message. Send the name again",
|
||||
)
|
||||
.reply_markup(account_list_markup(user_id, &db).await?)
|
||||
.await?;
|
||||
handler.previous = MessageIds::from(&msg);
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
||||
if text == "/cancel" {
|
||||
dialogue.exit().await?;
|
||||
handler
|
||||
.previous
|
||||
.alter_message(&bot, "Successfully cancelled", deletion_markup(), None)
|
||||
.await?;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if !Account::exists(user_id, text, &db).await? {
|
||||
let msg = bot
|
||||
.send_message(msg.chat.id, "Account doesn't exists. Try again")
|
||||
.reply_markup(account_list_markup(user_id, &db).await?)
|
||||
.await?;
|
||||
handler.previous = MessageIds::from(&msg);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let func = handler.func.take().unwrap();
|
||||
let text = text.to_owned();
|
||||
|
||||
if let Err(err) = func(bot, msg, db, dialogue.clone(), handler.previous, text).await {
|
||||
let _ = dialogue.exit().await;
|
||||
return Err(err);
|
||||
}
|
||||
Ok(())
|
||||
}
|
@ -39,7 +39,7 @@ impl MessageIds {
|
||||
}
|
||||
|
||||
match edit.send_ref().await {
|
||||
Ok(msg) => return Ok(()),
|
||||
Ok(_) => return Ok(()),
|
||||
Err(RequestError::Api(_)) => (),
|
||||
Err(err) => return Err(err.into()),
|
||||
};
|
||||
|
@ -1,7 +1,6 @@
|
||||
//! This module consists of endpoints to handle the state
|
||||
|
||||
mod generic;
|
||||
mod get_existing_name;
|
||||
mod get_login;
|
||||
mod get_master_pass;
|
||||
mod get_new_master_pass;
|
||||
@ -10,7 +9,6 @@ mod get_password;
|
||||
mod get_user;
|
||||
mod handler;
|
||||
|
||||
pub use get_existing_name::get_existing_name;
|
||||
pub use get_login::get_login;
|
||||
pub use get_master_pass::get_master_pass;
|
||||
pub use get_new_master_pass::get_new_master_pass;
|
||||
@ -26,7 +24,6 @@ use teloxide::dispatching::dialogue::InMemStorage;
|
||||
pub enum State {
|
||||
#[default]
|
||||
Start,
|
||||
GetExistingName(PackagedHandler<String>),
|
||||
GetNewName(PackagedHandler<String>),
|
||||
GetMasterPass(PackagedHandler<String>),
|
||||
GetNewMasterPass(PackagedHandler<String>),
|
||||
|
Reference in New Issue
Block a user