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 StarsRating struct {
Flags bin .Fields
Level int
CurrentLevelStars int64
Stars int64
NextLevelStars int64
}
const StarsRatingTypeID = 0x1b0e4f07
var (
_ bin .Encoder = &StarsRating {}
_ bin .Decoder = &StarsRating {}
_ bin .BareEncoder = &StarsRating {}
_ bin .BareDecoder = &StarsRating {}
)
func (s *StarsRating ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Level == 0 ) {
return false
}
if !(s .CurrentLevelStars == 0 ) {
return false
}
if !(s .Stars == 0 ) {
return false
}
if !(s .NextLevelStars == 0 ) {
return false
}
return true
}
func (s *StarsRating ) String () string {
if s == nil {
return "StarsRating(nil)"
}
type Alias StarsRating
return fmt .Sprintf ("StarsRating%+v" , Alias (*s ))
}
func (s *StarsRating ) FillFrom (from interface {
GetLevel () (value int )
GetCurrentLevelStars () (value int64 )
GetStars () (value int64 )
GetNextLevelStars () (value int64 , ok bool )
}) {
s .Level = from .GetLevel ()
s .CurrentLevelStars = from .GetCurrentLevelStars ()
s .Stars = from .GetStars ()
if val , ok := from .GetNextLevelStars (); ok {
s .NextLevelStars = val
}
}
func (*StarsRating ) TypeID () uint32 {
return StarsRatingTypeID
}
func (*StarsRating ) TypeName () string {
return "starsRating"
}
func (s *StarsRating ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "starsRating" ,
ID : StarsRatingTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Level" ,
SchemaName : "level" ,
},
{
Name : "CurrentLevelStars" ,
SchemaName : "current_level_stars" ,
},
{
Name : "Stars" ,
SchemaName : "stars" ,
},
{
Name : "NextLevelStars" ,
SchemaName : "next_level_stars" ,
Null : !s .Flags .Has (0 ),
},
}
return typ
}
func (s *StarsRating ) SetFlags () {
if !(s .NextLevelStars == 0 ) {
s .Flags .Set (0 )
}
}
func (s *StarsRating ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starsRating#1b0e4f07 as nil" )
}
b .PutID (StarsRatingTypeID )
return s .EncodeBare (b )
}
func (s *StarsRating ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starsRating#1b0e4f07 as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode starsRating#1b0e4f07: field flags: %w" , err )
}
b .PutInt (s .Level )
b .PutLong (s .CurrentLevelStars )
b .PutLong (s .Stars )
if s .Flags .Has (0 ) {
b .PutLong (s .NextLevelStars )
}
return nil
}
func (s *StarsRating ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starsRating#1b0e4f07 to nil" )
}
if err := b .ConsumeID (StarsRatingTypeID ); err != nil {
return fmt .Errorf ("unable to decode starsRating#1b0e4f07: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StarsRating ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starsRating#1b0e4f07 to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode starsRating#1b0e4f07: field flags: %w" , err )
}
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starsRating#1b0e4f07: field level: %w" , err )
}
s .Level = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode starsRating#1b0e4f07: field current_level_stars: %w" , err )
}
s .CurrentLevelStars = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode starsRating#1b0e4f07: field stars: %w" , err )
}
s .Stars = value
}
if s .Flags .Has (0 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode starsRating#1b0e4f07: field next_level_stars: %w" , err )
}
s .NextLevelStars = value
}
return nil
}
func (s *StarsRating ) GetLevel () (value int ) {
if s == nil {
return
}
return s .Level
}
func (s *StarsRating ) GetCurrentLevelStars () (value int64 ) {
if s == nil {
return
}
return s .CurrentLevelStars
}
func (s *StarsRating ) GetStars () (value int64 ) {
if s == nil {
return
}
return s .Stars
}
func (s *StarsRating ) SetNextLevelStars (value int64 ) {
s .Flags .Set (0 )
s .NextLevelStars = value
}
func (s *StarsRating ) GetNextLevelStars () (value int64 , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .NextLevelStars , 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 .