From 84fbbeba4c4a72a2f01c206558c78ce23f1a2cfe Mon Sep 17 00:00:00 2001 From: mctaylors Date: Sun, 8 Jun 2025 08:12:29 +0300 Subject: [PATCH] refactor: pt. 2: my head hurts Signed-off-by: mctaylors --- commands.py | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/commands.py b/commands.py index bc3d962..2fe6886 100644 --- a/commands.py +++ b/commands.py @@ -15,20 +15,28 @@ from extensions import get_json, format_rating, format_status, humanize_filesize async def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: await update.message.reply_text( - f"hello, i'm {html_parser.bold(context.bot.first_name)}, an inline image grabber.\n\n" - f"to get help, use /help", + "\n".join( + [ + f"hello, i'm {html_parser.bold(context.bot.first_name)}, an inline image grabber.\n", + "to get help, use /help", + ] + ), parse_mode=ParseMode.HTML, ) async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: await update.message.reply_text( - f"{html_parser.bold(f"how to use {context.bot.first_name}")}\n\n" - f"1. open your message box and type:\n" - f"{html_parser.code(f"@{context.bot.username} <post ID>")}\n" - f"2. click on the box that has popped up\n" - f"3. ???\n" - f"4. done!", + "\n".join( + [ + html_parser.bold(f"how to use {context.bot.first_name}\n"), + "1. open your message box and type:", + html_parser.code(f"@{context.bot.username} <post ID>"), + "2. click on the box that has popped up", + "3. ???", + "4. done!", + ] + ), parse_mode=ParseMode.HTML, ) @@ -40,11 +48,15 @@ async def about_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> N reply_markup = InlineKeyboardMarkup(keyboard) await update.message.reply_text( - f"{html_parser.bold(f"about {context.bot.first_name}")}\n" - f"{context.bot.first_name} is an inline image grabber written in python that grabs images from Danbooru " - f"(or other similar services).\n\n" - f"{html_parser.bold("currently configured instance:")}\n" - f"{html_parser.italic(app.name)} ({app.hostname})", + "\n".join( + [ + html_parser.bold(f"about {context.bot.first_name}"), + f"{context.bot.first_name} is an inline image grabber written in python that grabs images from " + "Danbooru (or other similar services).\n", + html_parser.bold("currently configured instance:"), + f"{html_parser.italic(app.name)} ({app.hostname})", + ] + ), parse_mode=ParseMode.HTML, reply_markup=reply_markup, ) @@ -55,13 +67,13 @@ async def info_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No post_id = context.args[0] message = await context.bot.send_message( update.effective_chat.id, - f"{html_parser.bold("Information")}\n" f"Fetching...", + "\n".join([html_parser.bold("Information"), "Fetching..."]), parse_mode=ParseMode.HTML, ) post_data = get_json(f"posts/{post_id}") if post_data is None: await context.bot.edit_message_text( - f"{html_parser.bold("Error")}: That record was not found.", + " ".join([html_parser.bold("Error:"), "That record was not found."]), update.effective_chat.id, message.message_id, parse_mode=ParseMode.HTML,