feat: show rating
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
parent
3242418ae6
commit
20b8bf2432
2 changed files with 19 additions and 2 deletions
|
@ -12,3 +12,19 @@ def humanize_tags_from_json(value, default):
|
|||
|
||||
return output
|
||||
return default
|
||||
|
||||
|
||||
def format_rating(value):
|
||||
match value:
|
||||
case "g":
|
||||
# Negative Squared Latin Capital Letter G
|
||||
return "🅶"
|
||||
case "s":
|
||||
# Negative Squared Latin Capital Letter S
|
||||
return "🆂"
|
||||
case "q":
|
||||
# Negative Squared Latin Capital Letter Q
|
||||
return "🆀"
|
||||
case "e":
|
||||
# Negative Squared Latin Capital Letter E
|
||||
return "🅴"
|
||||
|
|
|
@ -6,7 +6,7 @@ from telegram import Update, InlineKeyboardButton, InlineQueryResultArticle, Inp
|
|||
from telegram.constants import ParseMode
|
||||
from telegram.ext import ContextTypes
|
||||
|
||||
from extensions import humanize_tags_from_json
|
||||
from extensions import humanize_tags_from_json, format_rating
|
||||
|
||||
|
||||
# noinspection PyUnusedLocal
|
||||
|
@ -35,6 +35,7 @@ async def answer_query(update, query, config, data):
|
|||
characters = humanize_tags_from_json(data['tag_string_character'], "no characters")
|
||||
copyrights = humanize_tags_from_json(data['tag_string_copyright'], "unknown copyright")
|
||||
artists = humanize_tags_from_json(data['tag_string_artist'], "unknown artist")
|
||||
rating = format_rating(data['rating'])
|
||||
keyboard = [
|
||||
[
|
||||
InlineKeyboardButton(f"Open in {config.get('Service', 'Name')}",
|
||||
|
@ -50,7 +51,7 @@ async def answer_query(update, query, config, data):
|
|||
description=f"{characters} ({copyrights}) drawn by {artists}",
|
||||
thumbnail_url=data['preview_file_url'],
|
||||
input_message_content=InputTextMessageContent(
|
||||
f"ID: <code>{query}</code>\n"
|
||||
f"ID: <code>{query}</code> {rating}\n"
|
||||
f"<a href='{data['large_file_url']}'><b>{characters} ({copyrights})</b> "
|
||||
f"drawn by <b>{artists}</b></a>",
|
||||
parse_mode=ParseMode.HTML
|
||||
|
|
Loading…
Add table
Reference in a new issue