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 ChannelsUpdateColorRequest struct {
Flags bin .Fields
ForProfile bool
Channel InputChannelClass
Color int
BackgroundEmojiID int64
}
const ChannelsUpdateColorRequestTypeID = 0xd8aa3671
var (
_ bin .Encoder = &ChannelsUpdateColorRequest {}
_ bin .Decoder = &ChannelsUpdateColorRequest {}
_ bin .BareEncoder = &ChannelsUpdateColorRequest {}
_ bin .BareDecoder = &ChannelsUpdateColorRequest {}
)
func (u *ChannelsUpdateColorRequest ) Zero () bool {
if u == nil {
return true
}
if !(u .Flags .Zero ()) {
return false
}
if !(u .ForProfile == false ) {
return false
}
if !(u .Channel == nil ) {
return false
}
if !(u .Color == 0 ) {
return false
}
if !(u .BackgroundEmojiID == 0 ) {
return false
}
return true
}
func (u *ChannelsUpdateColorRequest ) String () string {
if u == nil {
return "ChannelsUpdateColorRequest(nil)"
}
type Alias ChannelsUpdateColorRequest
return fmt .Sprintf ("ChannelsUpdateColorRequest%+v" , Alias (*u ))
}
func (u *ChannelsUpdateColorRequest ) FillFrom (from interface {
GetForProfile () (value bool )
GetChannel () (value InputChannelClass )
GetColor () (value int , ok bool )
GetBackgroundEmojiID () (value int64 , ok bool )
}) {
u .ForProfile = from .GetForProfile ()
u .Channel = from .GetChannel ()
if val , ok := from .GetColor (); ok {
u .Color = val
}
if val , ok := from .GetBackgroundEmojiID (); ok {
u .BackgroundEmojiID = val
}
}
func (*ChannelsUpdateColorRequest ) TypeID () uint32 {
return ChannelsUpdateColorRequestTypeID
}
func (*ChannelsUpdateColorRequest ) TypeName () string {
return "channels.updateColor"
}
func (u *ChannelsUpdateColorRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "channels.updateColor" ,
ID : ChannelsUpdateColorRequestTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ForProfile" ,
SchemaName : "for_profile" ,
Null : !u .Flags .Has (1 ),
},
{
Name : "Channel" ,
SchemaName : "channel" ,
},
{
Name : "Color" ,
SchemaName : "color" ,
Null : !u .Flags .Has (2 ),
},
{
Name : "BackgroundEmojiID" ,
SchemaName : "background_emoji_id" ,
Null : !u .Flags .Has (0 ),
},
}
return typ
}
func (u *ChannelsUpdateColorRequest ) SetFlags () {
if !(u .ForProfile == false ) {
u .Flags .Set (1 )
}
if !(u .Color == 0 ) {
u .Flags .Set (2 )
}
if !(u .BackgroundEmojiID == 0 ) {
u .Flags .Set (0 )
}
}
func (u *ChannelsUpdateColorRequest ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode channels.updateColor#d8aa3671 as nil" )
}
b .PutID (ChannelsUpdateColorRequestTypeID )
return u .EncodeBare (b )
}
func (u *ChannelsUpdateColorRequest ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode channels.updateColor#d8aa3671 as nil" )
}
u .SetFlags ()
if err := u .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.updateColor#d8aa3671: field flags: %w" , err )
}
if u .Channel == nil {
return fmt .Errorf ("unable to encode channels.updateColor#d8aa3671: field channel is nil" )
}
if err := u .Channel .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.updateColor#d8aa3671: field channel: %w" , err )
}
if u .Flags .Has (2 ) {
b .PutInt (u .Color )
}
if u .Flags .Has (0 ) {
b .PutLong (u .BackgroundEmojiID )
}
return nil
}
func (u *ChannelsUpdateColorRequest ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode channels.updateColor#d8aa3671 to nil" )
}
if err := b .ConsumeID (ChannelsUpdateColorRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode channels.updateColor#d8aa3671: %w" , err )
}
return u .DecodeBare (b )
}
func (u *ChannelsUpdateColorRequest ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode channels.updateColor#d8aa3671 to nil" )
}
{
if err := u .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode channels.updateColor#d8aa3671: field flags: %w" , err )
}
}
u .ForProfile = u .Flags .Has (1 )
{
value , err := DecodeInputChannel (b )
if err != nil {
return fmt .Errorf ("unable to decode channels.updateColor#d8aa3671: field channel: %w" , err )
}
u .Channel = value
}
if u .Flags .Has (2 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode channels.updateColor#d8aa3671: field color: %w" , err )
}
u .Color = value
}
if u .Flags .Has (0 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode channels.updateColor#d8aa3671: field background_emoji_id: %w" , err )
}
u .BackgroundEmojiID = value
}
return nil
}
func (u *ChannelsUpdateColorRequest ) SetForProfile (value bool ) {
if value {
u .Flags .Set (1 )
u .ForProfile = true
} else {
u .Flags .Unset (1 )
u .ForProfile = false
}
}
func (u *ChannelsUpdateColorRequest ) GetForProfile () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (1 )
}
func (u *ChannelsUpdateColorRequest ) GetChannel () (value InputChannelClass ) {
if u == nil {
return
}
return u .Channel
}
func (u *ChannelsUpdateColorRequest ) SetColor (value int ) {
u .Flags .Set (2 )
u .Color = value
}
func (u *ChannelsUpdateColorRequest ) GetColor () (value int , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (2 ) {
return value , false
}
return u .Color , true
}
func (u *ChannelsUpdateColorRequest ) SetBackgroundEmojiID (value int64 ) {
u .Flags .Set (0 )
u .BackgroundEmojiID = value
}
func (u *ChannelsUpdateColorRequest ) GetBackgroundEmojiID () (value int64 , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (0 ) {
return value , false
}
return u .BackgroundEmojiID , true
}
func (u *ChannelsUpdateColorRequest ) GetChannelAsNotEmpty () (NotEmptyInputChannel , bool ) {
return u .Channel .AsNotEmpty ()
}
func (c *Client ) ChannelsUpdateColor (ctx context .Context , request *ChannelsUpdateColorRequest ) (UpdatesClass , error ) {
var result UpdatesBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .Updates , nil
}
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 .