Changed handlers.get_accounts to use a guard clause, added comment to clarify, why we are putting account in backticks

This commit is contained in:
StNicolay 2022-11-05 00:25:23 +03:00
parent da42d7ad1d
commit 66ab13b45d

View File

@ -26,17 +26,19 @@ def get_accounts(
) -> None: ) -> None:
base_handler(bot, mes) base_handler(bot, mes)
accounts = database.get.get_accounts(engine, mes.from_user.id) accounts = database.get.get_accounts(engine, mes.from_user.id)
if accounts: if not accounts:
accounts = [f"`{account}`" for account in accounts] return send_tmp_message(bot, mes.chat.id, "У вас нет аккаунтов")
return send_tmp_message(
bot, # Make accounts copyable and escape special chars
mes.chat.id, accounts = [f"`{account}`" for account in accounts]
"Ваши аккаунты:\n" send_tmp_message(
+ "\n".join(accounts) bot,
+ "\nНажмите на название, чтобы скопировать", mes.chat.id,
30, "Ваши аккаунты:\n"
) + "\n".join(accounts)
send_tmp_message(bot, mes.chat.id, "У вас нет аккаунтов") + "\nНажмите на название, чтобы скопировать",
30,
)
def delete_all( def delete_all(