SendMessageRequest

Both users and bots may be able to use this request. See code examples.

---functions---
ephemeral.sendMessage#68cbd09f flags:# peer:InputPeer receiver_id:InputUser query_id:flags.0?long message:string entities:flags.1?Vector<MessageEntity> media:flags.2?InputMedia reply_markup:flags.3?ReplyMarkup rich_message:flags.4?InputRichMessage random_id:long reply_to:flags.5?InputReplyTo = Updates

Returns

Updates

This type can be an instance of either:

UpdateShortUpdateShortChatMessage
UpdateShortMessageUpdateShortSentMessage
UpdatesUpdatesCombined
UpdatesTooLong

Parameters

peerInputPeerAnything entity-like will work if the library can find its Input version (e.g., usernames, Peer, User or Channel objects, etc.).
receiver_idInputUserAnything entity-like will work if the library can find its Input version (e.g., usernames, Peer, User or Channel objects, etc.).
messagestring
query_idlongThis argument defaults to None and can be omitted.
entitiesMessageEntityThis argument defaults to None and can be omitted. Otherwise, a list must be supplied.
mediaInputMediaThis argument defaults to None and can be omitted.
reply_markupReplyMarkupThis argument defaults to None and can be omitted.
rich_messageInputRichMessageThis argument defaults to None and can be omitted.
random_idlongIf left unspecified, it will be inferred automatically.
reply_toInputReplyToThis argument defaults to None and can be omitted.

Known RPC errors

This request can't cause any RPC error as far as we know.

Example

from telethon.sync import TelegramClient
from telethon import functions, types

with TelegramClient(name, api_id, api_hash) as client:
    result = client(functions.ephemeral.SendMessageRequest(
        peer='username',
        receiver_id='username',
        message='Hello there!',
        query_id=-12398745604826,
        media=types.InputMediaUploadedPhoto(
            file=client.upload_file('/path/to/file.jpg'),
            spoiler=True,
            live_photo=True,
            stickers=[types.InputDocument(
                id=-12398745604826,
                access_hash=-12398745604826,
                file_reference=b'arbitrary\x7f data \xfa here'
            )],
            ttl_seconds=42,
            video=types.InputDocument(
                id=-12398745604826,
                access_hash=-12398745604826,
                file_reference=b'arbitrary\x7f data \xfa here'
            )
        ),
        rich_message=types.InputRichMessage(
            blocks=[types.PageBlockUnsupported()],
            rtl=True,
            noautolink=True,
            photos=[types.InputPhoto(
                id=-12398745604826,
                access_hash=-12398745604826,
                file_reference=b'arbitrary\x7f data \xfa here'
            )],
            documents=[types.InputDocument(
                id=-12398745604826,
                access_hash=-12398745604826,
                file_reference=b'arbitrary\x7f data \xfa here'
            )],
            users=['username']
        ),
        reply_to=types.InputReplyToMessage(
            reply_to_msg_id=42,
            top_msg_id=42,
            reply_to_peer_id='username',
            quote_text='some string here',
            quote_entities=[types.MessageEntityUnknown(
                offset=42,
                length=42
            )],
            quote_offset=42,
            monoforum_peer_id='username',
            todo_item_id=42,
            poll_option=b'arbitrary\x7f data \xfa here'
        )
    ))
    print(result.stringify())