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 PeerColor struct {
Flags bin .Fields
Color int
BackgroundEmojiID int64
}
const PeerColorTypeID = 0xb54b5acf
func (p PeerColor ) construct () PeerColorClass { return &p }
var (
_ bin .Encoder = &PeerColor {}
_ bin .Decoder = &PeerColor {}
_ bin .BareEncoder = &PeerColor {}
_ bin .BareDecoder = &PeerColor {}
_ PeerColorClass = &PeerColor {}
)
func (p *PeerColor ) Zero () bool {
if p == nil {
return true
}
if !(p .Flags .Zero ()) {
return false
}
if !(p .Color == 0 ) {
return false
}
if !(p .BackgroundEmojiID == 0 ) {
return false
}
return true
}
func (p *PeerColor ) String () string {
if p == nil {
return "PeerColor(nil)"
}
type Alias PeerColor
return fmt .Sprintf ("PeerColor%+v" , Alias (*p ))
}
func (p *PeerColor ) FillFrom (from interface {
GetColor () (value int , ok bool )
GetBackgroundEmojiID () (value int64 , ok bool )
}) {
if val , ok := from .GetColor (); ok {
p .Color = val
}
if val , ok := from .GetBackgroundEmojiID (); ok {
p .BackgroundEmojiID = val
}
}
func (*PeerColor ) TypeID () uint32 {
return PeerColorTypeID
}
func (*PeerColor ) TypeName () string {
return "peerColor"
}
func (p *PeerColor ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "peerColor" ,
ID : PeerColorTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Color" ,
SchemaName : "color" ,
Null : !p .Flags .Has (0 ),
},
{
Name : "BackgroundEmojiID" ,
SchemaName : "background_emoji_id" ,
Null : !p .Flags .Has (1 ),
},
}
return typ
}
func (p *PeerColor ) SetFlags () {
if !(p .Color == 0 ) {
p .Flags .Set (0 )
}
if !(p .BackgroundEmojiID == 0 ) {
p .Flags .Set (1 )
}
}
func (p *PeerColor ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode peerColor#b54b5acf as nil" )
}
b .PutID (PeerColorTypeID )
return p .EncodeBare (b )
}
func (p *PeerColor ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode peerColor#b54b5acf as nil" )
}
p .SetFlags ()
if err := p .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode peerColor#b54b5acf: field flags: %w" , err )
}
if p .Flags .Has (0 ) {
b .PutInt (p .Color )
}
if p .Flags .Has (1 ) {
b .PutLong (p .BackgroundEmojiID )
}
return nil
}
func (p *PeerColor ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode peerColor#b54b5acf to nil" )
}
if err := b .ConsumeID (PeerColorTypeID ); err != nil {
return fmt .Errorf ("unable to decode peerColor#b54b5acf: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PeerColor ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode peerColor#b54b5acf to nil" )
}
{
if err := p .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode peerColor#b54b5acf: field flags: %w" , err )
}
}
if p .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode peerColor#b54b5acf: field color: %w" , err )
}
p .Color = value
}
if p .Flags .Has (1 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode peerColor#b54b5acf: field background_emoji_id: %w" , err )
}
p .BackgroundEmojiID = value
}
return nil
}
func (p *PeerColor ) SetColor (value int ) {
p .Flags .Set (0 )
p .Color = value
}
func (p *PeerColor ) GetColor () (value int , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (0 ) {
return value , false
}
return p .Color , true
}
func (p *PeerColor ) SetBackgroundEmojiID (value int64 ) {
p .Flags .Set (1 )
p .BackgroundEmojiID = value
}
func (p *PeerColor ) GetBackgroundEmojiID () (value int64 , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (1 ) {
return value , false
}
return p .BackgroundEmojiID , true
}
type PeerColorCollectible struct {
Flags bin .Fields
CollectibleID int64
GiftEmojiID int64
BackgroundEmojiID int64
AccentColor int
Colors []int
DarkAccentColor int
DarkColors []int
}
const PeerColorCollectibleTypeID = 0xb9c0639a
func (p PeerColorCollectible ) construct () PeerColorClass { return &p }
var (
_ bin .Encoder = &PeerColorCollectible {}
_ bin .Decoder = &PeerColorCollectible {}
_ bin .BareEncoder = &PeerColorCollectible {}
_ bin .BareDecoder = &PeerColorCollectible {}
_ PeerColorClass = &PeerColorCollectible {}
)
func (p *PeerColorCollectible ) Zero () bool {
if p == nil {
return true
}
if !(p .Flags .Zero ()) {
return false
}
if !(p .CollectibleID == 0 ) {
return false
}
if !(p .GiftEmojiID == 0 ) {
return false
}
if !(p .BackgroundEmojiID == 0 ) {
return false
}
if !(p .AccentColor == 0 ) {
return false
}
if !(p .Colors == nil ) {
return false
}
if !(p .DarkAccentColor == 0 ) {
return false
}
if !(p .DarkColors == nil ) {
return false
}
return true
}
func (p *PeerColorCollectible ) String () string {
if p == nil {
return "PeerColorCollectible(nil)"
}
type Alias PeerColorCollectible
return fmt .Sprintf ("PeerColorCollectible%+v" , Alias (*p ))
}
func (p *PeerColorCollectible ) FillFrom (from interface {
GetCollectibleID () (value int64 )
GetGiftEmojiID () (value int64 )
GetBackgroundEmojiID () (value int64 )
GetAccentColor () (value int )
GetColors () (value []int )
GetDarkAccentColor () (value int , ok bool )
GetDarkColors () (value []int , ok bool )
}) {
p .CollectibleID = from .GetCollectibleID ()
p .GiftEmojiID = from .GetGiftEmojiID ()
p .BackgroundEmojiID = from .GetBackgroundEmojiID ()
p .AccentColor = from .GetAccentColor ()
p .Colors = from .GetColors ()
if val , ok := from .GetDarkAccentColor (); ok {
p .DarkAccentColor = val
}
if val , ok := from .GetDarkColors (); ok {
p .DarkColors = val
}
}
func (*PeerColorCollectible ) TypeID () uint32 {
return PeerColorCollectibleTypeID
}
func (*PeerColorCollectible ) TypeName () string {
return "peerColorCollectible"
}
func (p *PeerColorCollectible ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "peerColorCollectible" ,
ID : PeerColorCollectibleTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "CollectibleID" ,
SchemaName : "collectible_id" ,
},
{
Name : "GiftEmojiID" ,
SchemaName : "gift_emoji_id" ,
},
{
Name : "BackgroundEmojiID" ,
SchemaName : "background_emoji_id" ,
},
{
Name : "AccentColor" ,
SchemaName : "accent_color" ,
},
{
Name : "Colors" ,
SchemaName : "colors" ,
},
{
Name : "DarkAccentColor" ,
SchemaName : "dark_accent_color" ,
Null : !p .Flags .Has (0 ),
},
{
Name : "DarkColors" ,
SchemaName : "dark_colors" ,
Null : !p .Flags .Has (1 ),
},
}
return typ
}
func (p *PeerColorCollectible ) SetFlags () {
if !(p .DarkAccentColor == 0 ) {
p .Flags .Set (0 )
}
if !(p .DarkColors == nil ) {
p .Flags .Set (1 )
}
}
func (p *PeerColorCollectible ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode peerColorCollectible#b9c0639a as nil" )
}
b .PutID (PeerColorCollectibleTypeID )
return p .EncodeBare (b )
}
func (p *PeerColorCollectible ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode peerColorCollectible#b9c0639a as nil" )
}
p .SetFlags ()
if err := p .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode peerColorCollectible#b9c0639a: field flags: %w" , err )
}
b .PutLong (p .CollectibleID )
b .PutLong (p .GiftEmojiID )
b .PutLong (p .BackgroundEmojiID )
b .PutInt (p .AccentColor )
b .PutVectorHeader (len (p .Colors ))
for _ , v := range p .Colors {
b .PutInt (v )
}
if p .Flags .Has (0 ) {
b .PutInt (p .DarkAccentColor )
}
if p .Flags .Has (1 ) {
b .PutVectorHeader (len (p .DarkColors ))
for _ , v := range p .DarkColors {
b .PutInt (v )
}
}
return nil
}
func (p *PeerColorCollectible ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode peerColorCollectible#b9c0639a to nil" )
}
if err := b .ConsumeID (PeerColorCollectibleTypeID ); err != nil {
return fmt .Errorf ("unable to decode peerColorCollectible#b9c0639a: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PeerColorCollectible ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode peerColorCollectible#b9c0639a to nil" )
}
{
if err := p .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode peerColorCollectible#b9c0639a: field flags: %w" , err )
}
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode peerColorCollectible#b9c0639a: field collectible_id: %w" , err )
}
p .CollectibleID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode peerColorCollectible#b9c0639a: field gift_emoji_id: %w" , err )
}
p .GiftEmojiID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode peerColorCollectible#b9c0639a: field background_emoji_id: %w" , err )
}
p .BackgroundEmojiID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode peerColorCollectible#b9c0639a: field accent_color: %w" , err )
}
p .AccentColor = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode peerColorCollectible#b9c0639a: field colors: %w" , err )
}
if headerLen > 0 {
p .Colors = make ([]int , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode peerColorCollectible#b9c0639a: field colors: %w" , err )
}
p .Colors = append (p .Colors , value )
}
}
if p .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode peerColorCollectible#b9c0639a: field dark_accent_color: %w" , err )
}
p .DarkAccentColor = value
}
if p .Flags .Has (1 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode peerColorCollectible#b9c0639a: field dark_colors: %w" , err )
}
if headerLen > 0 {
p .DarkColors = make ([]int , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode peerColorCollectible#b9c0639a: field dark_colors: %w" , err )
}
p .DarkColors = append (p .DarkColors , value )
}
}
return nil
}
func (p *PeerColorCollectible ) GetCollectibleID () (value int64 ) {
if p == nil {
return
}
return p .CollectibleID
}
func (p *PeerColorCollectible ) GetGiftEmojiID () (value int64 ) {
if p == nil {
return
}
return p .GiftEmojiID
}
func (p *PeerColorCollectible ) GetBackgroundEmojiID () (value int64 ) {
if p == nil {
return
}
return p .BackgroundEmojiID
}
func (p *PeerColorCollectible ) GetAccentColor () (value int ) {
if p == nil {
return
}
return p .AccentColor
}
func (p *PeerColorCollectible ) GetColors () (value []int ) {
if p == nil {
return
}
return p .Colors
}
func (p *PeerColorCollectible ) SetDarkAccentColor (value int ) {
p .Flags .Set (0 )
p .DarkAccentColor = value
}
func (p *PeerColorCollectible ) GetDarkAccentColor () (value int , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (0 ) {
return value , false
}
return p .DarkAccentColor , true
}
func (p *PeerColorCollectible ) SetDarkColors (value []int ) {
p .Flags .Set (1 )
p .DarkColors = value
}
func (p *PeerColorCollectible ) GetDarkColors () (value []int , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (1 ) {
return value , false
}
return p .DarkColors , true
}
type InputPeerColorCollectible struct {
CollectibleID int64
}
const InputPeerColorCollectibleTypeID = 0xb8ea86a9
func (i InputPeerColorCollectible ) construct () PeerColorClass { return &i }
var (
_ bin .Encoder = &InputPeerColorCollectible {}
_ bin .Decoder = &InputPeerColorCollectible {}
_ bin .BareEncoder = &InputPeerColorCollectible {}
_ bin .BareDecoder = &InputPeerColorCollectible {}
_ PeerColorClass = &InputPeerColorCollectible {}
)
func (i *InputPeerColorCollectible ) Zero () bool {
if i == nil {
return true
}
if !(i .CollectibleID == 0 ) {
return false
}
return true
}
func (i *InputPeerColorCollectible ) String () string {
if i == nil {
return "InputPeerColorCollectible(nil)"
}
type Alias InputPeerColorCollectible
return fmt .Sprintf ("InputPeerColorCollectible%+v" , Alias (*i ))
}
func (i *InputPeerColorCollectible ) FillFrom (from interface {
GetCollectibleID () (value int64 )
}) {
i .CollectibleID = from .GetCollectibleID ()
}
func (*InputPeerColorCollectible ) TypeID () uint32 {
return InputPeerColorCollectibleTypeID
}
func (*InputPeerColorCollectible ) TypeName () string {
return "inputPeerColorCollectible"
}
func (i *InputPeerColorCollectible ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputPeerColorCollectible" ,
ID : InputPeerColorCollectibleTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "CollectibleID" ,
SchemaName : "collectible_id" ,
},
}
return typ
}
func (i *InputPeerColorCollectible ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputPeerColorCollectible#b8ea86a9 as nil" )
}
b .PutID (InputPeerColorCollectibleTypeID )
return i .EncodeBare (b )
}
func (i *InputPeerColorCollectible ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputPeerColorCollectible#b8ea86a9 as nil" )
}
b .PutLong (i .CollectibleID )
return nil
}
func (i *InputPeerColorCollectible ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputPeerColorCollectible#b8ea86a9 to nil" )
}
if err := b .ConsumeID (InputPeerColorCollectibleTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputPeerColorCollectible#b8ea86a9: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputPeerColorCollectible ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputPeerColorCollectible#b8ea86a9 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputPeerColorCollectible#b8ea86a9: field collectible_id: %w" , err )
}
i .CollectibleID = value
}
return nil
}
func (i *InputPeerColorCollectible ) GetCollectibleID () (value int64 ) {
if i == nil {
return
}
return i .CollectibleID
}
const PeerColorClassName = "PeerColor"
type PeerColorClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () PeerColorClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodePeerColor (buf *bin .Buffer ) (PeerColorClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case PeerColorTypeID :
v := PeerColor {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PeerColorClass: %w" , err )
}
return &v , nil
case PeerColorCollectibleTypeID :
v := PeerColorCollectible {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PeerColorClass: %w" , err )
}
return &v , nil
case InputPeerColorCollectibleTypeID :
v := InputPeerColorCollectible {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PeerColorClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode PeerColorClass: %w" , bin .NewUnexpectedID (id ))
}
}
type PeerColorBox struct {
PeerColor PeerColorClass
}
func (b *PeerColorBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode PeerColorBox to nil" )
}
v , err := DecodePeerColor (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .PeerColor = v
return nil
}
func (b *PeerColorBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .PeerColor == nil {
return fmt .Errorf ("unable to encode PeerColorClass as nil" )
}
return b .PeerColor .Encode (buf )
}
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 .