chore: charts are now as a picture natively, not a link

This commit is contained in:
Danil 2025-05-17 00:34:05 +03:00
parent 9b3ed607b0
commit fd6f0b699e

View file

@ -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)