From cef922467844127748b80d95a0827ba5cc6cb04f Mon Sep 17 00:00:00 2001 From: Devesh Pal Date: Sun, 23 Jan 2022 10:49:49 +0000 Subject: [PATCH] add new parameters --- telethon/_client/messages.py | 16 ++++++++++++---- telethon/_client/uploads.py | 9 +++++++-- telethon/types/_custom/inlineresult.py | 8 ++++++-- telethon/types/_custom/message.py | 2 +- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/telethon/_client/messages.py b/telethon/_client/messages.py index e85921f3..250582d0 100644 --- a/telethon/_client/messages.py +++ b/telethon/_client/messages.py @@ -426,8 +426,10 @@ async def send_message( ttl: int = None, # - Send options reply_to: 'typing.Union[int, _tl.Message]' = None, + send_as: 'hints.EntityLike' = None, clear_draft: bool = False, background: bool = None, + noforwards: bool = None, schedule: 'hints.DateLike' = None, comment_to: 'typing.Union[int, _tl.Message]' = None, ) -> '_tl.Message': @@ -483,7 +485,7 @@ async def send_message( entity, message._file._media, reply_to_msg_id=reply_to, message=message._text, entities=message._fmt_entities, reply_markup=message._reply_markup, silent=message._silent, schedule_date=schedule, clear_draft=clear_draft, - background=background + background=background, noforwards=noforwards, send_as=send_as ) else: request = _tl.fn.messages.SendMessage( @@ -496,7 +498,9 @@ async def send_message( silent=silent, background=background, reply_markup=_custom.button.build_reply_markup(buttons), - schedule_date=schedule + schedule_date=schedule, + noforwards=noforwards, + send_as=send_as ) result = await self(request) @@ -525,7 +529,9 @@ async def forward_messages( with_my_score: bool = None, silent: bool = None, as_album: bool = None, - schedule: 'hints.DateLike' = None + schedule: 'hints.DateLike' = None, + noforwards: bool = None, + send_as: 'hints.EntityLike' = None ) -> 'typing.Sequence[_tl.Message]': if as_album is not None: warnings.warn('the as_album argument is deprecated and no longer has any effect') @@ -565,7 +571,9 @@ async def forward_messages( silent=silent, background=background, with_my_score=with_my_score, - schedule_date=schedule + schedule_date=schedule, + noforwards=noforwards, + send_as=send_as ) result = await self(req) sent.extend(self._get_response_message(req, result, entity)) diff --git a/telethon/_client/uploads.py b/telethon/_client/uploads.py index 92a2d36e..a92df8f4 100644 --- a/telethon/_client/uploads.py +++ b/telethon/_client/uploads.py @@ -113,6 +113,8 @@ async def send_file( reply_to: 'typing.Union[int, _tl.Message]' = None, clear_draft: bool = False, background: bool = None, + noforwards: bool = None, + send_as: 'hints.EntityLike' = None, schedule: 'hints.DateLike' = None, comment_to: 'typing.Union[int, _tl.Message]' = None, ) -> '_tl.Message': @@ -146,13 +148,16 @@ async def send_file( background=background, schedule=schedule, comment_to=comment_to, + noforwards=noforwards, + send_as=send_as ) async def _send_album(self: 'TelegramClient', entity, files, caption='', progress_callback=None, reply_to=None, parse_mode=(), silent=None, schedule=None, supports_streaming=None, clear_draft=None, - force_document=False, background=None, ttl=None): + force_document=False, background=None, ttl=None, + send_as=None, noforwards=None): """Specialized version of .send_file for albums""" # We don't care if the user wants to avoid cache, we will use it # anyway. Why? The cached version will be exactly the same thing @@ -212,7 +217,7 @@ async def _send_album(self: 'TelegramClient', entity, files, caption='', request = _tl.fn.messages.SendMultiMedia( entity, reply_to_msg_id=reply_to, multi_media=media, silent=silent, schedule_date=schedule, clear_draft=clear_draft, - background=background + background=background, noforwards=noforwards, send_as=send_as ) result = await self(request) diff --git a/telethon/types/_custom/inlineresult.py b/telethon/types/_custom/inlineresult.py index 052be4dd..45867edb 100644 --- a/telethon/types/_custom/inlineresult.py +++ b/telethon/types/_custom/inlineresult.py @@ -104,7 +104,7 @@ class InlineResult: async def click(self, entity=None, reply_to=None, comment_to=None, silent=False, clear_draft=False, hide_via=False, - background=None): + background=None, send_as=None): """ Clicks this result and sends the associated `message`. @@ -137,6 +137,9 @@ class InlineResult: background (`bool`, optional): Whether the message should be send in background. + send_as (`entity`, optional): + The channel entity on behalf of which, message should be send. + """ if entity: entity = await self._client.get_input_entity(entity) @@ -158,7 +161,8 @@ class InlineResult: background=background, clear_draft=clear_draft, hide_via=hide_via, - reply_to_msg_id=reply_id + reply_to_msg_id=reply_id, + send_as=send_as ) return self._client._get_response_message( req, await self._client(req), entity) diff --git a/telethon/types/_custom/message.py b/telethon/types/_custom/message.py index 00dc61c6..e1bfff41 100644 --- a/telethon/types/_custom/message.py +++ b/telethon/types/_custom/message.py @@ -209,7 +209,7 @@ class Message(ChatGetter, SenderGetter): grouped_id = _fwd('grouped_id', """ If this message belongs to a group of messages (photo albums or video albums), all of them will - have the same value here.""" + have the same value here.""") restriction_reason = _fwd('restriction_reason', """ An optional list of reasons why this message was restricted.