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 MessagesSendEncryptedFileRequest struct {
Flags bin .Fields
Silent bool
Peer InputEncryptedChat
RandomID int64
Data []byte
File InputEncryptedFileClass
}
const MessagesSendEncryptedFileRequestTypeID = 0x5559481d
var (
_ bin .Encoder = &MessagesSendEncryptedFileRequest {}
_ bin .Decoder = &MessagesSendEncryptedFileRequest {}
_ bin .BareEncoder = &MessagesSendEncryptedFileRequest {}
_ bin .BareDecoder = &MessagesSendEncryptedFileRequest {}
)
func (s *MessagesSendEncryptedFileRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Silent == false ) {
return false
}
if !(s .Peer .Zero ()) {
return false
}
if !(s .RandomID == 0 ) {
return false
}
if !(s .Data == nil ) {
return false
}
if !(s .File == nil ) {
return false
}
return true
}
func (s *MessagesSendEncryptedFileRequest ) String () string {
if s == nil {
return "MessagesSendEncryptedFileRequest(nil)"
}
type Alias MessagesSendEncryptedFileRequest
return fmt .Sprintf ("MessagesSendEncryptedFileRequest%+v" , Alias (*s ))
}
func (s *MessagesSendEncryptedFileRequest ) FillFrom (from interface {
GetSilent () (value bool )
GetPeer () (value InputEncryptedChat )
GetRandomID () (value int64 )
GetData () (value []byte )
GetFile () (value InputEncryptedFileClass )
}) {
s .Silent = from .GetSilent ()
s .Peer = from .GetPeer ()
s .RandomID = from .GetRandomID ()
s .Data = from .GetData ()
s .File = from .GetFile ()
}
func (*MessagesSendEncryptedFileRequest ) TypeID () uint32 {
return MessagesSendEncryptedFileRequestTypeID
}
func (*MessagesSendEncryptedFileRequest ) TypeName () string {
return "messages.sendEncryptedFile"
}
func (s *MessagesSendEncryptedFileRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.sendEncryptedFile" ,
ID : MessagesSendEncryptedFileRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Silent" ,
SchemaName : "silent" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "RandomID" ,
SchemaName : "random_id" ,
},
{
Name : "Data" ,
SchemaName : "data" ,
},
{
Name : "File" ,
SchemaName : "file" ,
},
}
return typ
}
func (s *MessagesSendEncryptedFileRequest ) SetFlags () {
if !(s .Silent == false ) {
s .Flags .Set (0 )
}
}
func (s *MessagesSendEncryptedFileRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.sendEncryptedFile#5559481d as nil" )
}
b .PutID (MessagesSendEncryptedFileRequestTypeID )
return s .EncodeBare (b )
}
func (s *MessagesSendEncryptedFileRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.sendEncryptedFile#5559481d as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.sendEncryptedFile#5559481d: field flags: %w" , err )
}
if err := s .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.sendEncryptedFile#5559481d: field peer: %w" , err )
}
b .PutLong (s .RandomID )
b .PutBytes (s .Data )
if s .File == nil {
return fmt .Errorf ("unable to encode messages.sendEncryptedFile#5559481d: field file is nil" )
}
if err := s .File .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.sendEncryptedFile#5559481d: field file: %w" , err )
}
return nil
}
func (s *MessagesSendEncryptedFileRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.sendEncryptedFile#5559481d to nil" )
}
if err := b .ConsumeID (MessagesSendEncryptedFileRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.sendEncryptedFile#5559481d: %w" , err )
}
return s .DecodeBare (b )
}
func (s *MessagesSendEncryptedFileRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.sendEncryptedFile#5559481d to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.sendEncryptedFile#5559481d: field flags: %w" , err )
}
}
s .Silent = s .Flags .Has (0 )
{
if err := s .Peer .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.sendEncryptedFile#5559481d: field peer: %w" , err )
}
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode messages.sendEncryptedFile#5559481d: field random_id: %w" , err )
}
s .RandomID = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode messages.sendEncryptedFile#5559481d: field data: %w" , err )
}
s .Data = value
}
{
value , err := DecodeInputEncryptedFile (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.sendEncryptedFile#5559481d: field file: %w" , err )
}
s .File = value
}
return nil
}
func (s *MessagesSendEncryptedFileRequest ) SetSilent (value bool ) {
if value {
s .Flags .Set (0 )
s .Silent = true
} else {
s .Flags .Unset (0 )
s .Silent = false
}
}
func (s *MessagesSendEncryptedFileRequest ) GetSilent () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (0 )
}
func (s *MessagesSendEncryptedFileRequest ) GetPeer () (value InputEncryptedChat ) {
if s == nil {
return
}
return s .Peer
}
func (s *MessagesSendEncryptedFileRequest ) GetRandomID () (value int64 ) {
if s == nil {
return
}
return s .RandomID
}
func (s *MessagesSendEncryptedFileRequest ) GetData () (value []byte ) {
if s == nil {
return
}
return s .Data
}
func (s *MessagesSendEncryptedFileRequest ) GetFile () (value InputEncryptedFileClass ) {
if s == nil {
return
}
return s .File
}
func (s *MessagesSendEncryptedFileRequest ) GetFileAsNotEmpty () (NotEmptyInputEncryptedFile , bool ) {
return s .File .AsNotEmpty ()
}
func (c *Client ) MessagesSendEncryptedFile (ctx context .Context , request *MessagesSendEncryptedFileRequest ) (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 .