package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type MessagesAcceptEncryptionRequest struct {
Peer InputEncryptedChat
GB []byte
KeyFingerprint int64
}
const MessagesAcceptEncryptionRequestTypeID = 0x3dbc0415
var (
_ bin .Encoder = &MessagesAcceptEncryptionRequest {}
_ bin .Decoder = &MessagesAcceptEncryptionRequest {}
_ bin .BareEncoder = &MessagesAcceptEncryptionRequest {}
_ bin .BareDecoder = &MessagesAcceptEncryptionRequest {}
)
func (a *MessagesAcceptEncryptionRequest ) Zero () bool {
if a == nil {
return true
}
if !(a .Peer .Zero ()) {
return false
}
if !(a .GB == nil ) {
return false
}
if !(a .KeyFingerprint == 0 ) {
return false
}
return true
}
func (a *MessagesAcceptEncryptionRequest ) String () string {
if a == nil {
return "MessagesAcceptEncryptionRequest(nil)"
}
type Alias MessagesAcceptEncryptionRequest
return fmt .Sprintf ("MessagesAcceptEncryptionRequest%+v" , Alias (*a ))
}
func (a *MessagesAcceptEncryptionRequest ) FillFrom (from interface {
GetPeer () (value InputEncryptedChat )
GetGB () (value []byte )
GetKeyFingerprint () (value int64 )
}) {
a .Peer = from .GetPeer ()
a .GB = from .GetGB ()
a .KeyFingerprint = from .GetKeyFingerprint ()
}
func (*MessagesAcceptEncryptionRequest ) TypeID () uint32 {
return MessagesAcceptEncryptionRequestTypeID
}
func (*MessagesAcceptEncryptionRequest ) TypeName () string {
return "messages.acceptEncryption"
}
func (a *MessagesAcceptEncryptionRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.acceptEncryption" ,
ID : MessagesAcceptEncryptionRequestTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "GB" ,
SchemaName : "g_b" ,
},
{
Name : "KeyFingerprint" ,
SchemaName : "key_fingerprint" ,
},
}
return typ
}
func (a *MessagesAcceptEncryptionRequest ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode messages.acceptEncryption#3dbc0415 as nil" )
}
b .PutID (MessagesAcceptEncryptionRequestTypeID )
return a .EncodeBare (b )
}
func (a *MessagesAcceptEncryptionRequest ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode messages.acceptEncryption#3dbc0415 as nil" )
}
if err := a .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.acceptEncryption#3dbc0415: field peer: %w" , err )
}
b .PutBytes (a .GB )
b .PutLong (a .KeyFingerprint )
return nil
}
func (a *MessagesAcceptEncryptionRequest ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode messages.acceptEncryption#3dbc0415 to nil" )
}
if err := b .ConsumeID (MessagesAcceptEncryptionRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.acceptEncryption#3dbc0415: %w" , err )
}
return a .DecodeBare (b )
}
func (a *MessagesAcceptEncryptionRequest ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode messages.acceptEncryption#3dbc0415 to nil" )
}
{
if err := a .Peer .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.acceptEncryption#3dbc0415: field peer: %w" , err )
}
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode messages.acceptEncryption#3dbc0415: field g_b: %w" , err )
}
a .GB = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode messages.acceptEncryption#3dbc0415: field key_fingerprint: %w" , err )
}
a .KeyFingerprint = value
}
return nil
}
func (a *MessagesAcceptEncryptionRequest ) GetPeer () (value InputEncryptedChat ) {
if a == nil {
return
}
return a .Peer
}
func (a *MessagesAcceptEncryptionRequest ) GetGB () (value []byte ) {
if a == nil {
return
}
return a .GB
}
func (a *MessagesAcceptEncryptionRequest ) GetKeyFingerprint () (value int64 ) {
if a == nil {
return
}
return a .KeyFingerprint
}
func (c *Client ) MessagesAcceptEncryption (ctx context .Context , request *MessagesAcceptEncryptionRequest ) (EncryptedChatClass , error ) {
var result EncryptedChatBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .EncryptedChat , nil
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .