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 StarGiftAuctionAcquiredGift struct {
Flags bin .Fields
NameHidden bool
Peer PeerClass
Date int
BidAmount int64
Round int
Pos int
Message TextWithEntities
GiftNum int
}
const StarGiftAuctionAcquiredGiftTypeID = 0x42b00348
var (
_ bin .Encoder = &StarGiftAuctionAcquiredGift {}
_ bin .Decoder = &StarGiftAuctionAcquiredGift {}
_ bin .BareEncoder = &StarGiftAuctionAcquiredGift {}
_ bin .BareDecoder = &StarGiftAuctionAcquiredGift {}
)
func (s *StarGiftAuctionAcquiredGift ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .NameHidden == false ) {
return false
}
if !(s .Peer == nil ) {
return false
}
if !(s .Date == 0 ) {
return false
}
if !(s .BidAmount == 0 ) {
return false
}
if !(s .Round == 0 ) {
return false
}
if !(s .Pos == 0 ) {
return false
}
if !(s .Message .Zero ()) {
return false
}
if !(s .GiftNum == 0 ) {
return false
}
return true
}
func (s *StarGiftAuctionAcquiredGift ) String () string {
if s == nil {
return "StarGiftAuctionAcquiredGift(nil)"
}
type Alias StarGiftAuctionAcquiredGift
return fmt .Sprintf ("StarGiftAuctionAcquiredGift%+v" , Alias (*s ))
}
func (s *StarGiftAuctionAcquiredGift ) FillFrom (from interface {
GetNameHidden () (value bool )
GetPeer () (value PeerClass )
GetDate () (value int )
GetBidAmount () (value int64 )
GetRound () (value int )
GetPos () (value int )
GetMessage () (value TextWithEntities , ok bool )
GetGiftNum () (value int , ok bool )
}) {
s .NameHidden = from .GetNameHidden ()
s .Peer = from .GetPeer ()
s .Date = from .GetDate ()
s .BidAmount = from .GetBidAmount ()
s .Round = from .GetRound ()
s .Pos = from .GetPos ()
if val , ok := from .GetMessage (); ok {
s .Message = val
}
if val , ok := from .GetGiftNum (); ok {
s .GiftNum = val
}
}
func (*StarGiftAuctionAcquiredGift ) TypeID () uint32 {
return StarGiftAuctionAcquiredGiftTypeID
}
func (*StarGiftAuctionAcquiredGift ) TypeName () string {
return "starGiftAuctionAcquiredGift"
}
func (s *StarGiftAuctionAcquiredGift ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "starGiftAuctionAcquiredGift" ,
ID : StarGiftAuctionAcquiredGiftTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "NameHidden" ,
SchemaName : "name_hidden" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "BidAmount" ,
SchemaName : "bid_amount" ,
},
{
Name : "Round" ,
SchemaName : "round" ,
},
{
Name : "Pos" ,
SchemaName : "pos" ,
},
{
Name : "Message" ,
SchemaName : "message" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "GiftNum" ,
SchemaName : "gift_num" ,
Null : !s .Flags .Has (2 ),
},
}
return typ
}
func (s *StarGiftAuctionAcquiredGift ) SetFlags () {
if !(s .NameHidden == false ) {
s .Flags .Set (0 )
}
if !(s .Message .Zero ()) {
s .Flags .Set (1 )
}
if !(s .GiftNum == 0 ) {
s .Flags .Set (2 )
}
}
func (s *StarGiftAuctionAcquiredGift ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starGiftAuctionAcquiredGift#42b00348 as nil" )
}
b .PutID (StarGiftAuctionAcquiredGiftTypeID )
return s .EncodeBare (b )
}
func (s *StarGiftAuctionAcquiredGift ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starGiftAuctionAcquiredGift#42b00348 as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode starGiftAuctionAcquiredGift#42b00348: field flags: %w" , err )
}
if s .Peer == nil {
return fmt .Errorf ("unable to encode starGiftAuctionAcquiredGift#42b00348: field peer is nil" )
}
if err := s .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode starGiftAuctionAcquiredGift#42b00348: field peer: %w" , err )
}
b .PutInt (s .Date )
b .PutLong (s .BidAmount )
b .PutInt (s .Round )
b .PutInt (s .Pos )
if s .Flags .Has (1 ) {
if err := s .Message .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode starGiftAuctionAcquiredGift#42b00348: field message: %w" , err )
}
}
if s .Flags .Has (2 ) {
b .PutInt (s .GiftNum )
}
return nil
}
func (s *StarGiftAuctionAcquiredGift ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starGiftAuctionAcquiredGift#42b00348 to nil" )
}
if err := b .ConsumeID (StarGiftAuctionAcquiredGiftTypeID ); err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionAcquiredGift#42b00348: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StarGiftAuctionAcquiredGift ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starGiftAuctionAcquiredGift#42b00348 to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionAcquiredGift#42b00348: field flags: %w" , err )
}
}
s .NameHidden = s .Flags .Has (0 )
{
value , err := DecodePeer (b )
if err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionAcquiredGift#42b00348: field peer: %w" , err )
}
s .Peer = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionAcquiredGift#42b00348: field date: %w" , err )
}
s .Date = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionAcquiredGift#42b00348: field bid_amount: %w" , err )
}
s .BidAmount = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionAcquiredGift#42b00348: field round: %w" , err )
}
s .Round = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionAcquiredGift#42b00348: field pos: %w" , err )
}
s .Pos = value
}
if s .Flags .Has (1 ) {
if err := s .Message .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionAcquiredGift#42b00348: field message: %w" , err )
}
}
if s .Flags .Has (2 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionAcquiredGift#42b00348: field gift_num: %w" , err )
}
s .GiftNum = value
}
return nil
}
func (s *StarGiftAuctionAcquiredGift ) SetNameHidden (value bool ) {
if value {
s .Flags .Set (0 )
s .NameHidden = true
} else {
s .Flags .Unset (0 )
s .NameHidden = false
}
}
func (s *StarGiftAuctionAcquiredGift ) GetNameHidden () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (0 )
}
func (s *StarGiftAuctionAcquiredGift ) GetPeer () (value PeerClass ) {
if s == nil {
return
}
return s .Peer
}
func (s *StarGiftAuctionAcquiredGift ) GetDate () (value int ) {
if s == nil {
return
}
return s .Date
}
func (s *StarGiftAuctionAcquiredGift ) GetBidAmount () (value int64 ) {
if s == nil {
return
}
return s .BidAmount
}
func (s *StarGiftAuctionAcquiredGift ) GetRound () (value int ) {
if s == nil {
return
}
return s .Round
}
func (s *StarGiftAuctionAcquiredGift ) GetPos () (value int ) {
if s == nil {
return
}
return s .Pos
}
func (s *StarGiftAuctionAcquiredGift ) SetMessage (value TextWithEntities ) {
s .Flags .Set (1 )
s .Message = value
}
func (s *StarGiftAuctionAcquiredGift ) GetMessage () (value TextWithEntities , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (1 ) {
return value , false
}
return s .Message , true
}
func (s *StarGiftAuctionAcquiredGift ) SetGiftNum (value int ) {
s .Flags .Set (2 )
s .GiftNum = value
}
func (s *StarGiftAuctionAcquiredGift ) GetGiftNum () (value int , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (2 ) {
return value , false
}
return s .GiftNum , 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 .