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 StickersCreateStickerSetRequest struct {
Flags bin .Fields
Masks bool
Animated bool
Videos bool
Emojis bool
TextColor bool
UserID InputUserClass
Title string
ShortName string
Thumb InputDocumentClass
Stickers []InputStickerSetItem
Software string
}
const StickersCreateStickerSetRequestTypeID = 0x9021ab67
var (
_ bin .Encoder = &StickersCreateStickerSetRequest {}
_ bin .Decoder = &StickersCreateStickerSetRequest {}
_ bin .BareEncoder = &StickersCreateStickerSetRequest {}
_ bin .BareDecoder = &StickersCreateStickerSetRequest {}
)
func (c *StickersCreateStickerSetRequest ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .Masks == false ) {
return false
}
if !(c .Animated == false ) {
return false
}
if !(c .Videos == false ) {
return false
}
if !(c .Emojis == false ) {
return false
}
if !(c .TextColor == false ) {
return false
}
if !(c .UserID == nil ) {
return false
}
if !(c .Title == "" ) {
return false
}
if !(c .ShortName == "" ) {
return false
}
if !(c .Thumb == nil ) {
return false
}
if !(c .Stickers == nil ) {
return false
}
if !(c .Software == "" ) {
return false
}
return true
}
func (c *StickersCreateStickerSetRequest ) String () string {
if c == nil {
return "StickersCreateStickerSetRequest(nil)"
}
type Alias StickersCreateStickerSetRequest
return fmt .Sprintf ("StickersCreateStickerSetRequest%+v" , Alias (*c ))
}
func (c *StickersCreateStickerSetRequest ) FillFrom (from interface {
GetMasks () (value bool )
GetAnimated () (value bool )
GetVideos () (value bool )
GetEmojis () (value bool )
GetTextColor () (value bool )
GetUserID () (value InputUserClass )
GetTitle () (value string )
GetShortName () (value string )
GetThumb () (value InputDocumentClass , ok bool )
GetStickers () (value []InputStickerSetItem )
GetSoftware () (value string , ok bool )
}) {
c .Masks = from .GetMasks ()
c .Animated = from .GetAnimated ()
c .Videos = from .GetVideos ()
c .Emojis = from .GetEmojis ()
c .TextColor = from .GetTextColor ()
c .UserID = from .GetUserID ()
c .Title = from .GetTitle ()
c .ShortName = from .GetShortName ()
if val , ok := from .GetThumb (); ok {
c .Thumb = val
}
c .Stickers = from .GetStickers ()
if val , ok := from .GetSoftware (); ok {
c .Software = val
}
}
func (*StickersCreateStickerSetRequest ) TypeID () uint32 {
return StickersCreateStickerSetRequestTypeID
}
func (*StickersCreateStickerSetRequest ) TypeName () string {
return "stickers.createStickerSet"
}
func (c *StickersCreateStickerSetRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "stickers.createStickerSet" ,
ID : StickersCreateStickerSetRequestTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Masks" ,
SchemaName : "masks" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "Animated" ,
SchemaName : "animated" ,
Null : !c .Flags .Has (1 ),
},
{
Name : "Videos" ,
SchemaName : "videos" ,
Null : !c .Flags .Has (4 ),
},
{
Name : "Emojis" ,
SchemaName : "emojis" ,
Null : !c .Flags .Has (5 ),
},
{
Name : "TextColor" ,
SchemaName : "text_color" ,
Null : !c .Flags .Has (6 ),
},
{
Name : "UserID" ,
SchemaName : "user_id" ,
},
{
Name : "Title" ,
SchemaName : "title" ,
},
{
Name : "ShortName" ,
SchemaName : "short_name" ,
},
{
Name : "Thumb" ,
SchemaName : "thumb" ,
Null : !c .Flags .Has (2 ),
},
{
Name : "Stickers" ,
SchemaName : "stickers" ,
},
{
Name : "Software" ,
SchemaName : "software" ,
Null : !c .Flags .Has (3 ),
},
}
return typ
}
func (c *StickersCreateStickerSetRequest ) SetFlags () {
if !(c .Masks == false ) {
c .Flags .Set (0 )
}
if !(c .Animated == false ) {
c .Flags .Set (1 )
}
if !(c .Videos == false ) {
c .Flags .Set (4 )
}
if !(c .Emojis == false ) {
c .Flags .Set (5 )
}
if !(c .TextColor == false ) {
c .Flags .Set (6 )
}
if !(c .Thumb == nil ) {
c .Flags .Set (2 )
}
if !(c .Software == "" ) {
c .Flags .Set (3 )
}
}
func (c *StickersCreateStickerSetRequest ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode stickers.createStickerSet#9021ab67 as nil" )
}
b .PutID (StickersCreateStickerSetRequestTypeID )
return c .EncodeBare (b )
}
func (c *StickersCreateStickerSetRequest ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode stickers.createStickerSet#9021ab67 as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stickers.createStickerSet#9021ab67: field flags: %w" , err )
}
if c .UserID == nil {
return fmt .Errorf ("unable to encode stickers.createStickerSet#9021ab67: field user_id is nil" )
}
if err := c .UserID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stickers.createStickerSet#9021ab67: field user_id: %w" , err )
}
b .PutString (c .Title )
b .PutString (c .ShortName )
if c .Flags .Has (2 ) {
if c .Thumb == nil {
return fmt .Errorf ("unable to encode stickers.createStickerSet#9021ab67: field thumb is nil" )
}
if err := c .Thumb .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stickers.createStickerSet#9021ab67: field thumb: %w" , err )
}
}
b .PutVectorHeader (len (c .Stickers ))
for idx , v := range c .Stickers {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stickers.createStickerSet#9021ab67: field stickers element with index %d: %w" , idx , err )
}
}
if c .Flags .Has (3 ) {
b .PutString (c .Software )
}
return nil
}
func (c *StickersCreateStickerSetRequest ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode stickers.createStickerSet#9021ab67 to nil" )
}
if err := b .ConsumeID (StickersCreateStickerSetRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode stickers.createStickerSet#9021ab67: %w" , err )
}
return c .DecodeBare (b )
}
func (c *StickersCreateStickerSetRequest ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode stickers.createStickerSet#9021ab67 to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode stickers.createStickerSet#9021ab67: field flags: %w" , err )
}
}
c .Masks = c .Flags .Has (0 )
c .Animated = c .Flags .Has (1 )
c .Videos = c .Flags .Has (4 )
c .Emojis = c .Flags .Has (5 )
c .TextColor = c .Flags .Has (6 )
{
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode stickers.createStickerSet#9021ab67: field user_id: %w" , err )
}
c .UserID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode stickers.createStickerSet#9021ab67: field title: %w" , err )
}
c .Title = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode stickers.createStickerSet#9021ab67: field short_name: %w" , err )
}
c .ShortName = value
}
if c .Flags .Has (2 ) {
value , err := DecodeInputDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode stickers.createStickerSet#9021ab67: field thumb: %w" , err )
}
c .Thumb = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stickers.createStickerSet#9021ab67: field stickers: %w" , err )
}
if headerLen > 0 {
c .Stickers = make ([]InputStickerSetItem , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value InputStickerSetItem
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode stickers.createStickerSet#9021ab67: field stickers: %w" , err )
}
c .Stickers = append (c .Stickers , value )
}
}
if c .Flags .Has (3 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode stickers.createStickerSet#9021ab67: field software: %w" , err )
}
c .Software = value
}
return nil
}
func (c *StickersCreateStickerSetRequest ) SetMasks (value bool ) {
if value {
c .Flags .Set (0 )
c .Masks = true
} else {
c .Flags .Unset (0 )
c .Masks = false
}
}
func (c *StickersCreateStickerSetRequest ) GetMasks () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (0 )
}
func (c *StickersCreateStickerSetRequest ) SetAnimated (value bool ) {
if value {
c .Flags .Set (1 )
c .Animated = true
} else {
c .Flags .Unset (1 )
c .Animated = false
}
}
func (c *StickersCreateStickerSetRequest ) GetAnimated () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (1 )
}
func (c *StickersCreateStickerSetRequest ) SetVideos (value bool ) {
if value {
c .Flags .Set (4 )
c .Videos = true
} else {
c .Flags .Unset (4 )
c .Videos = false
}
}
func (c *StickersCreateStickerSetRequest ) GetVideos () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (4 )
}
func (c *StickersCreateStickerSetRequest ) SetEmojis (value bool ) {
if value {
c .Flags .Set (5 )
c .Emojis = true
} else {
c .Flags .Unset (5 )
c .Emojis = false
}
}
func (c *StickersCreateStickerSetRequest ) GetEmojis () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (5 )
}
func (c *StickersCreateStickerSetRequest ) SetTextColor (value bool ) {
if value {
c .Flags .Set (6 )
c .TextColor = true
} else {
c .Flags .Unset (6 )
c .TextColor = false
}
}
func (c *StickersCreateStickerSetRequest ) GetTextColor () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (6 )
}
func (c *StickersCreateStickerSetRequest ) GetUserID () (value InputUserClass ) {
if c == nil {
return
}
return c .UserID
}
func (c *StickersCreateStickerSetRequest ) GetTitle () (value string ) {
if c == nil {
return
}
return c .Title
}
func (c *StickersCreateStickerSetRequest ) GetShortName () (value string ) {
if c == nil {
return
}
return c .ShortName
}
func (c *StickersCreateStickerSetRequest ) SetThumb (value InputDocumentClass ) {
c .Flags .Set (2 )
c .Thumb = value
}
func (c *StickersCreateStickerSetRequest ) GetThumb () (value InputDocumentClass , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (2 ) {
return value , false
}
return c .Thumb , true
}
func (c *StickersCreateStickerSetRequest ) GetStickers () (value []InputStickerSetItem ) {
if c == nil {
return
}
return c .Stickers
}
func (c *StickersCreateStickerSetRequest ) SetSoftware (value string ) {
c .Flags .Set (3 )
c .Software = value
}
func (c *StickersCreateStickerSetRequest ) GetSoftware () (value string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (3 ) {
return value , false
}
return c .Software , true
}
func (c *StickersCreateStickerSetRequest ) GetThumbAsNotEmpty () (*InputDocument , bool ) {
if value , ok := c .GetThumb (); ok {
return value .AsNotEmpty ()
}
return nil , false
}
func (c *Client ) StickersCreateStickerSet (ctx context .Context , request *StickersCreateStickerSetRequest ) (MessagesStickerSetClass , error ) {
var result MessagesStickerSetBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .StickerSet , 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 .