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
|
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:
|
async def reply(result_id: str, args: list, query: types.InlineQuery) -> None:
|
||||||
if not args:
|
if not args:
|
||||||
return
|
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
|
description = arg[1] if arg[1] else None
|
||||||
img = arg[2] if arg[2] else None
|
img = arg[2] if arg[2] else None
|
||||||
|
|
||||||
|
if img:
|
||||||
article = types.InlineQueryResultArticle(
|
article = types.InlineQueryResultPhoto(
|
||||||
id=f"{result_id}_{idx}",
|
id=f"{result_id}_{idx}",
|
||||||
title=re.sub(
|
photo_url=img,
|
||||||
r'\bChart\b|\[([^\]]+)\]\([^)]+\)',
|
thumbnail_url=img,
|
||||||
'',
|
title=title,
|
||||||
title,
|
description=description,
|
||||||
flags=re.IGNORECASE
|
caption=esc_md(title),
|
||||||
),
|
parse_mode="MarkdownV2"
|
||||||
thumbnail_url=img,
|
)
|
||||||
description=description,
|
else:
|
||||||
input_message_content=types.InputTextMessageContent(
|
article = types.InlineQueryResultArticle(
|
||||||
message_text=title,
|
id=f"{result_id}_{idx}",
|
||||||
parse_mode='markdown'
|
title=title,
|
||||||
|
description=description,
|
||||||
|
input_message_content=types.InputTextMessageContent(
|
||||||
|
message_text=esc_md(title),
|
||||||
|
parse_mode="MarkdownV2",
|
||||||
|
),
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
articles.append(article)
|
articles.append(article)
|
||||||
|
|
||||||
await query.answer(
|
await query.answer(results=articles, cache_time=0, is_personal=True)
|
||||||
results=articles,
|
|
||||||
parse_mode='markdown',
|
|
||||||
cache_time=0,
|
|
||||||
is_personal=True
|
|
||||||
)
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue