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 MessagesSendEncryptedServiceRequest struct {
Peer InputEncryptedChat
RandomID int64
Data []byte
}
const MessagesSendEncryptedServiceRequestTypeID = 0x32d439a4
var (
_ bin .Encoder = &MessagesSendEncryptedServiceRequest {}
_ bin .Decoder = &MessagesSendEncryptedServiceRequest {}
_ bin .BareEncoder = &MessagesSendEncryptedServiceRequest {}
_ bin .BareDecoder = &MessagesSendEncryptedServiceRequest {}
)
func (s *MessagesSendEncryptedServiceRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Peer .Zero ()) {
return false
}
if !(s .RandomID == 0 ) {
return false
}
if !(s .Data == nil ) {
return false
}
return true
}
func (s *MessagesSendEncryptedServiceRequest ) String () string {
if s == nil {
return "MessagesSendEncryptedServiceRequest(nil)"
}
type Alias MessagesSendEncryptedServiceRequest
return fmt .Sprintf ("MessagesSendEncryptedServiceRequest%+v" , Alias (*s ))
}
func (s *MessagesSendEncryptedServiceRequest ) FillFrom (from interface {
GetPeer () (value InputEncryptedChat )
GetRandomID () (value int64 )
GetData () (value []byte )
}) {
s .Peer = from .GetPeer ()
s .RandomID = from .GetRandomID ()
s .Data = from .GetData ()
}
func (*MessagesSendEncryptedServiceRequest ) TypeID () uint32 {
return MessagesSendEncryptedServiceRequestTypeID
}
func (*MessagesSendEncryptedServiceRequest ) TypeName () string {
return "messages.sendEncryptedService"
}
func (s *MessagesSendEncryptedServiceRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.sendEncryptedService" ,
ID : MessagesSendEncryptedServiceRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "RandomID" ,
SchemaName : "random_id" ,
},
{
Name : "Data" ,
SchemaName : "data" ,
},
}
return typ
}
func (s *MessagesSendEncryptedServiceRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.sendEncryptedService#32d439a4 as nil" )
}
b .PutID (MessagesSendEncryptedServiceRequestTypeID )
return s .EncodeBare (b )
}
func (s *MessagesSendEncryptedServiceRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.sendEncryptedService#32d439a4 as nil" )
}
if err := s .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.sendEncryptedService#32d439a4: field peer: %w" , err )
}
b .PutLong (s .RandomID )
b .PutBytes (s .Data )
return nil
}
func (s *MessagesSendEncryptedServiceRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.sendEncryptedService#32d439a4 to nil" )
}
if err := b .ConsumeID (MessagesSendEncryptedServiceRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.sendEncryptedService#32d439a4: %w" , err )
}
return s .DecodeBare (b )
}
func (s *MessagesSendEncryptedServiceRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.sendEncryptedService#32d439a4 to nil" )
}
{
if err := s .Peer .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.sendEncryptedService#32d439a4: field peer: %w" , err )
}
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode messages.sendEncryptedService#32d439a4: field random_id: %w" , err )
}
s .RandomID = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode messages.sendEncryptedService#32d439a4: field data: %w" , err )
}
s .Data = value
}
return nil
}
func (s *MessagesSendEncryptedServiceRequest ) GetPeer () (value InputEncryptedChat ) {
if s == nil {
return
}
return s .Peer
}
func (s *MessagesSendEncryptedServiceRequest ) GetRandomID () (value int64 ) {
if s == nil {
return
}
return s .RandomID
}
func (s *MessagesSendEncryptedServiceRequest ) GetData () (value []byte ) {
if s == nil {
return
}
return s .Data
}
func (c *Client ) MessagesSendEncryptedService (ctx context .Context , request *MessagesSendEncryptedServiceRequest ) (MessagesSentEncryptedMessageClass , error ) {
var result MessagesSentEncryptedMessageBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .SentEncryptedMessage , 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 .