messages.sendEncrypted

Sends a text message to a secret chat.

Example

const {Api, TelegramClient} = require('telegram');
const {StringSession} = require('telegram/sessions');

const session = new StringSession('');
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
    const result = await client.invoke(new Api.messages.sendEncrypted({
        silent: true,
        peer: new Api.InputEncryptedChat({...}),
        randomId: 2927390,
        data: Buffer.from('some bytes here'),
        }));
    console.log(result); // prints the result
})();

TL schema

messages.sentEncryptedMessage#560f8935 date:int = messages.SentEncryptedMessage;
messages.sentEncryptedFile#9493ff32 date:int file:EncryptedFile = messages.SentEncryptedMessage;
---functions---
messages.sendEncrypted#44fa7a15 flags:# silent:flags.0?true peer:InputEncryptedChat random_id:long data:bytes = messages.SentEncryptedMessage;

Parameters

Name

Type

Description

flags

silent

Send encrypted message without a notification

peer

Secret chat ID

random_id

Unique client message ID, necessary to avoid message resending

data

TL-serialization of DecryptedMessage type, encrypted with a key that was created during chat initialization

Result

messages.SentEncryptedMessage

Possible errors

Code

Type

Description

400

CHAT_ID_INVALID

The provided chat id is invalid

400

DATA_INVALID

Encrypted data invalid

400

ENCRYPTION_DECLINED

The secret chat was declined

400

MSG_WAIT_FAILED

A waiting call returned an error

Can bots use this methd ?

yes

Object describes the contents of an encrypted message.

Last updated