mirror of
https://github.com/Redume/Shirino.git
synced 2025-05-19 02:05:26 +01:00
chore: charts are now as a picture natively, not a link
This commit is contained in:
parent
9b3ed607b0
commit
fd6f0b699e
1 changed files with 23 additions and 21 deletions
|
@ -2,6 +2,9 @@ import re
|
|||
|
||||
from aiogram import types
|
||||
|
||||
def esc_md(text: str) -> str:
|
||||
return re.sub(r'([_*\[\]()~`>#+\-=|{}.!\\])', r'\\\1', text)
|
||||
|
||||
async def reply(result_id: str, args: list, query: types.InlineQuery) -> None:
|
||||
if not args:
|
||||
return
|
||||
|
@ -13,28 +16,27 @@ async def reply(result_id: str, args: list, query: types.InlineQuery) -> None:
|
|||
description = arg[1] if arg[1] else None
|
||||
img = arg[2] if arg[2] else None
|
||||
|
||||
|
||||
if img:
|
||||
article = types.InlineQueryResultPhoto(
|
||||
id=f"{result_id}_{idx}",
|
||||
photo_url=img,
|
||||
thumbnail_url=img,
|
||||
title=title,
|
||||
description=description,
|
||||
caption=esc_md(title),
|
||||
parse_mode="MarkdownV2"
|
||||
)
|
||||
else:
|
||||
article = types.InlineQueryResultArticle(
|
||||
id=f"{result_id}_{idx}",
|
||||
title=re.sub(
|
||||
r'\bChart\b|\[([^\]]+)\]\([^)]+\)',
|
||||
'',
|
||||
title,
|
||||
flags=re.IGNORECASE
|
||||
),
|
||||
thumbnail_url=img,
|
||||
title=title,
|
||||
description=description,
|
||||
input_message_content=types.InputTextMessageContent(
|
||||
message_text=title,
|
||||
parse_mode='markdown'
|
||||
)
|
||||
message_text=esc_md(title),
|
||||
parse_mode="MarkdownV2",
|
||||
),
|
||||
)
|
||||
|
||||
articles.append(article)
|
||||
|
||||
await query.answer(
|
||||
results=articles,
|
||||
parse_mode='markdown',
|
||||
cache_time=0,
|
||||
is_personal=True
|
||||
)
|
||||
await query.answer(results=articles, cache_time=0, is_personal=True)
|
||||
|
|
Loading…
Add table
Reference in a new issue