mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 19:03:46 +03:00
Add supports_streaming to send_file and update docs/errors
This commit is contained in:
parent
b0883148f5
commit
8f44364c6c
|
@ -121,7 +121,6 @@ request we do:
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
result = client(SendMessageRequest(peer, 'Hello there!'))
|
result = client(SendMessageRequest(peer, 'Hello there!'))
|
||||||
# __call__ is an alias for client.invoke(request). Both will work
|
|
||||||
|
|
||||||
Message sent! Of course, this is only an example. There are over 250
|
Message sent! Of course, this is only an example. There are over 250
|
||||||
methods available as of layer 80, and you can use every single of them
|
methods available as of layer 80, and you can use every single of them
|
||||||
|
|
|
@ -33,7 +33,7 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
|
||||||
progress_callback=None, reply_to=None, attributes=None,
|
progress_callback=None, reply_to=None, attributes=None,
|
||||||
thumb=None, allow_cache=True, parse_mode=(),
|
thumb=None, allow_cache=True, parse_mode=(),
|
||||||
voice_note=False, video_note=False, buttons=None, silent=None,
|
voice_note=False, video_note=False, buttons=None, silent=None,
|
||||||
**kwargs):
|
supports_streaming=False, **kwargs):
|
||||||
"""
|
"""
|
||||||
Sends a file to the specified entity.
|
Sends a file to the specified entity.
|
||||||
|
|
||||||
|
@ -119,6 +119,13 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
|
||||||
channel or not. Defaults to ``False``, which means it will
|
channel or not. Defaults to ``False``, which means it will
|
||||||
notify them. Set it to ``True`` to alter this behaviour.
|
notify them. Set it to ``True`` to alter this behaviour.
|
||||||
|
|
||||||
|
supports_streaming (`bool`, optional):
|
||||||
|
Whether the sent video supports streaming or not. Note that
|
||||||
|
Telegram only recognizes as streamable some formats like MP4,
|
||||||
|
and others like AVI or MKV will not work. You should convert
|
||||||
|
these to MP4 before sending if you want them to be streamable.
|
||||||
|
Unsupported formats will result in ``VideoContentTypeError``.
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
If the ``hachoir3`` package (``hachoir`` module) is installed,
|
If the ``hachoir3`` package (``hachoir`` module) is installed,
|
||||||
it will be used to determine metadata from audio and video files.
|
it will be used to determine metadata from audio and video files.
|
||||||
|
@ -161,6 +168,7 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
|
||||||
progress_callback=progress_callback, reply_to=reply_to,
|
progress_callback=progress_callback, reply_to=reply_to,
|
||||||
attributes=attributes, thumb=thumb, voice_note=voice_note,
|
attributes=attributes, thumb=thumb, voice_note=voice_note,
|
||||||
video_note=video_note, buttons=buttons, silent=silent,
|
video_note=video_note, buttons=buttons, silent=silent,
|
||||||
|
supports_streaming=supports_streaming,
|
||||||
**kwargs
|
**kwargs
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -181,7 +189,8 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
|
||||||
file, force_document=force_document,
|
file, force_document=force_document,
|
||||||
progress_callback=progress_callback,
|
progress_callback=progress_callback,
|
||||||
attributes=attributes, allow_cache=allow_cache, thumb=thumb,
|
attributes=attributes, allow_cache=allow_cache, thumb=thumb,
|
||||||
voice_note=voice_note, video_note=video_note
|
voice_note=voice_note, video_note=video_note,
|
||||||
|
supports_streaming=supports_streaming
|
||||||
)
|
)
|
||||||
|
|
||||||
markup = self.build_reply_markup(buttons)
|
markup = self.build_reply_markup(buttons)
|
||||||
|
@ -389,7 +398,8 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
|
||||||
async def _file_to_media(
|
async def _file_to_media(
|
||||||
self, file, force_document=False,
|
self, file, force_document=False,
|
||||||
progress_callback=None, attributes=None, thumb=None,
|
progress_callback=None, attributes=None, thumb=None,
|
||||||
allow_cache=True, voice_note=False, video_note=False):
|
allow_cache=True, voice_note=False, video_note=False,
|
||||||
|
supports_streaming=False):
|
||||||
if not file:
|
if not file:
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
|
@ -447,7 +457,8 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
|
||||||
attributes=attributes,
|
attributes=attributes,
|
||||||
force_document=force_document,
|
force_document=force_document,
|
||||||
voice_note=voice_note,
|
voice_note=voice_note,
|
||||||
video_note=video_note
|
video_note=video_note,
|
||||||
|
supports_streaming=supports_streaming
|
||||||
)
|
)
|
||||||
|
|
||||||
input_kw = {}
|
input_kw = {}
|
||||||
|
|
|
@ -463,7 +463,8 @@ def get_message_id(message):
|
||||||
|
|
||||||
|
|
||||||
def get_attributes(file, *, attributes=None, mime_type=None,
|
def get_attributes(file, *, attributes=None, mime_type=None,
|
||||||
force_document=False, voice_note=False, video_note=False):
|
force_document=False, voice_note=False, video_note=False,
|
||||||
|
supports_streaming=False):
|
||||||
"""
|
"""
|
||||||
Get a list of attributes for the given file and
|
Get a list of attributes for the given file and
|
||||||
the mime type as a tuple ([attribute], mime_type).
|
the mime type as a tuple ([attribute], mime_type).
|
||||||
|
@ -496,11 +497,13 @@ def get_attributes(file, *, attributes=None, mime_type=None,
|
||||||
w=m.get('width') if m.has('width') else 0,
|
w=m.get('width') if m.has('width') else 0,
|
||||||
h=m.get('height') if m.has('height') else 0,
|
h=m.get('height') if m.has('height') else 0,
|
||||||
duration=int(m.get('duration').seconds
|
duration=int(m.get('duration').seconds
|
||||||
if m.has('duration') else 0)
|
if m.has('duration') else 0),
|
||||||
|
supports_streaming=supports_streaming
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
doc = types.DocumentAttributeVideo(
|
doc = types.DocumentAttributeVideo(
|
||||||
0, 1, 1, round_message=video_note)
|
0, 1, 1, round_message=video_note,
|
||||||
|
supports_streaming=supports_streaming)
|
||||||
|
|
||||||
attr_dict[types.DocumentAttributeVideo] = doc
|
attr_dict[types.DocumentAttributeVideo] = doc
|
||||||
|
|
||||||
|
|
|
@ -247,6 +247,7 @@ USER_NOT_MUTUAL_CONTACT,400 403,The provided user is not a mutual contact
|
||||||
USER_NOT_PARTICIPANT,400,The target user is not a member of the specified megagroup or channel
|
USER_NOT_PARTICIPANT,400,The target user is not a member of the specified megagroup or channel
|
||||||
USER_PRIVACY_RESTRICTED,403,The user's privacy settings do not allow you to do this
|
USER_PRIVACY_RESTRICTED,403,The user's privacy settings do not allow you to do this
|
||||||
USER_RESTRICTED,403,"You're spamreported, you can't create channels or chats."
|
USER_RESTRICTED,403,"You're spamreported, you can't create channels or chats."
|
||||||
|
VIDEO_CONTENT_TYPE_INVALID,400,The video content type is not supported with the given parameters (i.e. supports_streaming)
|
||||||
WC_CONVERT_URL_INVALID,400,WC convert URL invalid
|
WC_CONVERT_URL_INVALID,400,WC convert URL invalid
|
||||||
WEBPAGE_CURL_FAILED,400,Failure while fetching the webpage with cURL
|
WEBPAGE_CURL_FAILED,400,Failure while fetching the webpage with cURL
|
||||||
WEBPAGE_MEDIA_EMPTY,400,Webpage media empty
|
WEBPAGE_MEDIA_EMPTY,400,Webpage media empty
|
||||||
|
|
|
|
@ -139,7 +139,7 @@ messages.sendEncrypted,unknown,CHAT_ID_INVALID DATA_INVALID ENCRYPTION_DECLINED
|
||||||
messages.sendEncryptedFile,unknown,MSG_WAIT_FAILED
|
messages.sendEncryptedFile,unknown,MSG_WAIT_FAILED
|
||||||
messages.sendEncryptedService,unknown,DATA_INVALID ENCRYPTION_DECLINED MSG_WAIT_FAILED USER_IS_BLOCKED
|
messages.sendEncryptedService,unknown,DATA_INVALID ENCRYPTION_DECLINED MSG_WAIT_FAILED USER_IS_BLOCKED
|
||||||
messages.sendInlineBotResult,user,CHAT_WRITE_FORBIDDEN INLINE_RESULT_EXPIRED PEER_ID_INVALID QUERY_ID_EMPTY WEBPAGE_CURL_FAILED WEBPAGE_MEDIA_EMPTY
|
messages.sendInlineBotResult,user,CHAT_WRITE_FORBIDDEN INLINE_RESULT_EXPIRED PEER_ID_INVALID QUERY_ID_EMPTY WEBPAGE_CURL_FAILED WEBPAGE_MEDIA_EMPTY
|
||||||
messages.sendMedia,unknown,BOT_POLLS_DISABLED CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED CHAT_SEND_MEDIA_FORBIDDEN CHAT_WRITE_FORBIDDEN EXTERNAL_URL_INVALID FILE_PARTS_INVALID FILE_PART_LENGTH_INVALID INPUT_USER_DEACTIVATED MEDIA_CAPTION_TOO_LONG MEDIA_EMPTY PEER_ID_INVALID PHOTO_EXT_INVALID PHOTO_INVALID_DIMENSIONS PHOTO_SAVE_FILE_INVALID RANDOM_ID_DUPLICATE STORAGE_CHECK_FAILED Timeout USER_BANNED_IN_CHANNEL USER_IS_BLOCKED USER_IS_BOT WEBPAGE_CURL_FAILED WEBPAGE_MEDIA_EMPTY
|
messages.sendMedia,unknown,BOT_POLLS_DISABLED CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED CHAT_SEND_MEDIA_FORBIDDEN CHAT_WRITE_FORBIDDEN EXTERNAL_URL_INVALID FILE_PARTS_INVALID FILE_PART_LENGTH_INVALID INPUT_USER_DEACTIVATED MEDIA_CAPTION_TOO_LONG MEDIA_EMPTY PEER_ID_INVALID PHOTO_EXT_INVALID PHOTO_INVALID_DIMENSIONS PHOTO_SAVE_FILE_INVALID RANDOM_ID_DUPLICATE STORAGE_CHECK_FAILED Timeout USER_BANNED_IN_CHANNEL USER_IS_BLOCKED USER_IS_BOT VIDEO_CONTENT_TYPE_INVALID WEBPAGE_CURL_FAILED WEBPAGE_MEDIA_EMPTY
|
||||||
messages.sendMessage,unknown,AUTH_KEY_DUPLICATED BUTTON_DATA_INVALID BUTTON_TYPE_INVALID BUTTON_URL_INVALID CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED CHAT_ID_INVALID CHAT_RESTRICTED CHAT_WRITE_FORBIDDEN ENTITY_MENTION_USER_INVALID INPUT_USER_DEACTIVATED MESSAGE_EMPTY MESSAGE_TOO_LONG PEER_ID_INVALID RANDOM_ID_DUPLICATE REPLY_MARKUP_INVALID REPLY_MARKUP_TOO_LONG Timeout USER_BANNED_IN_CHANNEL USER_IS_BLOCKED USER_IS_BOT YOU_BLOCKED_USER
|
messages.sendMessage,unknown,AUTH_KEY_DUPLICATED BUTTON_DATA_INVALID BUTTON_TYPE_INVALID BUTTON_URL_INVALID CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED CHAT_ID_INVALID CHAT_RESTRICTED CHAT_WRITE_FORBIDDEN ENTITY_MENTION_USER_INVALID INPUT_USER_DEACTIVATED MESSAGE_EMPTY MESSAGE_TOO_LONG PEER_ID_INVALID RANDOM_ID_DUPLICATE REPLY_MARKUP_INVALID REPLY_MARKUP_TOO_LONG Timeout USER_BANNED_IN_CHANNEL USER_IS_BLOCKED USER_IS_BOT YOU_BLOCKED_USER
|
||||||
messages.sendScreenshotNotification,user,PEER_ID_INVALID
|
messages.sendScreenshotNotification,user,PEER_ID_INVALID
|
||||||
messages.setBotCallbackAnswer,unknown,QUERY_ID_INVALID URL_INVALID
|
messages.setBotCallbackAnswer,unknown,QUERY_ID_INVALID URL_INVALID
|
||||||
|
|
|
Loading…
Reference in New Issue
Block a user