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 AvailableEffect struct {
Flags bin .Fields
PremiumRequired bool
ID int64
Emoticon string
StaticIconID int64
EffectStickerID int64
EffectAnimationID int64
}
const AvailableEffectTypeID = 0x93c3e27e
var (
_ bin .Encoder = &AvailableEffect {}
_ bin .Decoder = &AvailableEffect {}
_ bin .BareEncoder = &AvailableEffect {}
_ bin .BareDecoder = &AvailableEffect {}
)
func (a *AvailableEffect ) Zero () bool {
if a == nil {
return true
}
if !(a .Flags .Zero ()) {
return false
}
if !(a .PremiumRequired == false ) {
return false
}
if !(a .ID == 0 ) {
return false
}
if !(a .Emoticon == "" ) {
return false
}
if !(a .StaticIconID == 0 ) {
return false
}
if !(a .EffectStickerID == 0 ) {
return false
}
if !(a .EffectAnimationID == 0 ) {
return false
}
return true
}
func (a *AvailableEffect ) String () string {
if a == nil {
return "AvailableEffect(nil)"
}
type Alias AvailableEffect
return fmt .Sprintf ("AvailableEffect%+v" , Alias (*a ))
}
func (a *AvailableEffect ) FillFrom (from interface {
GetPremiumRequired () (value bool )
GetID () (value int64 )
GetEmoticon () (value string )
GetStaticIconID () (value int64 , ok bool )
GetEffectStickerID () (value int64 )
GetEffectAnimationID () (value int64 , ok bool )
}) {
a .PremiumRequired = from .GetPremiumRequired ()
a .ID = from .GetID ()
a .Emoticon = from .GetEmoticon ()
if val , ok := from .GetStaticIconID (); ok {
a .StaticIconID = val
}
a .EffectStickerID = from .GetEffectStickerID ()
if val , ok := from .GetEffectAnimationID (); ok {
a .EffectAnimationID = val
}
}
func (*AvailableEffect ) TypeID () uint32 {
return AvailableEffectTypeID
}
func (*AvailableEffect ) TypeName () string {
return "availableEffect"
}
func (a *AvailableEffect ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "availableEffect" ,
ID : AvailableEffectTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "PremiumRequired" ,
SchemaName : "premium_required" ,
Null : !a .Flags .Has (2 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Emoticon" ,
SchemaName : "emoticon" ,
},
{
Name : "StaticIconID" ,
SchemaName : "static_icon_id" ,
Null : !a .Flags .Has (0 ),
},
{
Name : "EffectStickerID" ,
SchemaName : "effect_sticker_id" ,
},
{
Name : "EffectAnimationID" ,
SchemaName : "effect_animation_id" ,
Null : !a .Flags .Has (1 ),
},
}
return typ
}
func (a *AvailableEffect ) SetFlags () {
if !(a .PremiumRequired == false ) {
a .Flags .Set (2 )
}
if !(a .StaticIconID == 0 ) {
a .Flags .Set (0 )
}
if !(a .EffectAnimationID == 0 ) {
a .Flags .Set (1 )
}
}
func (a *AvailableEffect ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode availableEffect#93c3e27e as nil" )
}
b .PutID (AvailableEffectTypeID )
return a .EncodeBare (b )
}
func (a *AvailableEffect ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode availableEffect#93c3e27e as nil" )
}
a .SetFlags ()
if err := a .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode availableEffect#93c3e27e: field flags: %w" , err )
}
b .PutLong (a .ID )
b .PutString (a .Emoticon )
if a .Flags .Has (0 ) {
b .PutLong (a .StaticIconID )
}
b .PutLong (a .EffectStickerID )
if a .Flags .Has (1 ) {
b .PutLong (a .EffectAnimationID )
}
return nil
}
func (a *AvailableEffect ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode availableEffect#93c3e27e to nil" )
}
if err := b .ConsumeID (AvailableEffectTypeID ); err != nil {
return fmt .Errorf ("unable to decode availableEffect#93c3e27e: %w" , err )
}
return a .DecodeBare (b )
}
func (a *AvailableEffect ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode availableEffect#93c3e27e to nil" )
}
{
if err := a .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode availableEffect#93c3e27e: field flags: %w" , err )
}
}
a .PremiumRequired = a .Flags .Has (2 )
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode availableEffect#93c3e27e: field id: %w" , err )
}
a .ID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode availableEffect#93c3e27e: field emoticon: %w" , err )
}
a .Emoticon = value
}
if a .Flags .Has (0 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode availableEffect#93c3e27e: field static_icon_id: %w" , err )
}
a .StaticIconID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode availableEffect#93c3e27e: field effect_sticker_id: %w" , err )
}
a .EffectStickerID = value
}
if a .Flags .Has (1 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode availableEffect#93c3e27e: field effect_animation_id: %w" , err )
}
a .EffectAnimationID = value
}
return nil
}
func (a *AvailableEffect ) SetPremiumRequired (value bool ) {
if value {
a .Flags .Set (2 )
a .PremiumRequired = true
} else {
a .Flags .Unset (2 )
a .PremiumRequired = false
}
}
func (a *AvailableEffect ) GetPremiumRequired () (value bool ) {
if a == nil {
return
}
return a .Flags .Has (2 )
}
func (a *AvailableEffect ) GetID () (value int64 ) {
if a == nil {
return
}
return a .ID
}
func (a *AvailableEffect ) GetEmoticon () (value string ) {
if a == nil {
return
}
return a .Emoticon
}
func (a *AvailableEffect ) SetStaticIconID (value int64 ) {
a .Flags .Set (0 )
a .StaticIconID = value
}
func (a *AvailableEffect ) GetStaticIconID () (value int64 , ok bool ) {
if a == nil {
return
}
if !a .Flags .Has (0 ) {
return value , false
}
return a .StaticIconID , true
}
func (a *AvailableEffect ) GetEffectStickerID () (value int64 ) {
if a == nil {
return
}
return a .EffectStickerID
}
func (a *AvailableEffect ) SetEffectAnimationID (value int64 ) {
a .Flags .Set (1 )
a .EffectAnimationID = value
}
func (a *AvailableEffect ) GetEffectAnimationID () (value int64 , ok bool ) {
if a == nil {
return
}
if !a .Flags .Has (1 ) {
return value , false
}
return a .EffectAnimationID , true
}
The pages are generated with Golds v0.8.4 . (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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .