Locale bug fixing
This commit is contained in:
parent
e8be611404
commit
9af37f78b2
@ -5,13 +5,11 @@ use std::fmt::Write;
|
|||||||
use teloxide::types::ParseMode;
|
use teloxide::types::ParseMode;
|
||||||
use tokio::task::spawn_blocking;
|
use tokio::task::spawn_blocking;
|
||||||
|
|
||||||
const MESSAGE_HEADER: &str = "Passwords:";
|
|
||||||
const PASSWORD_LENGTH: usize = 32;
|
const PASSWORD_LENGTH: usize = 32;
|
||||||
const PASSWORD_PADDING_LENGTH: usize = 3;
|
const PASSWORD_PADDING_LENGTH: usize = 3;
|
||||||
const AMOUNT_OF_PASSWORDS: usize = 10;
|
const AMOUNT_OF_PASSWORDS: usize = 10;
|
||||||
type PasswordArray = [ArrayString<PASSWORD_LENGTH>; AMOUNT_OF_PASSWORDS];
|
type PasswordArray = [ArrayString<PASSWORD_LENGTH>; AMOUNT_OF_PASSWORDS];
|
||||||
const BUFFER_LENGTH: usize =
|
const BUFFER_LENGTH: usize = (PASSWORD_LENGTH + PASSWORD_PADDING_LENGTH) * AMOUNT_OF_PASSWORDS;
|
||||||
MESSAGE_HEADER.len() + (PASSWORD_LENGTH + PASSWORD_PADDING_LENGTH) * AMOUNT_OF_PASSWORDS;
|
|
||||||
|
|
||||||
/// Handles /`gen_password` command by generating 10 copyable passwords and sending them to the user
|
/// Handles /`gen_password` command by generating 10 copyable passwords and sending them to the user
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -20,7 +18,7 @@ pub async fn gen_password(
|
|||||||
msg: Message,
|
msg: Message,
|
||||||
locale: LocaleRef,
|
locale: LocaleRef,
|
||||||
) -> crate::Result<()> {
|
) -> crate::Result<()> {
|
||||||
let mut message: ArrayString<BUFFER_LENGTH> = MESSAGE_HEADER.try_into().unwrap();
|
let mut message = ArrayString::<BUFFER_LENGTH>::new();
|
||||||
let passwords: PasswordArray = spawn_blocking(generate_passwords).await?;
|
let passwords: PasswordArray = spawn_blocking(generate_passwords).await?;
|
||||||
for password in passwords {
|
for password in passwords {
|
||||||
write!(message, "\n`{password}`").unwrap();
|
write!(message, "\n`{password}`").unwrap();
|
||||||
|
@ -26,7 +26,12 @@ fn process_validity(validity: PasswordValidity, locale: LocaleRef) -> Result<(),
|
|||||||
write!(error_text, "\n* {}", locale.master_pass_too_short).unwrap();
|
write!(error_text, "\n* {}", locale.master_pass_too_short).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
error_text.push_str(&locale.change_master_password_and_send_again);
|
write!(
|
||||||
|
error_text,
|
||||||
|
"\n{}",
|
||||||
|
locale.change_master_password_and_send_again
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
Err(error_text)
|
Err(error_text)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user