refactor: pt. 2: my head hurts
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
parent
6ea4f2c3ed
commit
84fbbeba4c
1 changed files with 27 additions and 15 deletions
42
commands.py
42
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:
|
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} <post ID>")}\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} <post ID>"),
|
||||||
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,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue