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