Compare commits
No commits in common. "fff77f51f8534d214ca13ef18aa4307bfc614ccb" and "a33df8f28ae662d9507d074d9f2cd4fc77444ab6" have entirely different histories.
fff77f51f8
...
a33df8f28a
1 changed files with 15 additions and 37 deletions
|
@ -24,10 +24,6 @@ async def inline_query(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
|
||||||
|
|
||||||
if not query.isdigit():
|
if not query.isdigit():
|
||||||
return
|
return
|
||||||
query = int(query)
|
|
||||||
|
|
||||||
if query <= 0:
|
|
||||||
return
|
|
||||||
|
|
||||||
data = get_json(f"posts/{query}")
|
data = get_json(f"posts/{query}")
|
||||||
if data is None:
|
if data is None:
|
||||||
|
@ -37,7 +33,7 @@ async def inline_query(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
|
||||||
await answer_query(update, query, data)
|
await answer_query(update, query, data)
|
||||||
|
|
||||||
|
|
||||||
async def answer_query(update: Update, query: int, data) -> None:
|
async def answer_query(update: Update, query: str, data) -> None:
|
||||||
characters = humanize_tags_from_json(data["tag_string_character"], "no characters")
|
characters = humanize_tags_from_json(data["tag_string_character"], "no characters")
|
||||||
copyrights = humanize_tags_from_json(
|
copyrights = humanize_tags_from_json(
|
||||||
data["tag_string_copyright"], "unknown copyright"
|
data["tag_string_copyright"], "unknown copyright"
|
||||||
|
@ -49,27 +45,16 @@ async def answer_query(update: Update, query: int, data) -> None:
|
||||||
results = [
|
results = [
|
||||||
InlineQueryResultArticle(
|
InlineQueryResultArticle(
|
||||||
id=str(uuid4()),
|
id=str(uuid4()),
|
||||||
title=f"#{query} {rating}",
|
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(
|
||||||
" ".join(
|
html_parser.code(f"#{query}")
|
||||||
[
|
+ html_parser.strikethrough(
|
||||||
html_parser.code(f"#{query}"),
|
f" {html_parser.bold(f"{characters} ({copyrights})")}"
|
||||||
html_parser.strikethrough(
|
f"drawn by {html_parser.bold(artists)}"
|
||||||
" ".join(
|
)
|
||||||
[
|
+ rating
|
||||||
html_parser.bold(
|
+ "\nThis post has been removed because of a takedown request or rule violation.",
|
||||||
f"{characters} ({copyrights})"
|
|
||||||
),
|
|
||||||
"drawn by",
|
|
||||||
html_parser.bold(artists),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
),
|
|
||||||
rating,
|
|
||||||
"\nThis post has been removed because of a takedown request or rule violation.",
|
|
||||||
]
|
|
||||||
),
|
|
||||||
parse_mode=ParseMode.HTML,
|
parse_mode=ParseMode.HTML,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -91,19 +76,12 @@ async def answer_query(update: Update, query: int, data) -> None:
|
||||||
results = [
|
results = [
|
||||||
InlineQueryResultArticle(
|
InlineQueryResultArticle(
|
||||||
id=str(uuid4()),
|
id=str(uuid4()),
|
||||||
title=f"#{query} {rating}",
|
title=f"ID: {query}",
|
||||||
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(
|
||||||
" ".join(
|
html_parser.code(f"#{query}")
|
||||||
[
|
+ f" {html_parser.bold(f"{characters} ({copyrights})")} drawn by {html_parser.bold(artists)} {rating}",
|
||||||
html_parser.code(f"#{query}"),
|
|
||||||
html_parser.bold(f"{characters} ({copyrights})"),
|
|
||||||
"drawn by",
|
|
||||||
html_parser.bold(artists),
|
|
||||||
rating,
|
|
||||||
]
|
|
||||||
),
|
|
||||||
parse_mode=ParseMode.HTML,
|
parse_mode=ParseMode.HTML,
|
||||||
link_preview_options=LinkPreviewOptions(url=data["large_file_url"]),
|
link_preview_options=LinkPreviewOptions(url=data["large_file_url"]),
|
||||||
),
|
),
|
||||||
|
@ -114,14 +92,14 @@ async def answer_query(update: Update, query: int, data) -> None:
|
||||||
await update.inline_query.answer(results)
|
await update.inline_query.answer(results)
|
||||||
|
|
||||||
|
|
||||||
async def invalid_query(update: Update, query: int) -> None:
|
async def invalid_query(update: Update, query: str) -> None:
|
||||||
results = [
|
results = [
|
||||||
InlineQueryResultArticle(
|
InlineQueryResultArticle(
|
||||||
id=str(uuid4()),
|
id=str(uuid4()),
|
||||||
title=f"#{query}",
|
title=f"ID: {query}",
|
||||||
description="Error",
|
description="Error",
|
||||||
input_message_content=InputTextMessageContent(
|
input_message_content=InputTextMessageContent(
|
||||||
" ".join([html_parser.code(f"#{query}"), "That record was not found."]),
|
html_parser.code(f"#{query}") + "That record was not found.",
|
||||||
parse_mode=ParseMode.HTML,
|
parse_mode=ParseMode.HTML,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue