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 MessagesSetChatWallPaperRequest struct {
Flags bin .Fields
ForBoth bool
Revert bool
Peer InputPeerClass
Wallpaper InputWallPaperClass
Settings WallPaperSettings
ID int
}
const MessagesSetChatWallPaperRequestTypeID = 0x8ffacae1
var (
_ bin .Encoder = &MessagesSetChatWallPaperRequest {}
_ bin .Decoder = &MessagesSetChatWallPaperRequest {}
_ bin .BareEncoder = &MessagesSetChatWallPaperRequest {}
_ bin .BareDecoder = &MessagesSetChatWallPaperRequest {}
)
func (s *MessagesSetChatWallPaperRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .ForBoth == false ) {
return false
}
if !(s .Revert == false ) {
return false
}
if !(s .Peer == nil ) {
return false
}
if !(s .Wallpaper == nil ) {
return false
}
if !(s .Settings .Zero ()) {
return false
}
if !(s .ID == 0 ) {
return false
}
return true
}
func (s *MessagesSetChatWallPaperRequest ) String () string {
if s == nil {
return "MessagesSetChatWallPaperRequest(nil)"
}
type Alias MessagesSetChatWallPaperRequest
return fmt .Sprintf ("MessagesSetChatWallPaperRequest%+v" , Alias (*s ))
}
func (s *MessagesSetChatWallPaperRequest ) FillFrom (from interface {
GetForBoth () (value bool )
GetRevert () (value bool )
GetPeer () (value InputPeerClass )
GetWallpaper () (value InputWallPaperClass , ok bool )
GetSettings () (value WallPaperSettings , ok bool )
GetID () (value int , ok bool )
}) {
s .ForBoth = from .GetForBoth ()
s .Revert = from .GetRevert ()
s .Peer = from .GetPeer ()
if val , ok := from .GetWallpaper (); ok {
s .Wallpaper = val
}
if val , ok := from .GetSettings (); ok {
s .Settings = val
}
if val , ok := from .GetID (); ok {
s .ID = val
}
}
func (*MessagesSetChatWallPaperRequest ) TypeID () uint32 {
return MessagesSetChatWallPaperRequestTypeID
}
func (*MessagesSetChatWallPaperRequest ) TypeName () string {
return "messages.setChatWallPaper"
}
func (s *MessagesSetChatWallPaperRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.setChatWallPaper" ,
ID : MessagesSetChatWallPaperRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ForBoth" ,
SchemaName : "for_both" ,
Null : !s .Flags .Has (3 ),
},
{
Name : "Revert" ,
SchemaName : "revert" ,
Null : !s .Flags .Has (4 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "Wallpaper" ,
SchemaName : "wallpaper" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "Settings" ,
SchemaName : "settings" ,
Null : !s .Flags .Has (2 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
Null : !s .Flags .Has (1 ),
},
}
return typ
}
func (s *MessagesSetChatWallPaperRequest ) SetFlags () {
if !(s .ForBoth == false ) {
s .Flags .Set (3 )
}
if !(s .Revert == false ) {
s .Flags .Set (4 )
}
if !(s .Wallpaper == nil ) {
s .Flags .Set (0 )
}
if !(s .Settings .Zero ()) {
s .Flags .Set (2 )
}
if !(s .ID == 0 ) {
s .Flags .Set (1 )
}
}
func (s *MessagesSetChatWallPaperRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.setChatWallPaper#8ffacae1 as nil" )
}
b .PutID (MessagesSetChatWallPaperRequestTypeID )
return s .EncodeBare (b )
}
func (s *MessagesSetChatWallPaperRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.setChatWallPaper#8ffacae1 as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.setChatWallPaper#8ffacae1: field flags: %w" , err )
}
if s .Peer == nil {
return fmt .Errorf ("unable to encode messages.setChatWallPaper#8ffacae1: field peer is nil" )
}
if err := s .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.setChatWallPaper#8ffacae1: field peer: %w" , err )
}
if s .Flags .Has (0 ) {
if s .Wallpaper == nil {
return fmt .Errorf ("unable to encode messages.setChatWallPaper#8ffacae1: field wallpaper is nil" )
}
if err := s .Wallpaper .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.setChatWallPaper#8ffacae1: field wallpaper: %w" , err )
}
}
if s .Flags .Has (2 ) {
if err := s .Settings .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.setChatWallPaper#8ffacae1: field settings: %w" , err )
}
}
if s .Flags .Has (1 ) {
b .PutInt (s .ID )
}
return nil
}
func (s *MessagesSetChatWallPaperRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.setChatWallPaper#8ffacae1 to nil" )
}
if err := b .ConsumeID (MessagesSetChatWallPaperRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.setChatWallPaper#8ffacae1: %w" , err )
}
return s .DecodeBare (b )
}
func (s *MessagesSetChatWallPaperRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.setChatWallPaper#8ffacae1 to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.setChatWallPaper#8ffacae1: field flags: %w" , err )
}
}
s .ForBoth = s .Flags .Has (3 )
s .Revert = s .Flags .Has (4 )
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.setChatWallPaper#8ffacae1: field peer: %w" , err )
}
s .Peer = value
}
if s .Flags .Has (0 ) {
value , err := DecodeInputWallPaper (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.setChatWallPaper#8ffacae1: field wallpaper: %w" , err )
}
s .Wallpaper = value
}
if s .Flags .Has (2 ) {
if err := s .Settings .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.setChatWallPaper#8ffacae1: field settings: %w" , err )
}
}
if s .Flags .Has (1 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.setChatWallPaper#8ffacae1: field id: %w" , err )
}
s .ID = value
}
return nil
}
func (s *MessagesSetChatWallPaperRequest ) SetForBoth (value bool ) {
if value {
s .Flags .Set (3 )
s .ForBoth = true
} else {
s .Flags .Unset (3 )
s .ForBoth = false
}
}
func (s *MessagesSetChatWallPaperRequest ) GetForBoth () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (3 )
}
func (s *MessagesSetChatWallPaperRequest ) SetRevert (value bool ) {
if value {
s .Flags .Set (4 )
s .Revert = true
} else {
s .Flags .Unset (4 )
s .Revert = false
}
}
func (s *MessagesSetChatWallPaperRequest ) GetRevert () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (4 )
}
func (s *MessagesSetChatWallPaperRequest ) GetPeer () (value InputPeerClass ) {
if s == nil {
return
}
return s .Peer
}
func (s *MessagesSetChatWallPaperRequest ) SetWallpaper (value InputWallPaperClass ) {
s .Flags .Set (0 )
s .Wallpaper = value
}
func (s *MessagesSetChatWallPaperRequest ) GetWallpaper () (value InputWallPaperClass , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .Wallpaper , true
}
func (s *MessagesSetChatWallPaperRequest ) SetSettings (value WallPaperSettings ) {
s .Flags .Set (2 )
s .Settings = value
}
func (s *MessagesSetChatWallPaperRequest ) GetSettings () (value WallPaperSettings , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (2 ) {
return value , false
}
return s .Settings , true
}
func (s *MessagesSetChatWallPaperRequest ) SetID (value int ) {
s .Flags .Set (1 )
s .ID = value
}
func (s *MessagesSetChatWallPaperRequest ) GetID () (value int , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (1 ) {
return value , false
}
return s .ID , true
}
func (c *Client ) MessagesSetChatWallPaper (ctx context .Context , request *MessagesSetChatWallPaperRequest ) (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 .