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 InputStickerSetItem struct {
Flags bin .Fields
Document InputDocumentClass
Emoji string
MaskCoords MaskCoords
Keywords string
}
const InputStickerSetItemTypeID = 0x32da9e9c
var (
_ bin .Encoder = &InputStickerSetItem {}
_ bin .Decoder = &InputStickerSetItem {}
_ bin .BareEncoder = &InputStickerSetItem {}
_ bin .BareDecoder = &InputStickerSetItem {}
)
func (i *InputStickerSetItem ) Zero () bool {
if i == nil {
return true
}
if !(i .Flags .Zero ()) {
return false
}
if !(i .Document == nil ) {
return false
}
if !(i .Emoji == "" ) {
return false
}
if !(i .MaskCoords .Zero ()) {
return false
}
if !(i .Keywords == "" ) {
return false
}
return true
}
func (i *InputStickerSetItem ) String () string {
if i == nil {
return "InputStickerSetItem(nil)"
}
type Alias InputStickerSetItem
return fmt .Sprintf ("InputStickerSetItem%+v" , Alias (*i ))
}
func (i *InputStickerSetItem ) FillFrom (from interface {
GetDocument () (value InputDocumentClass )
GetEmoji () (value string )
GetMaskCoords () (value MaskCoords , ok bool )
GetKeywords () (value string , ok bool )
}) {
i .Document = from .GetDocument ()
i .Emoji = from .GetEmoji ()
if val , ok := from .GetMaskCoords (); ok {
i .MaskCoords = val
}
if val , ok := from .GetKeywords (); ok {
i .Keywords = val
}
}
func (*InputStickerSetItem ) TypeID () uint32 {
return InputStickerSetItemTypeID
}
func (*InputStickerSetItem ) TypeName () string {
return "inputStickerSetItem"
}
func (i *InputStickerSetItem ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputStickerSetItem" ,
ID : InputStickerSetItemTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Document" ,
SchemaName : "document" ,
},
{
Name : "Emoji" ,
SchemaName : "emoji" ,
},
{
Name : "MaskCoords" ,
SchemaName : "mask_coords" ,
Null : !i .Flags .Has (0 ),
},
{
Name : "Keywords" ,
SchemaName : "keywords" ,
Null : !i .Flags .Has (1 ),
},
}
return typ
}
func (i *InputStickerSetItem ) SetFlags () {
if !(i .MaskCoords .Zero ()) {
i .Flags .Set (0 )
}
if !(i .Keywords == "" ) {
i .Flags .Set (1 )
}
}
func (i *InputStickerSetItem ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputStickerSetItem#32da9e9c as nil" )
}
b .PutID (InputStickerSetItemTypeID )
return i .EncodeBare (b )
}
func (i *InputStickerSetItem ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputStickerSetItem#32da9e9c as nil" )
}
i .SetFlags ()
if err := i .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputStickerSetItem#32da9e9c: field flags: %w" , err )
}
if i .Document == nil {
return fmt .Errorf ("unable to encode inputStickerSetItem#32da9e9c: field document is nil" )
}
if err := i .Document .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputStickerSetItem#32da9e9c: field document: %w" , err )
}
b .PutString (i .Emoji )
if i .Flags .Has (0 ) {
if err := i .MaskCoords .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputStickerSetItem#32da9e9c: field mask_coords: %w" , err )
}
}
if i .Flags .Has (1 ) {
b .PutString (i .Keywords )
}
return nil
}
func (i *InputStickerSetItem ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputStickerSetItem#32da9e9c to nil" )
}
if err := b .ConsumeID (InputStickerSetItemTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputStickerSetItem#32da9e9c: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputStickerSetItem ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputStickerSetItem#32da9e9c to nil" )
}
{
if err := i .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode inputStickerSetItem#32da9e9c: field flags: %w" , err )
}
}
{
value , err := DecodeInputDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode inputStickerSetItem#32da9e9c: field document: %w" , err )
}
i .Document = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputStickerSetItem#32da9e9c: field emoji: %w" , err )
}
i .Emoji = value
}
if i .Flags .Has (0 ) {
if err := i .MaskCoords .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode inputStickerSetItem#32da9e9c: field mask_coords: %w" , err )
}
}
if i .Flags .Has (1 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputStickerSetItem#32da9e9c: field keywords: %w" , err )
}
i .Keywords = value
}
return nil
}
func (i *InputStickerSetItem ) GetDocument () (value InputDocumentClass ) {
if i == nil {
return
}
return i .Document
}
func (i *InputStickerSetItem ) GetEmoji () (value string ) {
if i == nil {
return
}
return i .Emoji
}
func (i *InputStickerSetItem ) SetMaskCoords (value MaskCoords ) {
i .Flags .Set (0 )
i .MaskCoords = value
}
func (i *InputStickerSetItem ) GetMaskCoords () (value MaskCoords , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (0 ) {
return value , false
}
return i .MaskCoords , true
}
func (i *InputStickerSetItem ) SetKeywords (value string ) {
i .Flags .Set (1 )
i .Keywords = value
}
func (i *InputStickerSetItem ) GetKeywords () (value string , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (1 ) {
return value , false
}
return i .Keywords , true
}
func (i *InputStickerSetItem ) GetDocumentAsNotEmpty () (*InputDocument , bool ) {
return i .Document .AsNotEmpty ()
}
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 .