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 ReactionCount struct {
Flags bin .Fields
ChosenOrder int
Reaction ReactionClass
Count int
}
const ReactionCountTypeID = 0xa3d1cb80
var (
_ bin .Encoder = &ReactionCount {}
_ bin .Decoder = &ReactionCount {}
_ bin .BareEncoder = &ReactionCount {}
_ bin .BareDecoder = &ReactionCount {}
)
func (r *ReactionCount ) Zero () bool {
if r == nil {
return true
}
if !(r .Flags .Zero ()) {
return false
}
if !(r .ChosenOrder == 0 ) {
return false
}
if !(r .Reaction == nil ) {
return false
}
if !(r .Count == 0 ) {
return false
}
return true
}
func (r *ReactionCount ) String () string {
if r == nil {
return "ReactionCount(nil)"
}
type Alias ReactionCount
return fmt .Sprintf ("ReactionCount%+v" , Alias (*r ))
}
func (r *ReactionCount ) FillFrom (from interface {
GetChosenOrder () (value int , ok bool )
GetReaction () (value ReactionClass )
GetCount () (value int )
}) {
if val , ok := from .GetChosenOrder (); ok {
r .ChosenOrder = val
}
r .Reaction = from .GetReaction ()
r .Count = from .GetCount ()
}
func (*ReactionCount ) TypeID () uint32 {
return ReactionCountTypeID
}
func (*ReactionCount ) TypeName () string {
return "reactionCount"
}
func (r *ReactionCount ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "reactionCount" ,
ID : ReactionCountTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ChosenOrder" ,
SchemaName : "chosen_order" ,
Null : !r .Flags .Has (0 ),
},
{
Name : "Reaction" ,
SchemaName : "reaction" ,
},
{
Name : "Count" ,
SchemaName : "count" ,
},
}
return typ
}
func (r *ReactionCount ) SetFlags () {
if !(r .ChosenOrder == 0 ) {
r .Flags .Set (0 )
}
}
func (r *ReactionCount ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode reactionCount#a3d1cb80 as nil" )
}
b .PutID (ReactionCountTypeID )
return r .EncodeBare (b )
}
func (r *ReactionCount ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode reactionCount#a3d1cb80 as nil" )
}
r .SetFlags ()
if err := r .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode reactionCount#a3d1cb80: field flags: %w" , err )
}
if r .Flags .Has (0 ) {
b .PutInt (r .ChosenOrder )
}
if r .Reaction == nil {
return fmt .Errorf ("unable to encode reactionCount#a3d1cb80: field reaction is nil" )
}
if err := r .Reaction .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode reactionCount#a3d1cb80: field reaction: %w" , err )
}
b .PutInt (r .Count )
return nil
}
func (r *ReactionCount ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode reactionCount#a3d1cb80 to nil" )
}
if err := b .ConsumeID (ReactionCountTypeID ); err != nil {
return fmt .Errorf ("unable to decode reactionCount#a3d1cb80: %w" , err )
}
return r .DecodeBare (b )
}
func (r *ReactionCount ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode reactionCount#a3d1cb80 to nil" )
}
{
if err := r .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode reactionCount#a3d1cb80: field flags: %w" , err )
}
}
if r .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode reactionCount#a3d1cb80: field chosen_order: %w" , err )
}
r .ChosenOrder = value
}
{
value , err := DecodeReaction (b )
if err != nil {
return fmt .Errorf ("unable to decode reactionCount#a3d1cb80: field reaction: %w" , err )
}
r .Reaction = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode reactionCount#a3d1cb80: field count: %w" , err )
}
r .Count = value
}
return nil
}
func (r *ReactionCount ) SetChosenOrder (value int ) {
r .Flags .Set (0 )
r .ChosenOrder = value
}
func (r *ReactionCount ) GetChosenOrder () (value int , ok bool ) {
if r == nil {
return
}
if !r .Flags .Has (0 ) {
return value , false
}
return r .ChosenOrder , true
}
func (r *ReactionCount ) GetReaction () (value ReactionClass ) {
if r == nil {
return
}
return r .Reaction
}
func (r *ReactionCount ) GetCount () (value int ) {
if r == nil {
return
}
return r .Count
}
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 .