mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-05-03 23:33:42 +03:00
Support passing media objects to inline results (#1053)
This commit is contained in:
parent
4b9b77614f
commit
f99b4874c8
|
@ -113,7 +113,11 @@ class InlineBuilder:
|
||||||
Same as ``file`` for `client.send_file
|
Same as ``file`` for `client.send_file
|
||||||
<telethon.client.uploads.UploadMethods.send_file>`.
|
<telethon.client.uploads.UploadMethods.send_file>`.
|
||||||
"""
|
"""
|
||||||
fh = await self._client.upload_file(file, use_cache=types.InputPhoto)
|
try:
|
||||||
|
fh = utils.get_input_photo(file)
|
||||||
|
except TypeError:
|
||||||
|
fh = await self._client.upload_file(file, use_cache=types.InputPhoto)
|
||||||
|
|
||||||
if not isinstance(fh, types.InputPhoto):
|
if not isinstance(fh, types.InputPhoto):
|
||||||
r = await self._client(functions.messages.UploadMediaRequest(
|
r = await self._client(functions.messages.UploadMediaRequest(
|
||||||
types.InputPeerSelf(), media=types.InputMediaUploadedPhoto(fh)
|
types.InputPeerSelf(), media=types.InputMediaUploadedPhoto(fh)
|
||||||
|
@ -177,8 +181,12 @@ class InlineBuilder:
|
||||||
else:
|
else:
|
||||||
type = 'document'
|
type = 'document'
|
||||||
|
|
||||||
use_cache = types.InputDocument if use_cache else None
|
try:
|
||||||
fh = await self._client.upload_file(file, use_cache=use_cache)
|
fh = utils.get_input_document(file)
|
||||||
|
except TypeError:
|
||||||
|
use_cache = types.InputDocument if use_cache else None
|
||||||
|
fh = await self._client.upload_file(file, use_cache=use_cache)
|
||||||
|
|
||||||
if not isinstance(fh, types.InputDocument):
|
if not isinstance(fh, types.InputDocument):
|
||||||
attributes, mime_type = utils.get_attributes(
|
attributes, mime_type = utils.get_attributes(
|
||||||
file,
|
file,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user