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 AvailableReaction struct {
Flags bin .Fields
Inactive bool
Premium bool
Reaction string
Title string
StaticIcon DocumentClass
AppearAnimation DocumentClass
SelectAnimation DocumentClass
ActivateAnimation DocumentClass
EffectAnimation DocumentClass
AroundAnimation DocumentClass
CenterIcon DocumentClass
}
const AvailableReactionTypeID = 0xc077ec01
var (
_ bin .Encoder = &AvailableReaction {}
_ bin .Decoder = &AvailableReaction {}
_ bin .BareEncoder = &AvailableReaction {}
_ bin .BareDecoder = &AvailableReaction {}
)
func (a *AvailableReaction ) Zero () bool {
if a == nil {
return true
}
if !(a .Flags .Zero ()) {
return false
}
if !(a .Inactive == false ) {
return false
}
if !(a .Premium == false ) {
return false
}
if !(a .Reaction == "" ) {
return false
}
if !(a .Title == "" ) {
return false
}
if !(a .StaticIcon == nil ) {
return false
}
if !(a .AppearAnimation == nil ) {
return false
}
if !(a .SelectAnimation == nil ) {
return false
}
if !(a .ActivateAnimation == nil ) {
return false
}
if !(a .EffectAnimation == nil ) {
return false
}
if !(a .AroundAnimation == nil ) {
return false
}
if !(a .CenterIcon == nil ) {
return false
}
return true
}
func (a *AvailableReaction ) String () string {
if a == nil {
return "AvailableReaction(nil)"
}
type Alias AvailableReaction
return fmt .Sprintf ("AvailableReaction%+v" , Alias (*a ))
}
func (a *AvailableReaction ) FillFrom (from interface {
GetInactive () (value bool )
GetPremium () (value bool )
GetReaction () (value string )
GetTitle () (value string )
GetStaticIcon () (value DocumentClass )
GetAppearAnimation () (value DocumentClass )
GetSelectAnimation () (value DocumentClass )
GetActivateAnimation () (value DocumentClass )
GetEffectAnimation () (value DocumentClass )
GetAroundAnimation () (value DocumentClass , ok bool )
GetCenterIcon () (value DocumentClass , ok bool )
}) {
a .Inactive = from .GetInactive ()
a .Premium = from .GetPremium ()
a .Reaction = from .GetReaction ()
a .Title = from .GetTitle ()
a .StaticIcon = from .GetStaticIcon ()
a .AppearAnimation = from .GetAppearAnimation ()
a .SelectAnimation = from .GetSelectAnimation ()
a .ActivateAnimation = from .GetActivateAnimation ()
a .EffectAnimation = from .GetEffectAnimation ()
if val , ok := from .GetAroundAnimation (); ok {
a .AroundAnimation = val
}
if val , ok := from .GetCenterIcon (); ok {
a .CenterIcon = val
}
}
func (*AvailableReaction ) TypeID () uint32 {
return AvailableReactionTypeID
}
func (*AvailableReaction ) TypeName () string {
return "availableReaction"
}
func (a *AvailableReaction ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "availableReaction" ,
ID : AvailableReactionTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Inactive" ,
SchemaName : "inactive" ,
Null : !a .Flags .Has (0 ),
},
{
Name : "Premium" ,
SchemaName : "premium" ,
Null : !a .Flags .Has (2 ),
},
{
Name : "Reaction" ,
SchemaName : "reaction" ,
},
{
Name : "Title" ,
SchemaName : "title" ,
},
{
Name : "StaticIcon" ,
SchemaName : "static_icon" ,
},
{
Name : "AppearAnimation" ,
SchemaName : "appear_animation" ,
},
{
Name : "SelectAnimation" ,
SchemaName : "select_animation" ,
},
{
Name : "ActivateAnimation" ,
SchemaName : "activate_animation" ,
},
{
Name : "EffectAnimation" ,
SchemaName : "effect_animation" ,
},
{
Name : "AroundAnimation" ,
SchemaName : "around_animation" ,
Null : !a .Flags .Has (1 ),
},
{
Name : "CenterIcon" ,
SchemaName : "center_icon" ,
Null : !a .Flags .Has (1 ),
},
}
return typ
}
func (a *AvailableReaction ) SetFlags () {
if !(a .Inactive == false ) {
a .Flags .Set (0 )
}
if !(a .Premium == false ) {
a .Flags .Set (2 )
}
if !(a .AroundAnimation == nil ) {
a .Flags .Set (1 )
}
if !(a .CenterIcon == nil ) {
a .Flags .Set (1 )
}
}
func (a *AvailableReaction ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode availableReaction#c077ec01 as nil" )
}
b .PutID (AvailableReactionTypeID )
return a .EncodeBare (b )
}
func (a *AvailableReaction ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode availableReaction#c077ec01 as nil" )
}
a .SetFlags ()
if err := a .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode availableReaction#c077ec01: field flags: %w" , err )
}
b .PutString (a .Reaction )
b .PutString (a .Title )
if a .StaticIcon == nil {
return fmt .Errorf ("unable to encode availableReaction#c077ec01: field static_icon is nil" )
}
if err := a .StaticIcon .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode availableReaction#c077ec01: field static_icon: %w" , err )
}
if a .AppearAnimation == nil {
return fmt .Errorf ("unable to encode availableReaction#c077ec01: field appear_animation is nil" )
}
if err := a .AppearAnimation .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode availableReaction#c077ec01: field appear_animation: %w" , err )
}
if a .SelectAnimation == nil {
return fmt .Errorf ("unable to encode availableReaction#c077ec01: field select_animation is nil" )
}
if err := a .SelectAnimation .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode availableReaction#c077ec01: field select_animation: %w" , err )
}
if a .ActivateAnimation == nil {
return fmt .Errorf ("unable to encode availableReaction#c077ec01: field activate_animation is nil" )
}
if err := a .ActivateAnimation .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode availableReaction#c077ec01: field activate_animation: %w" , err )
}
if a .EffectAnimation == nil {
return fmt .Errorf ("unable to encode availableReaction#c077ec01: field effect_animation is nil" )
}
if err := a .EffectAnimation .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode availableReaction#c077ec01: field effect_animation: %w" , err )
}
if a .Flags .Has (1 ) {
if a .AroundAnimation == nil {
return fmt .Errorf ("unable to encode availableReaction#c077ec01: field around_animation is nil" )
}
if err := a .AroundAnimation .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode availableReaction#c077ec01: field around_animation: %w" , err )
}
}
if a .Flags .Has (1 ) {
if a .CenterIcon == nil {
return fmt .Errorf ("unable to encode availableReaction#c077ec01: field center_icon is nil" )
}
if err := a .CenterIcon .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode availableReaction#c077ec01: field center_icon: %w" , err )
}
}
return nil
}
func (a *AvailableReaction ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode availableReaction#c077ec01 to nil" )
}
if err := b .ConsumeID (AvailableReactionTypeID ); err != nil {
return fmt .Errorf ("unable to decode availableReaction#c077ec01: %w" , err )
}
return a .DecodeBare (b )
}
func (a *AvailableReaction ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode availableReaction#c077ec01 to nil" )
}
{
if err := a .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode availableReaction#c077ec01: field flags: %w" , err )
}
}
a .Inactive = a .Flags .Has (0 )
a .Premium = a .Flags .Has (2 )
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode availableReaction#c077ec01: field reaction: %w" , err )
}
a .Reaction = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode availableReaction#c077ec01: field title: %w" , err )
}
a .Title = value
}
{
value , err := DecodeDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode availableReaction#c077ec01: field static_icon: %w" , err )
}
a .StaticIcon = value
}
{
value , err := DecodeDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode availableReaction#c077ec01: field appear_animation: %w" , err )
}
a .AppearAnimation = value
}
{
value , err := DecodeDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode availableReaction#c077ec01: field select_animation: %w" , err )
}
a .SelectAnimation = value
}
{
value , err := DecodeDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode availableReaction#c077ec01: field activate_animation: %w" , err )
}
a .ActivateAnimation = value
}
{
value , err := DecodeDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode availableReaction#c077ec01: field effect_animation: %w" , err )
}
a .EffectAnimation = value
}
if a .Flags .Has (1 ) {
value , err := DecodeDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode availableReaction#c077ec01: field around_animation: %w" , err )
}
a .AroundAnimation = value
}
if a .Flags .Has (1 ) {
value , err := DecodeDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode availableReaction#c077ec01: field center_icon: %w" , err )
}
a .CenterIcon = value
}
return nil
}
func (a *AvailableReaction ) SetInactive (value bool ) {
if value {
a .Flags .Set (0 )
a .Inactive = true
} else {
a .Flags .Unset (0 )
a .Inactive = false
}
}
func (a *AvailableReaction ) GetInactive () (value bool ) {
if a == nil {
return
}
return a .Flags .Has (0 )
}
func (a *AvailableReaction ) SetPremium (value bool ) {
if value {
a .Flags .Set (2 )
a .Premium = true
} else {
a .Flags .Unset (2 )
a .Premium = false
}
}
func (a *AvailableReaction ) GetPremium () (value bool ) {
if a == nil {
return
}
return a .Flags .Has (2 )
}
func (a *AvailableReaction ) GetReaction () (value string ) {
if a == nil {
return
}
return a .Reaction
}
func (a *AvailableReaction ) GetTitle () (value string ) {
if a == nil {
return
}
return a .Title
}
func (a *AvailableReaction ) GetStaticIcon () (value DocumentClass ) {
if a == nil {
return
}
return a .StaticIcon
}
func (a *AvailableReaction ) GetAppearAnimation () (value DocumentClass ) {
if a == nil {
return
}
return a .AppearAnimation
}
func (a *AvailableReaction ) GetSelectAnimation () (value DocumentClass ) {
if a == nil {
return
}
return a .SelectAnimation
}
func (a *AvailableReaction ) GetActivateAnimation () (value DocumentClass ) {
if a == nil {
return
}
return a .ActivateAnimation
}
func (a *AvailableReaction ) GetEffectAnimation () (value DocumentClass ) {
if a == nil {
return
}
return a .EffectAnimation
}
func (a *AvailableReaction ) SetAroundAnimation (value DocumentClass ) {
a .Flags .Set (1 )
a .AroundAnimation = value
}
func (a *AvailableReaction ) GetAroundAnimation () (value DocumentClass , ok bool ) {
if a == nil {
return
}
if !a .Flags .Has (1 ) {
return value , false
}
return a .AroundAnimation , true
}
func (a *AvailableReaction ) SetCenterIcon (value DocumentClass ) {
a .Flags .Set (1 )
a .CenterIcon = value
}
func (a *AvailableReaction ) GetCenterIcon () (value DocumentClass , ok bool ) {
if a == nil {
return
}
if !a .Flags .Has (1 ) {
return value , false
}
return a .CenterIcon , true
}
func (a *AvailableReaction ) GetStaticIconAsNotEmpty () (*Document , bool ) {
return a .StaticIcon .AsNotEmpty ()
}
func (a *AvailableReaction ) GetAppearAnimationAsNotEmpty () (*Document , bool ) {
return a .AppearAnimation .AsNotEmpty ()
}
func (a *AvailableReaction ) GetSelectAnimationAsNotEmpty () (*Document , bool ) {
return a .SelectAnimation .AsNotEmpty ()
}
func (a *AvailableReaction ) GetActivateAnimationAsNotEmpty () (*Document , bool ) {
return a .ActivateAnimation .AsNotEmpty ()
}
func (a *AvailableReaction ) GetEffectAnimationAsNotEmpty () (*Document , bool ) {
return a .EffectAnimation .AsNotEmpty ()
}
func (a *AvailableReaction ) GetAroundAnimationAsNotEmpty () (*Document , bool ) {
if value , ok := a .GetAroundAnimation (); ok {
return value .AsNotEmpty ()
}
return nil , false
}
func (a *AvailableReaction ) GetCenterIconAsNotEmpty () (*Document , bool ) {
if value , ok := a .GetCenterIcon (); ok {
return value .AsNotEmpty ()
}
return nil , false
}
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 .