Skip to content

Commit

Permalink
Add attributes, supports_streaming to send_message and edit_message (#…
Browse files Browse the repository at this point in the history
…3066)

Closes #3047.
  • Loading branch information
BelgenOp committed May 31, 2021
1 parent 63f24d2 commit 6b53d45
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions telethon/client/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ async def send_message(
message: 'hints.MessageLike' = '',
*,
reply_to: 'typing.Union[int, types.Message]' = None,
attributes: 'typing.Sequence[types.TypeDocumentAttribute]' = None,
parse_mode: typing.Optional[str] = (),
formatting_entities: typing.Optional[typing.List[types.TypeMessageEntity]] = None,
link_preview: bool = True,
Expand All @@ -606,6 +607,7 @@ async def send_message(
clear_draft: bool = False,
buttons: 'hints.MarkupLike' = None,
silent: bool = None,
supports_streaming: bool = False,
schedule: 'hints.DateLike' = None,
comment_to: 'typing.Union[int, types.Message]' = None
) -> 'types.Message':
Expand Down Expand Up @@ -642,6 +644,10 @@ async def send_message(
Whether to reply to a message or not. If an integer is provided,
it should be the ID of the message that it should reply to.
attributes (`list`, optional):
Optional attributes that override the inferred ones, like
:tl:`DocumentAttributeFilename` and so on.
parse_mode (`object`, optional):
See the `TelegramClient.parse_mode
<telethon.client.messageparse.MessageParseMethods.parse_mode>`
Expand Down Expand Up @@ -683,6 +689,13 @@ async def send_message(
channel or not. Defaults to `False`, which means it will
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``.
schedule (`hints.DateLike`, optional):
If set, the message won't send immediately, and instead
it will be scheduled to be automatically sent at a later
Expand Down Expand Up @@ -758,9 +771,11 @@ async def callback(event):
if file is not None:
return await self.send_file(
entity, file, caption=message, reply_to=reply_to,
parse_mode=parse_mode, force_document=force_document,
attributes=attributes, parse_mode=parse_mode,
force_document=force_document,
buttons=buttons, clear_draft=clear_draft, silent=silent,
schedule=schedule, formatting_entities=formatting_entities,
schedule=schedule, supports_streaming=supports_streaming,
formatting_entities=formatting_entities,
comment_to=comment_to
)

Expand Down Expand Up @@ -967,11 +982,13 @@ async def edit_message(
text: str = None,
*,
parse_mode: str = (),
attributes: 'typing.Sequence[types.TypeDocumentAttribute]' = None,
formatting_entities: typing.Optional[typing.List[types.TypeMessageEntity]] = None,
link_preview: bool = True,
file: 'hints.FileLike' = None,
force_document: bool = False,
buttons: 'hints.MarkupLike' = None,
supports_streaming: bool = False,
schedule: 'hints.DateLike' = None
) -> 'types.Message':
"""
Expand Down Expand Up @@ -1007,6 +1024,10 @@ async def edit_message(
property for allowed values. Markdown parsing will be used by
default.
attributes (`list`, optional):
Optional attributes that override the inferred ones, like
:tl:`DocumentAttributeFilename` and so on.
formatting_entities (`list`, optional):
A list of message formatting entities. When provided, the ``parse_mode`` is ignored.
Expand All @@ -1026,6 +1047,13 @@ async def edit_message(
you have signed in as a bot. You can also pass your own
:tl:`ReplyMarkup` here.
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``.
schedule (`hints.DateLike`, optional):
If set, the message won't be edited immediately, and instead
it will be scheduled to be automatically edited at a later
Expand Down Expand Up @@ -1073,6 +1101,8 @@ async def edit_message(
if formatting_entities is None:
text, formatting_entities = await self._parse_message_text(text, parse_mode)
file_handle, media, image = await self._file_to_media(file,
supports_streaming=supports_streaming,
attributes=attributes,
force_document=force_document)

if isinstance(entity, types.InputBotInlineMessageID):
Expand Down

0 comments on commit 6b53d45

Please sign in to comment.