refactor: merge html_parser.py with extensions.py
All checks were successful
Build / Upload to production (push) Successful in 1m37s

Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
Macintxsh 2025-06-09 01:39:26 +03:00
parent d0357ff7c9
commit 511dc3e9b6
Signed by: mctaylors
GPG key ID: 4EEF4F949A266EE2
4 changed files with 84 additions and 74 deletions

View file

@ -14,7 +14,7 @@ from telegram.ext import ContextTypes
import html_parser
import config
from extensions import humanize_tags_from_json, format_rating, get_json
from extensions import humanize_tags_from_json, format_rating, get_json, HtmlFormat
async def inline_query(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
@ -66,15 +66,15 @@ async def answer_query(
input_message_content=InputTextMessageContent(
" ".join(
[
html_parser.code(f"#{query}"),
html_parser.strikethrough(
HtmlFormat.code(f"#{query}"),
HtmlFormat.strikethrough(
" ".join(
[
html_parser.bold(
HtmlFormat.bold(
f"{characters} ({copyrights})"
),
"drawn by",
html_parser.bold(artists),
HtmlFormat.bold(artists),
]
)
),
@ -102,13 +102,13 @@ async def answer_query(
input_message_content=InputTextMessageContent(
" ".join(
[
html_parser.code(f"#{query}"),
html_parser.hyperlink(
HtmlFormat.code(f"#{query}"),
HtmlFormat.hyperlink(
" ".join(
[
html_parser.bold(f"{characters} ({copyrights})"),
HtmlFormat.bold(f"{characters} ({copyrights})"),
"drawn by",
html_parser.bold(artists),
HtmlFormat.bold(artists),
]
),
f"{config.app.protocol}://{config.app.hostname}/posts/{query}",
@ -133,7 +133,7 @@ async def invalid_query(update: Update, query: int) -> None:
title=f"#{query}",
description="Error",
input_message_content=InputTextMessageContent(
" ".join([html_parser.code(f"#{query}"), "That record was not found."]),
" ".join([HtmlFormat.code(f"#{query}"), "That record was not found."]),
parse_mode=ParseMode.HTML,
),
)