Add send_as and effect parameters in high level

This commit is contained in:
Shrimadhav U K
2025-03-08 21:46:40 +05:30
committed by Lonami
parent 6f5556373f
commit 859f7423f2
2 changed files with 43 additions and 6 deletions

View File

@@ -644,6 +644,8 @@ class MessageMethods:
schedule: 'hints.DateLike' = None,
comment_to: 'typing.Union[int, types.Message]' = None,
nosound_video: bool = None,
send_as: typing.Optional['hints.EntityLike'] = None,
message_effect_id: typing.Optional[int] = None
) -> 'types.Message':
"""
Sends a message to the specified user, chat or channel.
@@ -766,6 +768,16 @@ class MessageMethods:
on non-video files. This is set to ``True`` for albums, as gifs
cannot be sent in albums.
send_as (`entity`):
Unique identifier (int) or username (str) of the chat or channel to send the message as.
You can use this to send the message on behalf of a chat or channel where you have appropriate permissions.
Use the GetSendAs to return the list of message sender identifiers, which can be used to send messages in the chat,
This setting applies to the current message and will remain effective for future messages unless explicitly changed.
To set this behavior permanently for all messages, use SaveDefaultSendAs.
message_effect_id (`int`, optional):
Unique identifier of the message effect to be added to the message; for private chats only
Returns
The sent `custom.Message <telethon.tl.custom.message.Message>`.
@@ -838,6 +850,7 @@ class MessageMethods:
formatting_entities=formatting_entities,
comment_to=comment_to, background=background,
nosound_video=nosound_video,
send_as=send_as, message_effect_id=message_effect_id
)
entity = await self.get_input_entity(entity)
@@ -867,7 +880,8 @@ class MessageMethods:
buttons=markup,
formatting_entities=message.entities,
parse_mode=None, # explicitly disable parse_mode to force using even empty formatting_entities
schedule=schedule
schedule=schedule,
send_as=send_as, message_effect_id=message_effect_id
)
request = functions.messages.SendMessageRequest(
@@ -881,7 +895,9 @@ class MessageMethods:
clear_draft=clear_draft,
no_webpage=not isinstance(
message.media, types.MessageMediaWebPage),
schedule_date=schedule
schedule_date=schedule,
send_as=await self.get_input_entity(send_as) if send_as else None,
effect=message_effect_id
)
message = message.message
else:
@@ -902,7 +918,9 @@ class MessageMethods:
silent=silent,
background=background,
reply_markup=self.build_reply_markup(buttons),
schedule_date=schedule
schedule_date=schedule,
send_as=await self.get_input_entity(send_as) if send_as else None,
effect=message_effect_id
)
result = await self(request)