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 StickersChangeStickerRequest struct {
Flags bin .Fields
Sticker InputDocumentClass
Emoji string
MaskCoords MaskCoords
Keywords string
}
const StickersChangeStickerRequestTypeID = 0xf5537ebc
var (
_ bin .Encoder = &StickersChangeStickerRequest {}
_ bin .Decoder = &StickersChangeStickerRequest {}
_ bin .BareEncoder = &StickersChangeStickerRequest {}
_ bin .BareDecoder = &StickersChangeStickerRequest {}
)
func (c *StickersChangeStickerRequest ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .Sticker == nil ) {
return false
}
if !(c .Emoji == "" ) {
return false
}
if !(c .MaskCoords .Zero ()) {
return false
}
if !(c .Keywords == "" ) {
return false
}
return true
}
func (c *StickersChangeStickerRequest ) String () string {
if c == nil {
return "StickersChangeStickerRequest(nil)"
}
type Alias StickersChangeStickerRequest
return fmt .Sprintf ("StickersChangeStickerRequest%+v" , Alias (*c ))
}
func (c *StickersChangeStickerRequest ) FillFrom (from interface {
GetSticker () (value InputDocumentClass )
GetEmoji () (value string , ok bool )
GetMaskCoords () (value MaskCoords , ok bool )
GetKeywords () (value string , ok bool )
}) {
c .Sticker = from .GetSticker ()
if val , ok := from .GetEmoji (); ok {
c .Emoji = val
}
if val , ok := from .GetMaskCoords (); ok {
c .MaskCoords = val
}
if val , ok := from .GetKeywords (); ok {
c .Keywords = val
}
}
func (*StickersChangeStickerRequest ) TypeID () uint32 {
return StickersChangeStickerRequestTypeID
}
func (*StickersChangeStickerRequest ) TypeName () string {
return "stickers.changeSticker"
}
func (c *StickersChangeStickerRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "stickers.changeSticker" ,
ID : StickersChangeStickerRequestTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Sticker" ,
SchemaName : "sticker" ,
},
{
Name : "Emoji" ,
SchemaName : "emoji" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "MaskCoords" ,
SchemaName : "mask_coords" ,
Null : !c .Flags .Has (1 ),
},
{
Name : "Keywords" ,
SchemaName : "keywords" ,
Null : !c .Flags .Has (2 ),
},
}
return typ
}
func (c *StickersChangeStickerRequest ) SetFlags () {
if !(c .Emoji == "" ) {
c .Flags .Set (0 )
}
if !(c .MaskCoords .Zero ()) {
c .Flags .Set (1 )
}
if !(c .Keywords == "" ) {
c .Flags .Set (2 )
}
}
func (c *StickersChangeStickerRequest ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode stickers.changeSticker#f5537ebc as nil" )
}
b .PutID (StickersChangeStickerRequestTypeID )
return c .EncodeBare (b )
}
func (c *StickersChangeStickerRequest ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode stickers.changeSticker#f5537ebc as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stickers.changeSticker#f5537ebc: field flags: %w" , err )
}
if c .Sticker == nil {
return fmt .Errorf ("unable to encode stickers.changeSticker#f5537ebc: field sticker is nil" )
}
if err := c .Sticker .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stickers.changeSticker#f5537ebc: field sticker: %w" , err )
}
if c .Flags .Has (0 ) {
b .PutString (c .Emoji )
}
if c .Flags .Has (1 ) {
if err := c .MaskCoords .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stickers.changeSticker#f5537ebc: field mask_coords: %w" , err )
}
}
if c .Flags .Has (2 ) {
b .PutString (c .Keywords )
}
return nil
}
func (c *StickersChangeStickerRequest ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode stickers.changeSticker#f5537ebc to nil" )
}
if err := b .ConsumeID (StickersChangeStickerRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode stickers.changeSticker#f5537ebc: %w" , err )
}
return c .DecodeBare (b )
}
func (c *StickersChangeStickerRequest ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode stickers.changeSticker#f5537ebc to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode stickers.changeSticker#f5537ebc: field flags: %w" , err )
}
}
{
value , err := DecodeInputDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode stickers.changeSticker#f5537ebc: field sticker: %w" , err )
}
c .Sticker = value
}
if c .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode stickers.changeSticker#f5537ebc: field emoji: %w" , err )
}
c .Emoji = value
}
if c .Flags .Has (1 ) {
if err := c .MaskCoords .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode stickers.changeSticker#f5537ebc: field mask_coords: %w" , err )
}
}
if c .Flags .Has (2 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode stickers.changeSticker#f5537ebc: field keywords: %w" , err )
}
c .Keywords = value
}
return nil
}
func (c *StickersChangeStickerRequest ) GetSticker () (value InputDocumentClass ) {
if c == nil {
return
}
return c .Sticker
}
func (c *StickersChangeStickerRequest ) SetEmoji (value string ) {
c .Flags .Set (0 )
c .Emoji = value
}
func (c *StickersChangeStickerRequest ) GetEmoji () (value string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (0 ) {
return value , false
}
return c .Emoji , true
}
func (c *StickersChangeStickerRequest ) SetMaskCoords (value MaskCoords ) {
c .Flags .Set (1 )
c .MaskCoords = value
}
func (c *StickersChangeStickerRequest ) GetMaskCoords () (value MaskCoords , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (1 ) {
return value , false
}
return c .MaskCoords , true
}
func (c *StickersChangeStickerRequest ) SetKeywords (value string ) {
c .Flags .Set (2 )
c .Keywords = value
}
func (c *StickersChangeStickerRequest ) GetKeywords () (value string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (2 ) {
return value , false
}
return c .Keywords , true
}
func (c *StickersChangeStickerRequest ) GetStickerAsNotEmpty () (*InputDocument , bool ) {
return c .Sticker .AsNotEmpty ()
}
func (c *Client ) StickersChangeSticker (ctx context .Context , request *StickersChangeStickerRequest ) (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 .