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 HelpPeerColorOption struct {
Flags bin .Fields
Hidden bool
ColorID int
Colors HelpPeerColorSetClass
DarkColors HelpPeerColorSetClass
ChannelMinLevel int
}
const HelpPeerColorOptionTypeID = 0xef8430ab
var (
_ bin .Encoder = &HelpPeerColorOption {}
_ bin .Decoder = &HelpPeerColorOption {}
_ bin .BareEncoder = &HelpPeerColorOption {}
_ bin .BareDecoder = &HelpPeerColorOption {}
)
func (p *HelpPeerColorOption ) Zero () bool {
if p == nil {
return true
}
if !(p .Flags .Zero ()) {
return false
}
if !(p .Hidden == false ) {
return false
}
if !(p .ColorID == 0 ) {
return false
}
if !(p .Colors == nil ) {
return false
}
if !(p .DarkColors == nil ) {
return false
}
if !(p .ChannelMinLevel == 0 ) {
return false
}
return true
}
func (p *HelpPeerColorOption ) String () string {
if p == nil {
return "HelpPeerColorOption(nil)"
}
type Alias HelpPeerColorOption
return fmt .Sprintf ("HelpPeerColorOption%+v" , Alias (*p ))
}
func (p *HelpPeerColorOption ) FillFrom (from interface {
GetHidden () (value bool )
GetColorID () (value int )
GetColors () (value HelpPeerColorSetClass , ok bool )
GetDarkColors () (value HelpPeerColorSetClass , ok bool )
GetChannelMinLevel () (value int , ok bool )
}) {
p .Hidden = from .GetHidden ()
p .ColorID = from .GetColorID ()
if val , ok := from .GetColors (); ok {
p .Colors = val
}
if val , ok := from .GetDarkColors (); ok {
p .DarkColors = val
}
if val , ok := from .GetChannelMinLevel (); ok {
p .ChannelMinLevel = val
}
}
func (*HelpPeerColorOption ) TypeID () uint32 {
return HelpPeerColorOptionTypeID
}
func (*HelpPeerColorOption ) TypeName () string {
return "help.peerColorOption"
}
func (p *HelpPeerColorOption ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "help.peerColorOption" ,
ID : HelpPeerColorOptionTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Hidden" ,
SchemaName : "hidden" ,
Null : !p .Flags .Has (0 ),
},
{
Name : "ColorID" ,
SchemaName : "color_id" ,
},
{
Name : "Colors" ,
SchemaName : "colors" ,
Null : !p .Flags .Has (1 ),
},
{
Name : "DarkColors" ,
SchemaName : "dark_colors" ,
Null : !p .Flags .Has (2 ),
},
{
Name : "ChannelMinLevel" ,
SchemaName : "channel_min_level" ,
Null : !p .Flags .Has (3 ),
},
}
return typ
}
func (p *HelpPeerColorOption ) SetFlags () {
if !(p .Hidden == false ) {
p .Flags .Set (0 )
}
if !(p .Colors == nil ) {
p .Flags .Set (1 )
}
if !(p .DarkColors == nil ) {
p .Flags .Set (2 )
}
if !(p .ChannelMinLevel == 0 ) {
p .Flags .Set (3 )
}
}
func (p *HelpPeerColorOption ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode help.peerColorOption#ef8430ab as nil" )
}
b .PutID (HelpPeerColorOptionTypeID )
return p .EncodeBare (b )
}
func (p *HelpPeerColorOption ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode help.peerColorOption#ef8430ab as nil" )
}
p .SetFlags ()
if err := p .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode help.peerColorOption#ef8430ab: field flags: %w" , err )
}
b .PutInt (p .ColorID )
if p .Flags .Has (1 ) {
if p .Colors == nil {
return fmt .Errorf ("unable to encode help.peerColorOption#ef8430ab: field colors is nil" )
}
if err := p .Colors .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode help.peerColorOption#ef8430ab: field colors: %w" , err )
}
}
if p .Flags .Has (2 ) {
if p .DarkColors == nil {
return fmt .Errorf ("unable to encode help.peerColorOption#ef8430ab: field dark_colors is nil" )
}
if err := p .DarkColors .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode help.peerColorOption#ef8430ab: field dark_colors: %w" , err )
}
}
if p .Flags .Has (3 ) {
b .PutInt (p .ChannelMinLevel )
}
return nil
}
func (p *HelpPeerColorOption ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode help.peerColorOption#ef8430ab to nil" )
}
if err := b .ConsumeID (HelpPeerColorOptionTypeID ); err != nil {
return fmt .Errorf ("unable to decode help.peerColorOption#ef8430ab: %w" , err )
}
return p .DecodeBare (b )
}
func (p *HelpPeerColorOption ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode help.peerColorOption#ef8430ab to nil" )
}
{
if err := p .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode help.peerColorOption#ef8430ab: field flags: %w" , err )
}
}
p .Hidden = p .Flags .Has (0 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode help.peerColorOption#ef8430ab: field color_id: %w" , err )
}
p .ColorID = value
}
if p .Flags .Has (1 ) {
value , err := DecodeHelpPeerColorSet (b )
if err != nil {
return fmt .Errorf ("unable to decode help.peerColorOption#ef8430ab: field colors: %w" , err )
}
p .Colors = value
}
if p .Flags .Has (2 ) {
value , err := DecodeHelpPeerColorSet (b )
if err != nil {
return fmt .Errorf ("unable to decode help.peerColorOption#ef8430ab: field dark_colors: %w" , err )
}
p .DarkColors = value
}
if p .Flags .Has (3 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode help.peerColorOption#ef8430ab: field channel_min_level: %w" , err )
}
p .ChannelMinLevel = value
}
return nil
}
func (p *HelpPeerColorOption ) SetHidden (value bool ) {
if value {
p .Flags .Set (0 )
p .Hidden = true
} else {
p .Flags .Unset (0 )
p .Hidden = false
}
}
func (p *HelpPeerColorOption ) GetHidden () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (0 )
}
func (p *HelpPeerColorOption ) GetColorID () (value int ) {
if p == nil {
return
}
return p .ColorID
}
func (p *HelpPeerColorOption ) SetColors (value HelpPeerColorSetClass ) {
p .Flags .Set (1 )
p .Colors = value
}
func (p *HelpPeerColorOption ) GetColors () (value HelpPeerColorSetClass , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (1 ) {
return value , false
}
return p .Colors , true
}
func (p *HelpPeerColorOption ) SetDarkColors (value HelpPeerColorSetClass ) {
p .Flags .Set (2 )
p .DarkColors = value
}
func (p *HelpPeerColorOption ) GetDarkColors () (value HelpPeerColorSetClass , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (2 ) {
return value , false
}
return p .DarkColors , true
}
func (p *HelpPeerColorOption ) SetChannelMinLevel (value int ) {
p .Flags .Set (3 )
p .ChannelMinLevel = value
}
func (p *HelpPeerColorOption ) GetChannelMinLevel () (value int , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (3 ) {
return value , false
}
return p .ChannelMinLevel , true
}
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 .