refactor: pt. 2: my head hurts

Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
Macintxsh 2025-06-08 08:12:29 +03:00
parent 6ea4f2c3ed
commit 84fbbeba4c
Signed by: mctaylors
GPG key ID: 4EEF4F949A266EE2

View file

@ -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: async def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
await update.message.reply_text( await update.message.reply_text(
f"hello, i'm {html_parser.bold(context.bot.first_name)}, an inline image grabber.\n\n" "\n".join(
f"to get help, use /help", [
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, parse_mode=ParseMode.HTML,
) )
async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
await update.message.reply_text( await update.message.reply_text(
f"{html_parser.bold(f"how to use {context.bot.first_name}")}\n\n" "\n".join(
f"1. open your message box and type:\n" [
f"{html_parser.code(f"@{context.bot.username} &lt;post ID&gt;")}\n" html_parser.bold(f"how to use {context.bot.first_name}\n"),
f"2. click on the box that has popped up\n" "1. open your message box and type:",
f"3. ???\n" html_parser.code(f"@{context.bot.username} &lt;post ID&gt;"),
f"4. done!", "2. click on the box that has popped up",
"3. ???",
"4. done!",
]
),
parse_mode=ParseMode.HTML, parse_mode=ParseMode.HTML,
) )
@ -40,11 +48,15 @@ async def about_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> N
reply_markup = InlineKeyboardMarkup(keyboard) reply_markup = InlineKeyboardMarkup(keyboard)
await update.message.reply_text( await update.message.reply_text(
f"{html_parser.bold(f"about {context.bot.first_name}")}\n" "\n".join(
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" html_parser.bold(f"about {context.bot.first_name}"),
f"{html_parser.bold("currently configured instance:")}\n" f"{context.bot.first_name} is an inline image grabber written in python that grabs images from "
f"{html_parser.italic(app.name)} ({app.hostname})", "Danbooru (or other similar services).\n",
html_parser.bold("currently configured instance:"),
f"{html_parser.italic(app.name)} ({app.hostname})",
]
),
parse_mode=ParseMode.HTML, parse_mode=ParseMode.HTML,
reply_markup=reply_markup, reply_markup=reply_markup,
) )
@ -55,13 +67,13 @@ async def info_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
post_id = context.args[0] post_id = context.args[0]
message = await context.bot.send_message( message = await context.bot.send_message(
update.effective_chat.id, update.effective_chat.id,
f"{html_parser.bold("Information")}\n" f"Fetching...", "\n".join([html_parser.bold("Information"), "Fetching..."]),
parse_mode=ParseMode.HTML, parse_mode=ParseMode.HTML,
) )
post_data = get_json(f"posts/{post_id}") post_data = get_json(f"posts/{post_id}")
if post_data is None: if post_data is None:
await context.bot.edit_message_text( 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, update.effective_chat.id,
message.message_id, message.message_id,
parse_mode=ParseMode.HTML, parse_mode=ParseMode.HTML,