mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
fix #660 prepare parse mode for input_message_content of InlineQueryResult
This commit is contained in:
parent
0ca9f98baf
commit
7e6567feb5
2 changed files with 25 additions and 2 deletions
|
|
@ -37,5 +37,11 @@ class AnswerInlineQuery(TelegramMethod[bool]):
|
|||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
prepare_parse_mode(bot, data["results"])
|
||||
|
||||
input_message_contents = []
|
||||
for result in data["results"]:
|
||||
if result.get("input_message_content", None) is not None:
|
||||
input_message_contents.append(result.get("input_message_content"))
|
||||
|
||||
prepare_parse_mode(bot, data["results"] + input_message_contents)
|
||||
return Request(method="answerInlineQuery", data=data)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import pytest
|
|||
|
||||
from aiogram import Bot
|
||||
from aiogram.methods import AnswerInlineQuery, Request
|
||||
from aiogram.types import InlineQueryResult, InlineQueryResultPhoto
|
||||
from aiogram.types import InlineQueryResult, InlineQueryResultPhoto, InputTextMessageContent
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
|
@ -40,3 +40,20 @@ class TestAnswerInlineQuery:
|
|||
new_bot = Bot(token="42:TEST", parse_mode="HTML")
|
||||
request = query.build_request(new_bot)
|
||||
assert request.data["results"][0]["parse_mode"] == "HTML"
|
||||
|
||||
def test_parse_mode_input_message_content(self, bot: MockedBot):
|
||||
query = AnswerInlineQuery(
|
||||
inline_query_id="query id",
|
||||
results=[InlineQueryResultPhoto(
|
||||
id="result id",
|
||||
photo_url="photo",
|
||||
thumb_url="thumb",
|
||||
input_message_content=InputTextMessageContent(message_text="test")
|
||||
)],
|
||||
)
|
||||
request = query.build_request(bot)
|
||||
assert request.data["results"][0]["input_message_content"]["parse_mode"] is None
|
||||
|
||||
new_bot = Bot(token="42:TEST", parse_mode="HTML")
|
||||
request = query.build_request(new_bot)
|
||||
assert request.data["results"][0]["input_message_content"]["parse_mode"] == "HTML"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue