messages.sendEncrypted
Sends a text message to a secret chat.
func (c *Client) MessagesSendEncrypted(ctx context.Context, request *MessagesSendEncryptedRequest) (MessagesSentEncryptedMessageClass, error)
Calling this method
client.Run(ctx, func(ctx context.Context) error {
api := client.API()
res, err := api.MessagesSendEncrypted(ctx, &tg.MessagesSendEncryptedRequest{
// see Parameters
})
if err != nil {
return err
}
_ = res // MessagesSentEncryptedMessageClass
return nil
})
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
Silent | bool | — | Send encrypted message without a notification |
Peer | InputEncryptedChat | yes | Secret chat ID |
RandomID | int64 | yes | Unique client message ID, necessary to avoid message resending |
Data | []byte | yes | TL-serialization of DecryptedMessage type, encrypted with a key that was created during chat initialization |
Returns
MessagesSentEncryptedMessageClass
Possible errors
| Code | Type | Description |
|---|---|---|
| 400 | CHAT_ID_INVALID | The provided chat id is invalid. |
| 400 | DATA_INVALID | Encrypted data invalid. |
| 400 | DATA_TOO_LONG | Data too long. |
| 400 | ENCRYPTION_DECLINED | The secret chat was declined. |
| 500 | MSG_WAIT_FAILED | A waiting call returned an error. |
| 403 | USER_IS_BLOCKED | You were blocked by this user. |
References
- Official documentation
- Generated Go reference
- TL definition:
messages.sendEncrypted#44fa7a15