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:
| UpdateShort | UpdateShortChatMessage |
| UpdateShortMessage | UpdateShortSentMessage |
| Updates | UpdatesCombined |
| UpdatesTooLong |
Parameters
| peer | InputPeer | Anything entity-like will work if the library can find its Input version (e.g., usernames, Peer, User or Channel objects, etc.). |
| receiver_id | InputUser | Anything entity-like will work if the library can find its Input version (e.g., usernames, Peer, User or Channel objects, etc.). |
| message | string | |
| query_id | long | This argument defaults to None and can be omitted. |
| entities | MessageEntity | This argument defaults to None and can be omitted. Otherwise, a list must be supplied. |
| media | InputMedia | This argument defaults to None and can be omitted. |
| reply_markup | ReplyMarkup | This argument defaults to None and can be omitted. |
| rich_message | InputRichMessage | This argument defaults to None and can be omitted. |
| random_id | long | If left unspecified, it will be inferred automatically. |
| reply_to | InputReplyTo | This 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())