Compare commits

..

12 commits

Author SHA1 Message Date
270e1630d4
feat: add /info command, pt. 2
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2025-05-18 12:35:05 +03:00
b079d56250
feat: add /info command, pt. 1
# Conflicts:
#	extensions.py
2025-05-18 12:34:58 +03:00
c70d7fe3be
refactor: completely rewrite humanize_tags_from_json
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2025-05-18 12:30:22 +03:00
f07a51f76a
change: make inline query answer more compact
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2025-05-18 12:30:22 +03:00
df1735ef36
feat: use LinkPreviewOptions in answer_query
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2025-05-18 12:30:22 +03:00
0cc77dd42c
change: make return None statement explicit in format_rating
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2025-05-18 12:30:22 +03:00
d646920210
fix: set encoding for _c.read
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2025-05-18 12:30:22 +03:00
0ee018e2ce
refactor: define parameter types *again*
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2025-05-18 12:30:22 +03:00
7fdf18b5cb
i18n: use strings from Danbooru
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2025-05-18 12:30:22 +03:00
ff86c78b21
fix: add is_banned check
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2025-05-18 12:30:22 +03:00
05cbca7509
chore: remove unused imports
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2025-05-18 12:30:22 +03:00
b503234b85
pip: add requirements.txt
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2025-05-18 12:30:22 +03:00
2 changed files with 4 additions and 13 deletions

View file

@ -7,14 +7,7 @@ from config import app
def humanize_tags_from_json(value: str, default: str) -> str:
if value != "":
output = str()
tags = value.split()
for t in tags:
output += f"{re.sub('_\\(.*', '', t)}, "
output = output[:-2]
return output
return ", ".join([re.sub('_\\(.*', '', t) for t in value.split()])
return default

View file

@ -40,8 +40,7 @@ async def answer_query(update: Update, query: str, data) -> None:
title=f"ID: {query}",
description=f"{characters} ({copyrights}) drawn by {artists}",
input_message_content=InputTextMessageContent(
f"ID: <code>{query}</code> {rating}\n"
f"<s><b>{characters} ({copyrights})</b> drawn by <b>{artists}</b></s>\n"
f"<code>#{query}</code> <s><b>{characters} ({copyrights})</b> drawn by <b>{artists}</b></s> {rating}\n"
f"This post has been removed because of a takedown request or rule violation.",
parse_mode=ParseMode.HTML
)
@ -66,8 +65,7 @@ async def answer_query(update: Update, query: str, data) -> None:
description=f"{characters} ({copyrights}) drawn by {artists}",
thumbnail_url=data['preview_file_url'],
input_message_content=InputTextMessageContent(
f"ID: <code>{query}</code> {rating}\n"
f"<b>{characters} ({copyrights})</b> drawn by <b>{artists}</b>",
f"<code>#{query}</code> <b>{characters} ({copyrights})</b> drawn by <b>{artists}</b> {rating}",
parse_mode=ParseMode.HTML,
link_preview_options=LinkPreviewOptions(url=data['large_file_url'])
),
@ -85,7 +83,7 @@ async def invalid_query(update: Update, query: str) -> None:
title=f"ID: {query}",
description="Error",
input_message_content=InputTextMessageContent(
f"ID: <code>{query}</code>\n"
f"<code>#{query}</code>\n"
f"That record was not found.",
parse_mode=ParseMode.HTML
)