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:
|
def humanize_tags_from_json(value: str, default: str) -> str:
|
||||||
if value != "":
|
if value != "":
|
||||||
output = str()
|
return ", ".join([re.sub('_\\(.*', '', t) for t in value.split()])
|
||||||
tags = value.split()
|
|
||||||
|
|
||||||
for t in tags:
|
|
||||||
output += f"{re.sub('_\\(.*', '', t)}, "
|
|
||||||
output = output[:-2]
|
|
||||||
|
|
||||||
return output
|
|
||||||
return default
|
return default
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,3 +21,4 @@ def format_rating(value: str) -> str | None:
|
||||||
case "e":
|
case "e":
|
||||||
# Negative Squared Latin Capital Letter E
|
# Negative Squared Latin Capital Letter E
|
||||||
return "🅴"
|
return "🅴"
|
||||||
|
return None
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
from telegram import Update, InlineKeyboardButton, InlineQueryResultArticle, InputTextMessageContent, \
|
from telegram import Update, InlineKeyboardButton, InlineQueryResultArticle, InputTextMessageContent, \
|
||||||
InlineKeyboardMarkup
|
InlineKeyboardMarkup, LinkPreviewOptions
|
||||||
from telegram.constants import ParseMode
|
from telegram.constants import ParseMode
|
||||||
from telegram.ext import ContextTypes
|
from telegram.ext import ContextTypes
|
||||||
|
|
||||||
|
@ -43,8 +43,7 @@ async def answer_query(update: Update, query: str, data) -> None:
|
||||||
title=f"ID: {query}",
|
title=f"ID: {query}",
|
||||||
description=f"{characters} ({copyrights}) drawn by {artists}",
|
description=f"{characters} ({copyrights}) drawn by {artists}",
|
||||||
input_message_content=InputTextMessageContent(
|
input_message_content=InputTextMessageContent(
|
||||||
f"ID: <code>{query}</code> {rating}\n"
|
f"<code>#{query}</code> <s><b>{characters} ({copyrights})</b> drawn by <b>{artists}</b></s> {rating}\n"
|
||||||
f"<s><b>{characters} ({copyrights})</b> drawn by <b>{artists}</b></s>\n"
|
|
||||||
f"This post has been removed because of a takedown request or rule violation.",
|
f"This post has been removed because of a takedown request or rule violation.",
|
||||||
parse_mode=ParseMode.HTML
|
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}",
|
description=f"{characters} ({copyrights}) drawn by {artists}",
|
||||||
thumbnail_url=data['preview_file_url'],
|
thumbnail_url=data['preview_file_url'],
|
||||||
input_message_content=InputTextMessageContent(
|
input_message_content=InputTextMessageContent(
|
||||||
f"ID: <code>{query}</code> {rating}\n"
|
f"<code>#{query}</code> <b>{characters} ({copyrights})</b> drawn by <b>{artists}</b> {rating}",
|
||||||
f"<a href='{data['large_file_url']}'><b>{characters} ({copyrights})</b> "
|
parse_mode=ParseMode.HTML,
|
||||||
f"drawn by <b>{artists}</b></a>",
|
link_preview_options=LinkPreviewOptions(url=data['large_file_url'])
|
||||||
parse_mode=ParseMode.HTML
|
|
||||||
),
|
),
|
||||||
reply_markup=InlineKeyboardMarkup(keyboard)
|
reply_markup=InlineKeyboardMarkup(keyboard)
|
||||||
)
|
)
|
||||||
|
@ -88,7 +86,7 @@ async def invalid_query(update: Update, query: str) -> None:
|
||||||
title=f"ID: {query}",
|
title=f"ID: {query}",
|
||||||
description="Error",
|
description="Error",
|
||||||
input_message_content=InputTextMessageContent(
|
input_message_content=InputTextMessageContent(
|
||||||
f"ID: <code>{query}</code>\n"
|
f"<code>#{query}</code>\n"
|
||||||
f"That record was not found.",
|
f"That record was not found.",
|
||||||
parse_mode=ParseMode.HTML
|
parse_mode=ParseMode.HTML
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue