Add missing awaits

This commit is contained in:
Dan 2019-04-13 17:51:47 +02:00
parent ad49e72f02
commit 1750300ab9
4 changed files with 11 additions and 6 deletions

View File

@ -75,10 +75,15 @@ class AnswerInlineQuery(BaseClient):
Returns:
On success, True is returned.
"""
written_results = [] # Py 3.5 doesn't support await inside comprehensions
for r in results:
written_results.append(await r.write())
return await self.send(
functions.messages.SetInlineBotResults(
query_id=int(inline_query_id),
results=[r.write() for r in results],
results=written_results,
cache_time=cache_time,
gallery=None,
private=is_personal or None,

View File

@ -55,5 +55,5 @@ class InlineQueryResult(PyrogramType):
self.type = type
self.id = id
def write(self):
async def write(self):
pass

View File

@ -84,11 +84,11 @@ class InlineQueryResultArticle(InlineQueryResult):
self.thumb_width = thumb_width
self.thumb_height = thumb_height
def write(self):
async def write(self):
return types.InputBotInlineResult(
id=str(self.id),
type=self.type,
send_message=self.input_message_content.write(self.reply_markup),
send_message=await self.input_message_content.write(self.reply_markup),
title=self.title,
description=self.description,
url=self.url,

View File

@ -46,9 +46,9 @@ class InputTextMessageContent(InputMessageContent):
self.parse_mode = parse_mode
self.disable_web_page_preview = disable_web_page_preview
def write(self, reply_markup):
async def write(self, reply_markup):
return types.InputBotInlineMessageText(
no_webpage=self.disable_web_page_preview or None,
reply_markup=reply_markup.write() if reply_markup else None,
**(HTML() if self.parse_mode.lower() == "html" else Markdown()).parse(self.message_text)
**await(HTML() if self.parse_mode.lower() == "html" else Markdown()).parse(self.message_text)
)