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 MessagesToggleStickerSetsRequest struct {
Flags bin .Fields
Uninstall bool
Archive bool
Unarchive bool
Stickersets []InputStickerSetClass
}
const MessagesToggleStickerSetsRequestTypeID = 0xb5052fea
var (
_ bin .Encoder = &MessagesToggleStickerSetsRequest {}
_ bin .Decoder = &MessagesToggleStickerSetsRequest {}
_ bin .BareEncoder = &MessagesToggleStickerSetsRequest {}
_ bin .BareDecoder = &MessagesToggleStickerSetsRequest {}
)
func (t *MessagesToggleStickerSetsRequest ) Zero () bool {
if t == nil {
return true
}
if !(t .Flags .Zero ()) {
return false
}
if !(t .Uninstall == false ) {
return false
}
if !(t .Archive == false ) {
return false
}
if !(t .Unarchive == false ) {
return false
}
if !(t .Stickersets == nil ) {
return false
}
return true
}
func (t *MessagesToggleStickerSetsRequest ) String () string {
if t == nil {
return "MessagesToggleStickerSetsRequest(nil)"
}
type Alias MessagesToggleStickerSetsRequest
return fmt .Sprintf ("MessagesToggleStickerSetsRequest%+v" , Alias (*t ))
}
func (t *MessagesToggleStickerSetsRequest ) FillFrom (from interface {
GetUninstall () (value bool )
GetArchive () (value bool )
GetUnarchive () (value bool )
GetStickersets () (value []InputStickerSetClass )
}) {
t .Uninstall = from .GetUninstall ()
t .Archive = from .GetArchive ()
t .Unarchive = from .GetUnarchive ()
t .Stickersets = from .GetStickersets ()
}
func (*MessagesToggleStickerSetsRequest ) TypeID () uint32 {
return MessagesToggleStickerSetsRequestTypeID
}
func (*MessagesToggleStickerSetsRequest ) TypeName () string {
return "messages.toggleStickerSets"
}
func (t *MessagesToggleStickerSetsRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.toggleStickerSets" ,
ID : MessagesToggleStickerSetsRequestTypeID ,
}
if t == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Uninstall" ,
SchemaName : "uninstall" ,
Null : !t .Flags .Has (0 ),
},
{
Name : "Archive" ,
SchemaName : "archive" ,
Null : !t .Flags .Has (1 ),
},
{
Name : "Unarchive" ,
SchemaName : "unarchive" ,
Null : !t .Flags .Has (2 ),
},
{
Name : "Stickersets" ,
SchemaName : "stickersets" ,
},
}
return typ
}
func (t *MessagesToggleStickerSetsRequest ) SetFlags () {
if !(t .Uninstall == false ) {
t .Flags .Set (0 )
}
if !(t .Archive == false ) {
t .Flags .Set (1 )
}
if !(t .Unarchive == false ) {
t .Flags .Set (2 )
}
}
func (t *MessagesToggleStickerSetsRequest ) Encode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode messages.toggleStickerSets#b5052fea as nil" )
}
b .PutID (MessagesToggleStickerSetsRequestTypeID )
return t .EncodeBare (b )
}
func (t *MessagesToggleStickerSetsRequest ) EncodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode messages.toggleStickerSets#b5052fea as nil" )
}
t .SetFlags ()
if err := t .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.toggleStickerSets#b5052fea: field flags: %w" , err )
}
b .PutVectorHeader (len (t .Stickersets ))
for idx , v := range t .Stickersets {
if v == nil {
return fmt .Errorf ("unable to encode messages.toggleStickerSets#b5052fea: field stickersets element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.toggleStickerSets#b5052fea: field stickersets element with index %d: %w" , idx , err )
}
}
return nil
}
func (t *MessagesToggleStickerSetsRequest ) Decode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode messages.toggleStickerSets#b5052fea to nil" )
}
if err := b .ConsumeID (MessagesToggleStickerSetsRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.toggleStickerSets#b5052fea: %w" , err )
}
return t .DecodeBare (b )
}
func (t *MessagesToggleStickerSetsRequest ) DecodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode messages.toggleStickerSets#b5052fea to nil" )
}
{
if err := t .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.toggleStickerSets#b5052fea: field flags: %w" , err )
}
}
t .Uninstall = t .Flags .Has (0 )
t .Archive = t .Flags .Has (1 )
t .Unarchive = t .Flags .Has (2 )
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.toggleStickerSets#b5052fea: field stickersets: %w" , err )
}
if headerLen > 0 {
t .Stickersets = make ([]InputStickerSetClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeInputStickerSet (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.toggleStickerSets#b5052fea: field stickersets: %w" , err )
}
t .Stickersets = append (t .Stickersets , value )
}
}
return nil
}
func (t *MessagesToggleStickerSetsRequest ) SetUninstall (value bool ) {
if value {
t .Flags .Set (0 )
t .Uninstall = true
} else {
t .Flags .Unset (0 )
t .Uninstall = false
}
}
func (t *MessagesToggleStickerSetsRequest ) GetUninstall () (value bool ) {
if t == nil {
return
}
return t .Flags .Has (0 )
}
func (t *MessagesToggleStickerSetsRequest ) SetArchive (value bool ) {
if value {
t .Flags .Set (1 )
t .Archive = true
} else {
t .Flags .Unset (1 )
t .Archive = false
}
}
func (t *MessagesToggleStickerSetsRequest ) GetArchive () (value bool ) {
if t == nil {
return
}
return t .Flags .Has (1 )
}
func (t *MessagesToggleStickerSetsRequest ) SetUnarchive (value bool ) {
if value {
t .Flags .Set (2 )
t .Unarchive = true
} else {
t .Flags .Unset (2 )
t .Unarchive = false
}
}
func (t *MessagesToggleStickerSetsRequest ) GetUnarchive () (value bool ) {
if t == nil {
return
}
return t .Flags .Has (2 )
}
func (t *MessagesToggleStickerSetsRequest ) GetStickersets () (value []InputStickerSetClass ) {
if t == nil {
return
}
return t .Stickersets
}
func (t *MessagesToggleStickerSetsRequest ) MapStickersets () (value InputStickerSetClassArray ) {
return InputStickerSetClassArray (t .Stickersets )
}
func (c *Client ) MessagesToggleStickerSets (ctx context .Context , request *MessagesToggleStickerSetsRequest ) (bool , error ) {
var result BoolBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return false , err
}
_ , ok := result .Bool .(*BoolTrue )
return ok , 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 .