messages.sendEncryptedFile
Sends a message with a file attachment to a secret chat
func (c *Client) MessagesSendEncryptedFile(ctx context.Context, request *MessagesSendEncryptedFileRequest) (MessagesSentEncryptedMessageClass, error)
Calling this method
client.Run(ctx, func(ctx context.Context) error {
api := client.API()
res, err := api.MessagesSendEncryptedFile(ctx, &tg.MessagesSendEncryptedFileRequest{
// see Parameters
})
if err != nil {
return err
}
_ = res // MessagesSentEncryptedMessageClass
return nil
})
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
Silent | bool | — | Whether to send the file without triggering a notification |
Peer | InputEncryptedChat | yes | Secret chat ID |
RandomID | int64 | yes | Unique client message ID necessary to prevent message resending |
Data | []byte | yes | TL-serialization of DecryptedMessage type, encrypted with a key generated during chat initialization |
File | InputEncryptedFileClass | yes | File attachment for the secret chat |
Returns
MessagesSentEncryptedMessageClass
Possible errors
| Code | Type | Description |
|---|---|---|
| 400 | CHAT_ID_INVALID | The provided chat id is invalid. |
| 400 | DATA_TOO_LONG | Data too long. |
| 400 | ENCRYPTION_DECLINED | The secret chat was declined. |
| 400 | FILE_EMTPY | An empty file was provided. |
| 400 | MD5_CHECKSUM_INVALID | The MD5 checksums do not match. |
| 400 | MSG_WAIT_FAILED | A waiting call returned an error. |
References
- Official documentation
- Generated Go reference
- TL definition:
messages.sendEncryptedFile#5559481d