SaveDraftRequest

Only users can use this request. See code examples.

---functions---
messages.saveDraft#d372c5ce flags:# no_webpage:flags.1?true invert_media:flags.6?true reply_to:flags.4?InputReplyTo peer:InputPeer message:string entities:flags.3?Vector<MessageEntity> media:flags.5?InputMedia effect:flags.7?long = Bool

Returns

Bool

This type has no instances available.

Parameters

peerInputPeerAnything entity-like will work if the library can find its Input version (e.g., usernames, Peer, User or Channel objects, etc.).
messagestring
no_webpageflagThis argument defaults to None and can be omitted.
invert_mediaflagThis argument defaults to None and can be omitted.
reply_toInputReplyToThis 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.
effectlongThis argument defaults to None and can be omitted.

Known RPC errors

This request can cause 2 known errors:

EntityBoundsInvalidErrorSome of provided entities have invalid bounds (length is zero or out of the boundaries of the string).
PeerIdInvalidErrorAn invalid Peer was used. Make sure to pass the right peer type and that the value is valid (for instance, bots cannot start conversations).

You can import these from telethon.errors.

Example

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

with TelegramClient(name, api_id, api_hash) as client:
    result = client(functions.messages.SaveDraftRequest(
        peer='username',
        message='Hello there!',
        no_webpage=True,
        invert_media=True,
        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
        ),
        media=types.InputMediaUploadedPhoto(
            file=client.upload_file('/path/to/file.jpg'),
            spoiler=True,
            stickers=[types.InputDocument(
                id=-12398745604826,
                access_hash=-12398745604826,
                file_reference=b'arbitrary\x7f data \xfa here'
            )],
            ttl_seconds=42
        ),
        effect=-12398745604826
    ))
    print(result)