mirror of
https://github.com/Redume/Shirino.git
synced 2025-02-04 09:58:57 +03:00
chore: Returned the formatting and the inline query response
This commit is contained in:
parent
90c1717b6b
commit
8cc073c473
2 changed files with 48 additions and 0 deletions
14
utils/format_number.py
Normal file
14
utils/format_number.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
def format_number(number):
|
||||||
|
number_str = str(number)
|
||||||
|
|
||||||
|
if '.' in number_str:
|
||||||
|
integer_part, fractional_part = number_str.split('.')
|
||||||
|
else:
|
||||||
|
integer_part, fractional_part = number_str, ''
|
||||||
|
|
||||||
|
formatted_integer_part = '{:,}'.format(int(integer_part)).replace(',', ' ')
|
||||||
|
|
||||||
|
if fractional_part:
|
||||||
|
return formatted_integer_part + '.' + fractional_part
|
||||||
|
else:
|
||||||
|
return formatted_integer_part
|
34
utils/inline_query.py
Normal file
34
utils/inline_query.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
from aiogram import types
|
||||||
|
|
||||||
|
|
||||||
|
async def reply(result_id: str, args: list, query: types.InlineQuery) -> None:
|
||||||
|
if not args:
|
||||||
|
return
|
||||||
|
|
||||||
|
articles = []
|
||||||
|
|
||||||
|
for idx, arg in enumerate(args):
|
||||||
|
title = arg[0]
|
||||||
|
description = arg[1] if arg[1] else None
|
||||||
|
img = arg[2] if arg[2] else None
|
||||||
|
|
||||||
|
|
||||||
|
article = types.InlineQueryResultArticle(
|
||||||
|
id=f"{result_id}_{idx}",
|
||||||
|
title=title,
|
||||||
|
thumbnail_url=img,
|
||||||
|
description=description,
|
||||||
|
input_message_content=types.InputTextMessageContent(
|
||||||
|
message_text=title,
|
||||||
|
parse_mode='markdown'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
articles.append(article)
|
||||||
|
|
||||||
|
await query.answer(
|
||||||
|
results=articles,
|
||||||
|
parse_mode='markdown',
|
||||||
|
cache_time=0,
|
||||||
|
is_personal=True
|
||||||
|
)
|
Loading…
Add table
Reference in a new issue