Added /gen_password command

This commit is contained in:
StNicolay 2022-11-13 18:49:57 +03:00
parent 2c07b3bed2
commit 9ee51dc19f
2 changed files with 16 additions and 0 deletions

View File

@ -46,4 +46,7 @@ def create_bot(token: str, engine: Engine) -> telebot.TeleBot:
bot.register_message_handler(
functools.partial(handlers.import_accounts, bot, engine), commands=["import"]
)
bot.register_message_handler(
functools.partial(handlers.gen_password, bot), commands=["gen_password"]
)
return bot

View File

@ -13,6 +13,7 @@ from .utils import (
check_account_name,
check_login,
check_passwd,
gen_passwd,
get_all_accounts,
json_to_accounts,
send_tmp_message,
@ -471,3 +472,15 @@ def _import3(
send_tmp_message(bot, mes.chat.id, mes_text, 10)
del text, mes, accounts
gc.collect()
def gen_password(bot: telebot.TeleBot, mes: Message) -> None:
# Generate 10 passwords and put 'em in the backticks
base_handler(bot, mes)
passwords = (f"`{gen_passwd()}`" for _ in range(10))
text = (
"Пароли:\n"
+ "\n".join(passwords)
+ "\nНажмите на пароль, чтобы его скопировать"
)
send_tmp_message(bot, mes.chat.id, text)