Compare commits
4 commits
b892a3a201
...
4adfcd316f
Author | SHA1 | Date | |
---|---|---|---|
4adfcd316f | |||
e59ff67176 | |||
735bfdb406 | |||
1ce708a40b |
2 changed files with 8 additions and 16 deletions
|
@ -3,14 +3,7 @@ import re
|
|||
|
||||
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
|
||||
|
||||
|
||||
|
@ -28,3 +21,4 @@ def format_rating(value: str) -> str | None:
|
|||
case "e":
|
||||
# Negative Squared Latin Capital Letter E
|
||||
return "🅴"
|
||||
return None
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from uuid import uuid4
|
||||
|
||||
from telegram import Update, InlineKeyboardButton, InlineQueryResultArticle, InputTextMessageContent, \
|
||||
InlineKeyboardMarkup
|
||||
InlineKeyboardMarkup, LinkPreviewOptions
|
||||
from telegram.constants import ParseMode
|
||||
from telegram.ext import ContextTypes
|
||||
|
||||
|
@ -43,8 +43,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
|
||||
)
|
||||
|
@ -69,10 +68,9 @@ 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"<a href='{data['large_file_url']}'><b>{characters} ({copyrights})</b> "
|
||||
f"drawn by <b>{artists}</b></a>",
|
||||
parse_mode=ParseMode.HTML
|
||||
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'])
|
||||
),
|
||||
reply_markup=InlineKeyboardMarkup(keyboard)
|
||||
)
|
||||
|
@ -88,7 +86,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
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue