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 DialogFilter struct {
Flags bin .Fields
Contacts bool
NonContacts bool
Groups bool
Broadcasts bool
Bots bool
ExcludeMuted bool
ExcludeRead bool
ExcludeArchived bool
ID int
Title string
Emoticon string
PinnedPeers []InputPeerClass
IncludePeers []InputPeerClass
ExcludePeers []InputPeerClass
}
const DialogFilterTypeID = 0x7438f7e8
func (d DialogFilter ) construct () DialogFilterClass { return &d }
var (
_ bin .Encoder = &DialogFilter {}
_ bin .Decoder = &DialogFilter {}
_ bin .BareEncoder = &DialogFilter {}
_ bin .BareDecoder = &DialogFilter {}
_ DialogFilterClass = &DialogFilter {}
)
func (d *DialogFilter ) Zero () bool {
if d == nil {
return true
}
if !(d .Flags .Zero ()) {
return false
}
if !(d .Contacts == false ) {
return false
}
if !(d .NonContacts == false ) {
return false
}
if !(d .Groups == false ) {
return false
}
if !(d .Broadcasts == false ) {
return false
}
if !(d .Bots == false ) {
return false
}
if !(d .ExcludeMuted == false ) {
return false
}
if !(d .ExcludeRead == false ) {
return false
}
if !(d .ExcludeArchived == false ) {
return false
}
if !(d .ID == 0 ) {
return false
}
if !(d .Title == "" ) {
return false
}
if !(d .Emoticon == "" ) {
return false
}
if !(d .PinnedPeers == nil ) {
return false
}
if !(d .IncludePeers == nil ) {
return false
}
if !(d .ExcludePeers == nil ) {
return false
}
return true
}
func (d *DialogFilter ) String () string {
if d == nil {
return "DialogFilter(nil)"
}
type Alias DialogFilter
return fmt .Sprintf ("DialogFilter%+v" , Alias (*d ))
}
func (d *DialogFilter ) FillFrom (from interface {
GetContacts () (value bool )
GetNonContacts () (value bool )
GetGroups () (value bool )
GetBroadcasts () (value bool )
GetBots () (value bool )
GetExcludeMuted () (value bool )
GetExcludeRead () (value bool )
GetExcludeArchived () (value bool )
GetID () (value int )
GetTitle () (value string )
GetEmoticon () (value string , ok bool )
GetPinnedPeers () (value []InputPeerClass )
GetIncludePeers () (value []InputPeerClass )
GetExcludePeers () (value []InputPeerClass )
}) {
d .Contacts = from .GetContacts ()
d .NonContacts = from .GetNonContacts ()
d .Groups = from .GetGroups ()
d .Broadcasts = from .GetBroadcasts ()
d .Bots = from .GetBots ()
d .ExcludeMuted = from .GetExcludeMuted ()
d .ExcludeRead = from .GetExcludeRead ()
d .ExcludeArchived = from .GetExcludeArchived ()
d .ID = from .GetID ()
d .Title = from .GetTitle ()
if val , ok := from .GetEmoticon (); ok {
d .Emoticon = val
}
d .PinnedPeers = from .GetPinnedPeers ()
d .IncludePeers = from .GetIncludePeers ()
d .ExcludePeers = from .GetExcludePeers ()
}
func (*DialogFilter ) TypeID () uint32 {
return DialogFilterTypeID
}
func (*DialogFilter ) TypeName () string {
return "dialogFilter"
}
func (d *DialogFilter ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "dialogFilter" ,
ID : DialogFilterTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Contacts" ,
SchemaName : "contacts" ,
Null : !d .Flags .Has (0 ),
},
{
Name : "NonContacts" ,
SchemaName : "non_contacts" ,
Null : !d .Flags .Has (1 ),
},
{
Name : "Groups" ,
SchemaName : "groups" ,
Null : !d .Flags .Has (2 ),
},
{
Name : "Broadcasts" ,
SchemaName : "broadcasts" ,
Null : !d .Flags .Has (3 ),
},
{
Name : "Bots" ,
SchemaName : "bots" ,
Null : !d .Flags .Has (4 ),
},
{
Name : "ExcludeMuted" ,
SchemaName : "exclude_muted" ,
Null : !d .Flags .Has (11 ),
},
{
Name : "ExcludeRead" ,
SchemaName : "exclude_read" ,
Null : !d .Flags .Has (12 ),
},
{
Name : "ExcludeArchived" ,
SchemaName : "exclude_archived" ,
Null : !d .Flags .Has (13 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Title" ,
SchemaName : "title" ,
},
{
Name : "Emoticon" ,
SchemaName : "emoticon" ,
Null : !d .Flags .Has (25 ),
},
{
Name : "PinnedPeers" ,
SchemaName : "pinned_peers" ,
},
{
Name : "IncludePeers" ,
SchemaName : "include_peers" ,
},
{
Name : "ExcludePeers" ,
SchemaName : "exclude_peers" ,
},
}
return typ
}
func (d *DialogFilter ) SetFlags () {
if !(d .Contacts == false ) {
d .Flags .Set (0 )
}
if !(d .NonContacts == false ) {
d .Flags .Set (1 )
}
if !(d .Groups == false ) {
d .Flags .Set (2 )
}
if !(d .Broadcasts == false ) {
d .Flags .Set (3 )
}
if !(d .Bots == false ) {
d .Flags .Set (4 )
}
if !(d .ExcludeMuted == false ) {
d .Flags .Set (11 )
}
if !(d .ExcludeRead == false ) {
d .Flags .Set (12 )
}
if !(d .ExcludeArchived == false ) {
d .Flags .Set (13 )
}
if !(d .Emoticon == "" ) {
d .Flags .Set (25 )
}
}
func (d *DialogFilter ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode dialogFilter#7438f7e8 as nil" )
}
b .PutID (DialogFilterTypeID )
return d .EncodeBare (b )
}
func (d *DialogFilter ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode dialogFilter#7438f7e8 as nil" )
}
d .SetFlags ()
if err := d .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode dialogFilter#7438f7e8: field flags: %w" , err )
}
b .PutInt (d .ID )
b .PutString (d .Title )
if d .Flags .Has (25 ) {
b .PutString (d .Emoticon )
}
b .PutVectorHeader (len (d .PinnedPeers ))
for idx , v := range d .PinnedPeers {
if v == nil {
return fmt .Errorf ("unable to encode dialogFilter#7438f7e8: field pinned_peers element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode dialogFilter#7438f7e8: field pinned_peers element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (d .IncludePeers ))
for idx , v := range d .IncludePeers {
if v == nil {
return fmt .Errorf ("unable to encode dialogFilter#7438f7e8: field include_peers element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode dialogFilter#7438f7e8: field include_peers element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (d .ExcludePeers ))
for idx , v := range d .ExcludePeers {
if v == nil {
return fmt .Errorf ("unable to encode dialogFilter#7438f7e8: field exclude_peers element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode dialogFilter#7438f7e8: field exclude_peers element with index %d: %w" , idx , err )
}
}
return nil
}
func (d *DialogFilter ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode dialogFilter#7438f7e8 to nil" )
}
if err := b .ConsumeID (DialogFilterTypeID ); err != nil {
return fmt .Errorf ("unable to decode dialogFilter#7438f7e8: %w" , err )
}
return d .DecodeBare (b )
}
func (d *DialogFilter ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode dialogFilter#7438f7e8 to nil" )
}
{
if err := d .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode dialogFilter#7438f7e8: field flags: %w" , err )
}
}
d .Contacts = d .Flags .Has (0 )
d .NonContacts = d .Flags .Has (1 )
d .Groups = d .Flags .Has (2 )
d .Broadcasts = d .Flags .Has (3 )
d .Bots = d .Flags .Has (4 )
d .ExcludeMuted = d .Flags .Has (11 )
d .ExcludeRead = d .Flags .Has (12 )
d .ExcludeArchived = d .Flags .Has (13 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode dialogFilter#7438f7e8: field id: %w" , err )
}
d .ID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode dialogFilter#7438f7e8: field title: %w" , err )
}
d .Title = value
}
if d .Flags .Has (25 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode dialogFilter#7438f7e8: field emoticon: %w" , err )
}
d .Emoticon = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode dialogFilter#7438f7e8: field pinned_peers: %w" , err )
}
if headerLen > 0 {
d .PinnedPeers = make ([]InputPeerClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode dialogFilter#7438f7e8: field pinned_peers: %w" , err )
}
d .PinnedPeers = append (d .PinnedPeers , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode dialogFilter#7438f7e8: field include_peers: %w" , err )
}
if headerLen > 0 {
d .IncludePeers = make ([]InputPeerClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode dialogFilter#7438f7e8: field include_peers: %w" , err )
}
d .IncludePeers = append (d .IncludePeers , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode dialogFilter#7438f7e8: field exclude_peers: %w" , err )
}
if headerLen > 0 {
d .ExcludePeers = make ([]InputPeerClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode dialogFilter#7438f7e8: field exclude_peers: %w" , err )
}
d .ExcludePeers = append (d .ExcludePeers , value )
}
}
return nil
}
func (d *DialogFilter ) SetContacts (value bool ) {
if value {
d .Flags .Set (0 )
d .Contacts = true
} else {
d .Flags .Unset (0 )
d .Contacts = false
}
}
func (d *DialogFilter ) GetContacts () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (0 )
}
func (d *DialogFilter ) SetNonContacts (value bool ) {
if value {
d .Flags .Set (1 )
d .NonContacts = true
} else {
d .Flags .Unset (1 )
d .NonContacts = false
}
}
func (d *DialogFilter ) GetNonContacts () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (1 )
}
func (d *DialogFilter ) SetGroups (value bool ) {
if value {
d .Flags .Set (2 )
d .Groups = true
} else {
d .Flags .Unset (2 )
d .Groups = false
}
}
func (d *DialogFilter ) GetGroups () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (2 )
}
func (d *DialogFilter ) SetBroadcasts (value bool ) {
if value {
d .Flags .Set (3 )
d .Broadcasts = true
} else {
d .Flags .Unset (3 )
d .Broadcasts = false
}
}
func (d *DialogFilter ) GetBroadcasts () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (3 )
}
func (d *DialogFilter ) SetBots (value bool ) {
if value {
d .Flags .Set (4 )
d .Bots = true
} else {
d .Flags .Unset (4 )
d .Bots = false
}
}
func (d *DialogFilter ) GetBots () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (4 )
}
func (d *DialogFilter ) SetExcludeMuted (value bool ) {
if value {
d .Flags .Set (11 )
d .ExcludeMuted = true
} else {
d .Flags .Unset (11 )
d .ExcludeMuted = false
}
}
func (d *DialogFilter ) GetExcludeMuted () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (11 )
}
func (d *DialogFilter ) SetExcludeRead (value bool ) {
if value {
d .Flags .Set (12 )
d .ExcludeRead = true
} else {
d .Flags .Unset (12 )
d .ExcludeRead = false
}
}
func (d *DialogFilter ) GetExcludeRead () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (12 )
}
func (d *DialogFilter ) SetExcludeArchived (value bool ) {
if value {
d .Flags .Set (13 )
d .ExcludeArchived = true
} else {
d .Flags .Unset (13 )
d .ExcludeArchived = false
}
}
func (d *DialogFilter ) GetExcludeArchived () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (13 )
}
func (d *DialogFilter ) GetID () (value int ) {
if d == nil {
return
}
return d .ID
}
func (d *DialogFilter ) GetTitle () (value string ) {
if d == nil {
return
}
return d .Title
}
func (d *DialogFilter ) SetEmoticon (value string ) {
d .Flags .Set (25 )
d .Emoticon = value
}
func (d *DialogFilter ) GetEmoticon () (value string , ok bool ) {
if d == nil {
return
}
if !d .Flags .Has (25 ) {
return value , false
}
return d .Emoticon , true
}
func (d *DialogFilter ) GetPinnedPeers () (value []InputPeerClass ) {
if d == nil {
return
}
return d .PinnedPeers
}
func (d *DialogFilter ) GetIncludePeers () (value []InputPeerClass ) {
if d == nil {
return
}
return d .IncludePeers
}
func (d *DialogFilter ) GetExcludePeers () (value []InputPeerClass ) {
if d == nil {
return
}
return d .ExcludePeers
}
func (d *DialogFilter ) MapPinnedPeers () (value InputPeerClassArray ) {
return InputPeerClassArray (d .PinnedPeers )
}
func (d *DialogFilter ) MapIncludePeers () (value InputPeerClassArray ) {
return InputPeerClassArray (d .IncludePeers )
}
func (d *DialogFilter ) MapExcludePeers () (value InputPeerClassArray ) {
return InputPeerClassArray (d .ExcludePeers )
}
type DialogFilterDefault struct {
}
const DialogFilterDefaultTypeID = 0x363293ae
func (d DialogFilterDefault ) construct () DialogFilterClass { return &d }
var (
_ bin .Encoder = &DialogFilterDefault {}
_ bin .Decoder = &DialogFilterDefault {}
_ bin .BareEncoder = &DialogFilterDefault {}
_ bin .BareDecoder = &DialogFilterDefault {}
_ DialogFilterClass = &DialogFilterDefault {}
)
func (d *DialogFilterDefault ) Zero () bool {
if d == nil {
return true
}
return true
}
func (d *DialogFilterDefault ) String () string {
if d == nil {
return "DialogFilterDefault(nil)"
}
type Alias DialogFilterDefault
return fmt .Sprintf ("DialogFilterDefault%+v" , Alias (*d ))
}
func (*DialogFilterDefault ) TypeID () uint32 {
return DialogFilterDefaultTypeID
}
func (*DialogFilterDefault ) TypeName () string {
return "dialogFilterDefault"
}
func (d *DialogFilterDefault ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "dialogFilterDefault" ,
ID : DialogFilterDefaultTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (d *DialogFilterDefault ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode dialogFilterDefault#363293ae as nil" )
}
b .PutID (DialogFilterDefaultTypeID )
return d .EncodeBare (b )
}
func (d *DialogFilterDefault ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode dialogFilterDefault#363293ae as nil" )
}
return nil
}
func (d *DialogFilterDefault ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode dialogFilterDefault#363293ae to nil" )
}
if err := b .ConsumeID (DialogFilterDefaultTypeID ); err != nil {
return fmt .Errorf ("unable to decode dialogFilterDefault#363293ae: %w" , err )
}
return d .DecodeBare (b )
}
func (d *DialogFilterDefault ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode dialogFilterDefault#363293ae to nil" )
}
return nil
}
type DialogFilterChatlist struct {
Flags bin .Fields
HasMyInvites bool
ID int
Title string
Emoticon string
PinnedPeers []InputPeerClass
IncludePeers []InputPeerClass
}
const DialogFilterChatlistTypeID = 0xd64a04a8
func (d DialogFilterChatlist ) construct () DialogFilterClass { return &d }
var (
_ bin .Encoder = &DialogFilterChatlist {}
_ bin .Decoder = &DialogFilterChatlist {}
_ bin .BareEncoder = &DialogFilterChatlist {}
_ bin .BareDecoder = &DialogFilterChatlist {}
_ DialogFilterClass = &DialogFilterChatlist {}
)
func (d *DialogFilterChatlist ) Zero () bool {
if d == nil {
return true
}
if !(d .Flags .Zero ()) {
return false
}
if !(d .HasMyInvites == false ) {
return false
}
if !(d .ID == 0 ) {
return false
}
if !(d .Title == "" ) {
return false
}
if !(d .Emoticon == "" ) {
return false
}
if !(d .PinnedPeers == nil ) {
return false
}
if !(d .IncludePeers == nil ) {
return false
}
return true
}
func (d *DialogFilterChatlist ) String () string {
if d == nil {
return "DialogFilterChatlist(nil)"
}
type Alias DialogFilterChatlist
return fmt .Sprintf ("DialogFilterChatlist%+v" , Alias (*d ))
}
func (d *DialogFilterChatlist ) FillFrom (from interface {
GetHasMyInvites () (value bool )
GetID () (value int )
GetTitle () (value string )
GetEmoticon () (value string , ok bool )
GetPinnedPeers () (value []InputPeerClass )
GetIncludePeers () (value []InputPeerClass )
}) {
d .HasMyInvites = from .GetHasMyInvites ()
d .ID = from .GetID ()
d .Title = from .GetTitle ()
if val , ok := from .GetEmoticon (); ok {
d .Emoticon = val
}
d .PinnedPeers = from .GetPinnedPeers ()
d .IncludePeers = from .GetIncludePeers ()
}
func (*DialogFilterChatlist ) TypeID () uint32 {
return DialogFilterChatlistTypeID
}
func (*DialogFilterChatlist ) TypeName () string {
return "dialogFilterChatlist"
}
func (d *DialogFilterChatlist ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "dialogFilterChatlist" ,
ID : DialogFilterChatlistTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "HasMyInvites" ,
SchemaName : "has_my_invites" ,
Null : !d .Flags .Has (26 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Title" ,
SchemaName : "title" ,
},
{
Name : "Emoticon" ,
SchemaName : "emoticon" ,
Null : !d .Flags .Has (25 ),
},
{
Name : "PinnedPeers" ,
SchemaName : "pinned_peers" ,
},
{
Name : "IncludePeers" ,
SchemaName : "include_peers" ,
},
}
return typ
}
func (d *DialogFilterChatlist ) SetFlags () {
if !(d .HasMyInvites == false ) {
d .Flags .Set (26 )
}
if !(d .Emoticon == "" ) {
d .Flags .Set (25 )
}
}
func (d *DialogFilterChatlist ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode dialogFilterChatlist#d64a04a8 as nil" )
}
b .PutID (DialogFilterChatlistTypeID )
return d .EncodeBare (b )
}
func (d *DialogFilterChatlist ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode dialogFilterChatlist#d64a04a8 as nil" )
}
d .SetFlags ()
if err := d .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode dialogFilterChatlist#d64a04a8: field flags: %w" , err )
}
b .PutInt (d .ID )
b .PutString (d .Title )
if d .Flags .Has (25 ) {
b .PutString (d .Emoticon )
}
b .PutVectorHeader (len (d .PinnedPeers ))
for idx , v := range d .PinnedPeers {
if v == nil {
return fmt .Errorf ("unable to encode dialogFilterChatlist#d64a04a8: field pinned_peers element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode dialogFilterChatlist#d64a04a8: field pinned_peers element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (d .IncludePeers ))
for idx , v := range d .IncludePeers {
if v == nil {
return fmt .Errorf ("unable to encode dialogFilterChatlist#d64a04a8: field include_peers element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode dialogFilterChatlist#d64a04a8: field include_peers element with index %d: %w" , idx , err )
}
}
return nil
}
func (d *DialogFilterChatlist ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode dialogFilterChatlist#d64a04a8 to nil" )
}
if err := b .ConsumeID (DialogFilterChatlistTypeID ); err != nil {
return fmt .Errorf ("unable to decode dialogFilterChatlist#d64a04a8: %w" , err )
}
return d .DecodeBare (b )
}
func (d *DialogFilterChatlist ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode dialogFilterChatlist#d64a04a8 to nil" )
}
{
if err := d .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode dialogFilterChatlist#d64a04a8: field flags: %w" , err )
}
}
d .HasMyInvites = d .Flags .Has (26 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode dialogFilterChatlist#d64a04a8: field id: %w" , err )
}
d .ID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode dialogFilterChatlist#d64a04a8: field title: %w" , err )
}
d .Title = value
}
if d .Flags .Has (25 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode dialogFilterChatlist#d64a04a8: field emoticon: %w" , err )
}
d .Emoticon = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode dialogFilterChatlist#d64a04a8: field pinned_peers: %w" , err )
}
if headerLen > 0 {
d .PinnedPeers = make ([]InputPeerClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode dialogFilterChatlist#d64a04a8: field pinned_peers: %w" , err )
}
d .PinnedPeers = append (d .PinnedPeers , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode dialogFilterChatlist#d64a04a8: field include_peers: %w" , err )
}
if headerLen > 0 {
d .IncludePeers = make ([]InputPeerClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode dialogFilterChatlist#d64a04a8: field include_peers: %w" , err )
}
d .IncludePeers = append (d .IncludePeers , value )
}
}
return nil
}
func (d *DialogFilterChatlist ) SetHasMyInvites (value bool ) {
if value {
d .Flags .Set (26 )
d .HasMyInvites = true
} else {
d .Flags .Unset (26 )
d .HasMyInvites = false
}
}
func (d *DialogFilterChatlist ) GetHasMyInvites () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (26 )
}
func (d *DialogFilterChatlist ) GetID () (value int ) {
if d == nil {
return
}
return d .ID
}
func (d *DialogFilterChatlist ) GetTitle () (value string ) {
if d == nil {
return
}
return d .Title
}
func (d *DialogFilterChatlist ) SetEmoticon (value string ) {
d .Flags .Set (25 )
d .Emoticon = value
}
func (d *DialogFilterChatlist ) GetEmoticon () (value string , ok bool ) {
if d == nil {
return
}
if !d .Flags .Has (25 ) {
return value , false
}
return d .Emoticon , true
}
func (d *DialogFilterChatlist ) GetPinnedPeers () (value []InputPeerClass ) {
if d == nil {
return
}
return d .PinnedPeers
}
func (d *DialogFilterChatlist ) GetIncludePeers () (value []InputPeerClass ) {
if d == nil {
return
}
return d .IncludePeers
}
func (d *DialogFilterChatlist ) MapPinnedPeers () (value InputPeerClassArray ) {
return InputPeerClassArray (d .PinnedPeers )
}
func (d *DialogFilterChatlist ) MapIncludePeers () (value InputPeerClassArray ) {
return InputPeerClassArray (d .IncludePeers )
}
const DialogFilterClassName = "DialogFilter"
type DialogFilterClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () DialogFilterClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func (d *DialogFilter ) AsInputChatlist () *InputChatlistDialogFilter {
value := new (InputChatlistDialogFilter )
value .FilterID = d .GetID ()
return value
}
func DecodeDialogFilter (buf *bin .Buffer ) (DialogFilterClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case DialogFilterTypeID :
v := DialogFilter {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode DialogFilterClass: %w" , err )
}
return &v , nil
case DialogFilterDefaultTypeID :
v := DialogFilterDefault {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode DialogFilterClass: %w" , err )
}
return &v , nil
case DialogFilterChatlistTypeID :
v := DialogFilterChatlist {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode DialogFilterClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode DialogFilterClass: %w" , bin .NewUnexpectedID (id ))
}
}
type DialogFilterBox struct {
DialogFilter DialogFilterClass
}
func (b *DialogFilterBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode DialogFilterBox to nil" )
}
v , err := DecodeDialogFilter (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .DialogFilter = v
return nil
}
func (b *DialogFilterBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .DialogFilter == nil {
return fmt .Errorf ("unable to encode DialogFilterClass as nil" )
}
return b .DialogFilter .Encode (buf )
}
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 .