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 MessagesSendMultiMediaRequest struct {
Flags bin .Fields
Silent bool
Background bool
ClearDraft bool
Noforwards bool
UpdateStickersetsOrder bool
InvertMedia bool
Peer InputPeerClass
ReplyTo InputReplyToClass
MultiMedia []InputSingleMedia
ScheduleDate int
SendAs InputPeerClass
}
const MessagesSendMultiMediaRequestTypeID = 0x456e8987
var (
_ bin .Encoder = &MessagesSendMultiMediaRequest {}
_ bin .Decoder = &MessagesSendMultiMediaRequest {}
_ bin .BareEncoder = &MessagesSendMultiMediaRequest {}
_ bin .BareDecoder = &MessagesSendMultiMediaRequest {}
)
func (s *MessagesSendMultiMediaRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Silent == false ) {
return false
}
if !(s .Background == false ) {
return false
}
if !(s .ClearDraft == false ) {
return false
}
if !(s .Noforwards == false ) {
return false
}
if !(s .UpdateStickersetsOrder == false ) {
return false
}
if !(s .InvertMedia == false ) {
return false
}
if !(s .Peer == nil ) {
return false
}
if !(s .ReplyTo == nil ) {
return false
}
if !(s .MultiMedia == nil ) {
return false
}
if !(s .ScheduleDate == 0 ) {
return false
}
if !(s .SendAs == nil ) {
return false
}
return true
}
func (s *MessagesSendMultiMediaRequest ) String () string {
if s == nil {
return "MessagesSendMultiMediaRequest(nil)"
}
type Alias MessagesSendMultiMediaRequest
return fmt .Sprintf ("MessagesSendMultiMediaRequest%+v" , Alias (*s ))
}
func (s *MessagesSendMultiMediaRequest ) FillFrom (from interface {
GetSilent () (value bool )
GetBackground () (value bool )
GetClearDraft () (value bool )
GetNoforwards () (value bool )
GetUpdateStickersetsOrder () (value bool )
GetInvertMedia () (value bool )
GetPeer () (value InputPeerClass )
GetReplyTo () (value InputReplyToClass , ok bool )
GetMultiMedia () (value []InputSingleMedia )
GetScheduleDate () (value int , ok bool )
GetSendAs () (value InputPeerClass , ok bool )
}) {
s .Silent = from .GetSilent ()
s .Background = from .GetBackground ()
s .ClearDraft = from .GetClearDraft ()
s .Noforwards = from .GetNoforwards ()
s .UpdateStickersetsOrder = from .GetUpdateStickersetsOrder ()
s .InvertMedia = from .GetInvertMedia ()
s .Peer = from .GetPeer ()
if val , ok := from .GetReplyTo (); ok {
s .ReplyTo = val
}
s .MultiMedia = from .GetMultiMedia ()
if val , ok := from .GetScheduleDate (); ok {
s .ScheduleDate = val
}
if val , ok := from .GetSendAs (); ok {
s .SendAs = val
}
}
func (*MessagesSendMultiMediaRequest ) TypeID () uint32 {
return MessagesSendMultiMediaRequestTypeID
}
func (*MessagesSendMultiMediaRequest ) TypeName () string {
return "messages.sendMultiMedia"
}
func (s *MessagesSendMultiMediaRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.sendMultiMedia" ,
ID : MessagesSendMultiMediaRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Silent" ,
SchemaName : "silent" ,
Null : !s .Flags .Has (5 ),
},
{
Name : "Background" ,
SchemaName : "background" ,
Null : !s .Flags .Has (6 ),
},
{
Name : "ClearDraft" ,
SchemaName : "clear_draft" ,
Null : !s .Flags .Has (7 ),
},
{
Name : "Noforwards" ,
SchemaName : "noforwards" ,
Null : !s .Flags .Has (14 ),
},
{
Name : "UpdateStickersetsOrder" ,
SchemaName : "update_stickersets_order" ,
Null : !s .Flags .Has (15 ),
},
{
Name : "InvertMedia" ,
SchemaName : "invert_media" ,
Null : !s .Flags .Has (16 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "ReplyTo" ,
SchemaName : "reply_to" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "MultiMedia" ,
SchemaName : "multi_media" ,
},
{
Name : "ScheduleDate" ,
SchemaName : "schedule_date" ,
Null : !s .Flags .Has (10 ),
},
{
Name : "SendAs" ,
SchemaName : "send_as" ,
Null : !s .Flags .Has (13 ),
},
}
return typ
}
func (s *MessagesSendMultiMediaRequest ) SetFlags () {
if !(s .Silent == false ) {
s .Flags .Set (5 )
}
if !(s .Background == false ) {
s .Flags .Set (6 )
}
if !(s .ClearDraft == false ) {
s .Flags .Set (7 )
}
if !(s .Noforwards == false ) {
s .Flags .Set (14 )
}
if !(s .UpdateStickersetsOrder == false ) {
s .Flags .Set (15 )
}
if !(s .InvertMedia == false ) {
s .Flags .Set (16 )
}
if !(s .ReplyTo == nil ) {
s .Flags .Set (0 )
}
if !(s .ScheduleDate == 0 ) {
s .Flags .Set (10 )
}
if !(s .SendAs == nil ) {
s .Flags .Set (13 )
}
}
func (s *MessagesSendMultiMediaRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.sendMultiMedia#456e8987 as nil" )
}
b .PutID (MessagesSendMultiMediaRequestTypeID )
return s .EncodeBare (b )
}
func (s *MessagesSendMultiMediaRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.sendMultiMedia#456e8987 as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.sendMultiMedia#456e8987: field flags: %w" , err )
}
if s .Peer == nil {
return fmt .Errorf ("unable to encode messages.sendMultiMedia#456e8987: field peer is nil" )
}
if err := s .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.sendMultiMedia#456e8987: field peer: %w" , err )
}
if s .Flags .Has (0 ) {
if s .ReplyTo == nil {
return fmt .Errorf ("unable to encode messages.sendMultiMedia#456e8987: field reply_to is nil" )
}
if err := s .ReplyTo .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.sendMultiMedia#456e8987: field reply_to: %w" , err )
}
}
b .PutVectorHeader (len (s .MultiMedia ))
for idx , v := range s .MultiMedia {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.sendMultiMedia#456e8987: field multi_media element with index %d: %w" , idx , err )
}
}
if s .Flags .Has (10 ) {
b .PutInt (s .ScheduleDate )
}
if s .Flags .Has (13 ) {
if s .SendAs == nil {
return fmt .Errorf ("unable to encode messages.sendMultiMedia#456e8987: field send_as is nil" )
}
if err := s .SendAs .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.sendMultiMedia#456e8987: field send_as: %w" , err )
}
}
return nil
}
func (s *MessagesSendMultiMediaRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.sendMultiMedia#456e8987 to nil" )
}
if err := b .ConsumeID (MessagesSendMultiMediaRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.sendMultiMedia#456e8987: %w" , err )
}
return s .DecodeBare (b )
}
func (s *MessagesSendMultiMediaRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.sendMultiMedia#456e8987 to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.sendMultiMedia#456e8987: field flags: %w" , err )
}
}
s .Silent = s .Flags .Has (5 )
s .Background = s .Flags .Has (6 )
s .ClearDraft = s .Flags .Has (7 )
s .Noforwards = s .Flags .Has (14 )
s .UpdateStickersetsOrder = s .Flags .Has (15 )
s .InvertMedia = s .Flags .Has (16 )
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.sendMultiMedia#456e8987: field peer: %w" , err )
}
s .Peer = value
}
if s .Flags .Has (0 ) {
value , err := DecodeInputReplyTo (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.sendMultiMedia#456e8987: field reply_to: %w" , err )
}
s .ReplyTo = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.sendMultiMedia#456e8987: field multi_media: %w" , err )
}
if headerLen > 0 {
s .MultiMedia = make ([]InputSingleMedia , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value InputSingleMedia
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.sendMultiMedia#456e8987: field multi_media: %w" , err )
}
s .MultiMedia = append (s .MultiMedia , value )
}
}
if s .Flags .Has (10 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.sendMultiMedia#456e8987: field schedule_date: %w" , err )
}
s .ScheduleDate = value
}
if s .Flags .Has (13 ) {
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.sendMultiMedia#456e8987: field send_as: %w" , err )
}
s .SendAs = value
}
return nil
}
func (s *MessagesSendMultiMediaRequest ) SetSilent (value bool ) {
if value {
s .Flags .Set (5 )
s .Silent = true
} else {
s .Flags .Unset (5 )
s .Silent = false
}
}
func (s *MessagesSendMultiMediaRequest ) GetSilent () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (5 )
}
func (s *MessagesSendMultiMediaRequest ) SetBackground (value bool ) {
if value {
s .Flags .Set (6 )
s .Background = true
} else {
s .Flags .Unset (6 )
s .Background = false
}
}
func (s *MessagesSendMultiMediaRequest ) GetBackground () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (6 )
}
func (s *MessagesSendMultiMediaRequest ) SetClearDraft (value bool ) {
if value {
s .Flags .Set (7 )
s .ClearDraft = true
} else {
s .Flags .Unset (7 )
s .ClearDraft = false
}
}
func (s *MessagesSendMultiMediaRequest ) GetClearDraft () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (7 )
}
func (s *MessagesSendMultiMediaRequest ) SetNoforwards (value bool ) {
if value {
s .Flags .Set (14 )
s .Noforwards = true
} else {
s .Flags .Unset (14 )
s .Noforwards = false
}
}
func (s *MessagesSendMultiMediaRequest ) GetNoforwards () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (14 )
}
func (s *MessagesSendMultiMediaRequest ) SetUpdateStickersetsOrder (value bool ) {
if value {
s .Flags .Set (15 )
s .UpdateStickersetsOrder = true
} else {
s .Flags .Unset (15 )
s .UpdateStickersetsOrder = false
}
}
func (s *MessagesSendMultiMediaRequest ) GetUpdateStickersetsOrder () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (15 )
}
func (s *MessagesSendMultiMediaRequest ) SetInvertMedia (value bool ) {
if value {
s .Flags .Set (16 )
s .InvertMedia = true
} else {
s .Flags .Unset (16 )
s .InvertMedia = false
}
}
func (s *MessagesSendMultiMediaRequest ) GetInvertMedia () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (16 )
}
func (s *MessagesSendMultiMediaRequest ) GetPeer () (value InputPeerClass ) {
if s == nil {
return
}
return s .Peer
}
func (s *MessagesSendMultiMediaRequest ) SetReplyTo (value InputReplyToClass ) {
s .Flags .Set (0 )
s .ReplyTo = value
}
func (s *MessagesSendMultiMediaRequest ) GetReplyTo () (value InputReplyToClass , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .ReplyTo , true
}
func (s *MessagesSendMultiMediaRequest ) GetMultiMedia () (value []InputSingleMedia ) {
if s == nil {
return
}
return s .MultiMedia
}
func (s *MessagesSendMultiMediaRequest ) SetScheduleDate (value int ) {
s .Flags .Set (10 )
s .ScheduleDate = value
}
func (s *MessagesSendMultiMediaRequest ) GetScheduleDate () (value int , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (10 ) {
return value , false
}
return s .ScheduleDate , true
}
func (s *MessagesSendMultiMediaRequest ) SetSendAs (value InputPeerClass ) {
s .Flags .Set (13 )
s .SendAs = value
}
func (s *MessagesSendMultiMediaRequest ) GetSendAs () (value InputPeerClass , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (13 ) {
return value , false
}
return s .SendAs , true
}
func (c *Client ) MessagesSendMultiMedia (ctx context .Context , request *MessagesSendMultiMediaRequest ) (UpdatesClass , error ) {
var result UpdatesBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .Updates , 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 .