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 ChatEmpty struct {
ID int64
}
const ChatEmptyTypeID = 0x29562865
func (c ChatEmpty ) construct () ChatClass { return &c }
var (
_ bin .Encoder = &ChatEmpty {}
_ bin .Decoder = &ChatEmpty {}
_ bin .BareEncoder = &ChatEmpty {}
_ bin .BareDecoder = &ChatEmpty {}
_ ChatClass = &ChatEmpty {}
)
func (c *ChatEmpty ) Zero () bool {
if c == nil {
return true
}
if !(c .ID == 0 ) {
return false
}
return true
}
func (c *ChatEmpty ) String () string {
if c == nil {
return "ChatEmpty(nil)"
}
type Alias ChatEmpty
return fmt .Sprintf ("ChatEmpty%+v" , Alias (*c ))
}
func (c *ChatEmpty ) FillFrom (from interface {
GetID () (value int64 )
}) {
c .ID = from .GetID ()
}
func (*ChatEmpty ) TypeID () uint32 {
return ChatEmptyTypeID
}
func (*ChatEmpty ) TypeName () string {
return "chatEmpty"
}
func (c *ChatEmpty ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatEmpty" ,
ID : ChatEmptyTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
}
return typ
}
func (c *ChatEmpty ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatEmpty#29562865 as nil" )
}
b .PutID (ChatEmptyTypeID )
return c .EncodeBare (b )
}
func (c *ChatEmpty ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatEmpty#29562865 as nil" )
}
b .PutLong (c .ID )
return nil
}
func (c *ChatEmpty ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatEmpty#29562865 to nil" )
}
if err := b .ConsumeID (ChatEmptyTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatEmpty#29562865: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChatEmpty ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatEmpty#29562865 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode chatEmpty#29562865: field id: %w" , err )
}
c .ID = value
}
return nil
}
func (c *ChatEmpty ) GetID () (value int64 ) {
if c == nil {
return
}
return c .ID
}
type Chat struct {
Flags bin .Fields
Creator bool
Left bool
Deactivated bool
CallActive bool
CallNotEmpty bool
Noforwards bool
ID int64
Title string
Photo ChatPhotoClass
ParticipantsCount int
Date int
Version int
MigratedTo InputChannelClass
AdminRights ChatAdminRights
DefaultBannedRights ChatBannedRights
}
const ChatTypeID = 0x41cbf256
func (c Chat ) construct () ChatClass { return &c }
var (
_ bin .Encoder = &Chat {}
_ bin .Decoder = &Chat {}
_ bin .BareEncoder = &Chat {}
_ bin .BareDecoder = &Chat {}
_ ChatClass = &Chat {}
)
func (c *Chat ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .Creator == false ) {
return false
}
if !(c .Left == false ) {
return false
}
if !(c .Deactivated == false ) {
return false
}
if !(c .CallActive == false ) {
return false
}
if !(c .CallNotEmpty == false ) {
return false
}
if !(c .Noforwards == false ) {
return false
}
if !(c .ID == 0 ) {
return false
}
if !(c .Title == "" ) {
return false
}
if !(c .Photo == nil ) {
return false
}
if !(c .ParticipantsCount == 0 ) {
return false
}
if !(c .Date == 0 ) {
return false
}
if !(c .Version == 0 ) {
return false
}
if !(c .MigratedTo == nil ) {
return false
}
if !(c .AdminRights .Zero ()) {
return false
}
if !(c .DefaultBannedRights .Zero ()) {
return false
}
return true
}
func (c *Chat ) String () string {
if c == nil {
return "Chat(nil)"
}
type Alias Chat
return fmt .Sprintf ("Chat%+v" , Alias (*c ))
}
func (c *Chat ) FillFrom (from interface {
GetCreator () (value bool )
GetLeft () (value bool )
GetDeactivated () (value bool )
GetCallActive () (value bool )
GetCallNotEmpty () (value bool )
GetNoforwards () (value bool )
GetID () (value int64 )
GetTitle () (value string )
GetPhoto () (value ChatPhotoClass )
GetParticipantsCount () (value int )
GetDate () (value int )
GetVersion () (value int )
GetMigratedTo () (value InputChannelClass , ok bool )
GetAdminRights () (value ChatAdminRights , ok bool )
GetDefaultBannedRights () (value ChatBannedRights , ok bool )
}) {
c .Creator = from .GetCreator ()
c .Left = from .GetLeft ()
c .Deactivated = from .GetDeactivated ()
c .CallActive = from .GetCallActive ()
c .CallNotEmpty = from .GetCallNotEmpty ()
c .Noforwards = from .GetNoforwards ()
c .ID = from .GetID ()
c .Title = from .GetTitle ()
c .Photo = from .GetPhoto ()
c .ParticipantsCount = from .GetParticipantsCount ()
c .Date = from .GetDate ()
c .Version = from .GetVersion ()
if val , ok := from .GetMigratedTo (); ok {
c .MigratedTo = val
}
if val , ok := from .GetAdminRights (); ok {
c .AdminRights = val
}
if val , ok := from .GetDefaultBannedRights (); ok {
c .DefaultBannedRights = val
}
}
func (*Chat ) TypeID () uint32 {
return ChatTypeID
}
func (*Chat ) TypeName () string {
return "chat"
}
func (c *Chat ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chat" ,
ID : ChatTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Creator" ,
SchemaName : "creator" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "Left" ,
SchemaName : "left" ,
Null : !c .Flags .Has (2 ),
},
{
Name : "Deactivated" ,
SchemaName : "deactivated" ,
Null : !c .Flags .Has (5 ),
},
{
Name : "CallActive" ,
SchemaName : "call_active" ,
Null : !c .Flags .Has (23 ),
},
{
Name : "CallNotEmpty" ,
SchemaName : "call_not_empty" ,
Null : !c .Flags .Has (24 ),
},
{
Name : "Noforwards" ,
SchemaName : "noforwards" ,
Null : !c .Flags .Has (25 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Title" ,
SchemaName : "title" ,
},
{
Name : "Photo" ,
SchemaName : "photo" ,
},
{
Name : "ParticipantsCount" ,
SchemaName : "participants_count" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "Version" ,
SchemaName : "version" ,
},
{
Name : "MigratedTo" ,
SchemaName : "migrated_to" ,
Null : !c .Flags .Has (6 ),
},
{
Name : "AdminRights" ,
SchemaName : "admin_rights" ,
Null : !c .Flags .Has (14 ),
},
{
Name : "DefaultBannedRights" ,
SchemaName : "default_banned_rights" ,
Null : !c .Flags .Has (18 ),
},
}
return typ
}
func (c *Chat ) SetFlags () {
if !(c .Creator == false ) {
c .Flags .Set (0 )
}
if !(c .Left == false ) {
c .Flags .Set (2 )
}
if !(c .Deactivated == false ) {
c .Flags .Set (5 )
}
if !(c .CallActive == false ) {
c .Flags .Set (23 )
}
if !(c .CallNotEmpty == false ) {
c .Flags .Set (24 )
}
if !(c .Noforwards == false ) {
c .Flags .Set (25 )
}
if !(c .MigratedTo == nil ) {
c .Flags .Set (6 )
}
if !(c .AdminRights .Zero ()) {
c .Flags .Set (14 )
}
if !(c .DefaultBannedRights .Zero ()) {
c .Flags .Set (18 )
}
}
func (c *Chat ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chat#41cbf256 as nil" )
}
b .PutID (ChatTypeID )
return c .EncodeBare (b )
}
func (c *Chat ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chat#41cbf256 as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chat#41cbf256: field flags: %w" , err )
}
b .PutLong (c .ID )
b .PutString (c .Title )
if c .Photo == nil {
return fmt .Errorf ("unable to encode chat#41cbf256: field photo is nil" )
}
if err := c .Photo .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chat#41cbf256: field photo: %w" , err )
}
b .PutInt (c .ParticipantsCount )
b .PutInt (c .Date )
b .PutInt (c .Version )
if c .Flags .Has (6 ) {
if c .MigratedTo == nil {
return fmt .Errorf ("unable to encode chat#41cbf256: field migrated_to is nil" )
}
if err := c .MigratedTo .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chat#41cbf256: field migrated_to: %w" , err )
}
}
if c .Flags .Has (14 ) {
if err := c .AdminRights .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chat#41cbf256: field admin_rights: %w" , err )
}
}
if c .Flags .Has (18 ) {
if err := c .DefaultBannedRights .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chat#41cbf256: field default_banned_rights: %w" , err )
}
}
return nil
}
func (c *Chat ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chat#41cbf256 to nil" )
}
if err := b .ConsumeID (ChatTypeID ); err != nil {
return fmt .Errorf ("unable to decode chat#41cbf256: %w" , err )
}
return c .DecodeBare (b )
}
func (c *Chat ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chat#41cbf256 to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode chat#41cbf256: field flags: %w" , err )
}
}
c .Creator = c .Flags .Has (0 )
c .Left = c .Flags .Has (2 )
c .Deactivated = c .Flags .Has (5 )
c .CallActive = c .Flags .Has (23 )
c .CallNotEmpty = c .Flags .Has (24 )
c .Noforwards = c .Flags .Has (25 )
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode chat#41cbf256: field id: %w" , err )
}
c .ID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode chat#41cbf256: field title: %w" , err )
}
c .Title = value
}
{
value , err := DecodeChatPhoto (b )
if err != nil {
return fmt .Errorf ("unable to decode chat#41cbf256: field photo: %w" , err )
}
c .Photo = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode chat#41cbf256: field participants_count: %w" , err )
}
c .ParticipantsCount = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode chat#41cbf256: field date: %w" , err )
}
c .Date = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode chat#41cbf256: field version: %w" , err )
}
c .Version = value
}
if c .Flags .Has (6 ) {
value , err := DecodeInputChannel (b )
if err != nil {
return fmt .Errorf ("unable to decode chat#41cbf256: field migrated_to: %w" , err )
}
c .MigratedTo = value
}
if c .Flags .Has (14 ) {
if err := c .AdminRights .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode chat#41cbf256: field admin_rights: %w" , err )
}
}
if c .Flags .Has (18 ) {
if err := c .DefaultBannedRights .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode chat#41cbf256: field default_banned_rights: %w" , err )
}
}
return nil
}
func (c *Chat ) SetCreator (value bool ) {
if value {
c .Flags .Set (0 )
c .Creator = true
} else {
c .Flags .Unset (0 )
c .Creator = false
}
}
func (c *Chat ) GetCreator () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (0 )
}
func (c *Chat ) SetLeft (value bool ) {
if value {
c .Flags .Set (2 )
c .Left = true
} else {
c .Flags .Unset (2 )
c .Left = false
}
}
func (c *Chat ) GetLeft () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (2 )
}
func (c *Chat ) SetDeactivated (value bool ) {
if value {
c .Flags .Set (5 )
c .Deactivated = true
} else {
c .Flags .Unset (5 )
c .Deactivated = false
}
}
func (c *Chat ) GetDeactivated () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (5 )
}
func (c *Chat ) SetCallActive (value bool ) {
if value {
c .Flags .Set (23 )
c .CallActive = true
} else {
c .Flags .Unset (23 )
c .CallActive = false
}
}
func (c *Chat ) GetCallActive () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (23 )
}
func (c *Chat ) SetCallNotEmpty (value bool ) {
if value {
c .Flags .Set (24 )
c .CallNotEmpty = true
} else {
c .Flags .Unset (24 )
c .CallNotEmpty = false
}
}
func (c *Chat ) GetCallNotEmpty () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (24 )
}
func (c *Chat ) SetNoforwards (value bool ) {
if value {
c .Flags .Set (25 )
c .Noforwards = true
} else {
c .Flags .Unset (25 )
c .Noforwards = false
}
}
func (c *Chat ) GetNoforwards () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (25 )
}
func (c *Chat ) GetID () (value int64 ) {
if c == nil {
return
}
return c .ID
}
func (c *Chat ) GetTitle () (value string ) {
if c == nil {
return
}
return c .Title
}
func (c *Chat ) GetPhoto () (value ChatPhotoClass ) {
if c == nil {
return
}
return c .Photo
}
func (c *Chat ) GetParticipantsCount () (value int ) {
if c == nil {
return
}
return c .ParticipantsCount
}
func (c *Chat ) GetDate () (value int ) {
if c == nil {
return
}
return c .Date
}
func (c *Chat ) GetVersion () (value int ) {
if c == nil {
return
}
return c .Version
}
func (c *Chat ) SetMigratedTo (value InputChannelClass ) {
c .Flags .Set (6 )
c .MigratedTo = value
}
func (c *Chat ) GetMigratedTo () (value InputChannelClass , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (6 ) {
return value , false
}
return c .MigratedTo , true
}
func (c *Chat ) SetAdminRights (value ChatAdminRights ) {
c .Flags .Set (14 )
c .AdminRights = value
}
func (c *Chat ) GetAdminRights () (value ChatAdminRights , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (14 ) {
return value , false
}
return c .AdminRights , true
}
func (c *Chat ) SetDefaultBannedRights (value ChatBannedRights ) {
c .Flags .Set (18 )
c .DefaultBannedRights = value
}
func (c *Chat ) GetDefaultBannedRights () (value ChatBannedRights , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (18 ) {
return value , false
}
return c .DefaultBannedRights , true
}
type ChatForbidden struct {
ID int64
Title string
}
const ChatForbiddenTypeID = 0x6592a1a7
func (c ChatForbidden ) construct () ChatClass { return &c }
var (
_ bin .Encoder = &ChatForbidden {}
_ bin .Decoder = &ChatForbidden {}
_ bin .BareEncoder = &ChatForbidden {}
_ bin .BareDecoder = &ChatForbidden {}
_ ChatClass = &ChatForbidden {}
)
func (c *ChatForbidden ) Zero () bool {
if c == nil {
return true
}
if !(c .ID == 0 ) {
return false
}
if !(c .Title == "" ) {
return false
}
return true
}
func (c *ChatForbidden ) String () string {
if c == nil {
return "ChatForbidden(nil)"
}
type Alias ChatForbidden
return fmt .Sprintf ("ChatForbidden%+v" , Alias (*c ))
}
func (c *ChatForbidden ) FillFrom (from interface {
GetID () (value int64 )
GetTitle () (value string )
}) {
c .ID = from .GetID ()
c .Title = from .GetTitle ()
}
func (*ChatForbidden ) TypeID () uint32 {
return ChatForbiddenTypeID
}
func (*ChatForbidden ) TypeName () string {
return "chatForbidden"
}
func (c *ChatForbidden ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatForbidden" ,
ID : ChatForbiddenTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Title" ,
SchemaName : "title" ,
},
}
return typ
}
func (c *ChatForbidden ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatForbidden#6592a1a7 as nil" )
}
b .PutID (ChatForbiddenTypeID )
return c .EncodeBare (b )
}
func (c *ChatForbidden ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatForbidden#6592a1a7 as nil" )
}
b .PutLong (c .ID )
b .PutString (c .Title )
return nil
}
func (c *ChatForbidden ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatForbidden#6592a1a7 to nil" )
}
if err := b .ConsumeID (ChatForbiddenTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatForbidden#6592a1a7: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChatForbidden ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatForbidden#6592a1a7 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode chatForbidden#6592a1a7: field id: %w" , err )
}
c .ID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode chatForbidden#6592a1a7: field title: %w" , err )
}
c .Title = value
}
return nil
}
func (c *ChatForbidden ) GetID () (value int64 ) {
if c == nil {
return
}
return c .ID
}
func (c *ChatForbidden ) GetTitle () (value string ) {
if c == nil {
return
}
return c .Title
}
type Channel struct {
Flags bin .Fields
Creator bool
Left bool
Broadcast bool
Verified bool
Megagroup bool
Restricted bool
Signatures bool
Min bool
Scam bool
HasLink bool
HasGeo bool
SlowmodeEnabled bool
CallActive bool
CallNotEmpty bool
Fake bool
Gigagroup bool
Noforwards bool
JoinToSend bool
JoinRequest bool
Forum bool
Flags2 bin .Fields
StoriesHidden bool
StoriesHiddenMin bool
StoriesUnavailable bool
ID int64
AccessHash int64
Title string
Username string
Photo ChatPhotoClass
Date int
RestrictionReason []RestrictionReason
AdminRights ChatAdminRights
BannedRights ChatBannedRights
DefaultBannedRights ChatBannedRights
ParticipantsCount int
Usernames []Username
StoriesMaxID int
Color PeerColor
ProfileColor PeerColor
EmojiStatus EmojiStatusClass
Level int
}
const ChannelTypeID = 0xaadfc8f
func (c Channel ) construct () ChatClass { return &c }
var (
_ bin .Encoder = &Channel {}
_ bin .Decoder = &Channel {}
_ bin .BareEncoder = &Channel {}
_ bin .BareDecoder = &Channel {}
_ ChatClass = &Channel {}
)
func (c *Channel ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .Creator == false ) {
return false
}
if !(c .Left == false ) {
return false
}
if !(c .Broadcast == false ) {
return false
}
if !(c .Verified == false ) {
return false
}
if !(c .Megagroup == false ) {
return false
}
if !(c .Restricted == false ) {
return false
}
if !(c .Signatures == false ) {
return false
}
if !(c .Min == false ) {
return false
}
if !(c .Scam == false ) {
return false
}
if !(c .HasLink == false ) {
return false
}
if !(c .HasGeo == false ) {
return false
}
if !(c .SlowmodeEnabled == false ) {
return false
}
if !(c .CallActive == false ) {
return false
}
if !(c .CallNotEmpty == false ) {
return false
}
if !(c .Fake == false ) {
return false
}
if !(c .Gigagroup == false ) {
return false
}
if !(c .Noforwards == false ) {
return false
}
if !(c .JoinToSend == false ) {
return false
}
if !(c .JoinRequest == false ) {
return false
}
if !(c .Forum == false ) {
return false
}
if !(c .Flags2 .Zero ()) {
return false
}
if !(c .StoriesHidden == false ) {
return false
}
if !(c .StoriesHiddenMin == false ) {
return false
}
if !(c .StoriesUnavailable == false ) {
return false
}
if !(c .ID == 0 ) {
return false
}
if !(c .AccessHash == 0 ) {
return false
}
if !(c .Title == "" ) {
return false
}
if !(c .Username == "" ) {
return false
}
if !(c .Photo == nil ) {
return false
}
if !(c .Date == 0 ) {
return false
}
if !(c .RestrictionReason == nil ) {
return false
}
if !(c .AdminRights .Zero ()) {
return false
}
if !(c .BannedRights .Zero ()) {
return false
}
if !(c .DefaultBannedRights .Zero ()) {
return false
}
if !(c .ParticipantsCount == 0 ) {
return false
}
if !(c .Usernames == nil ) {
return false
}
if !(c .StoriesMaxID == 0 ) {
return false
}
if !(c .Color .Zero ()) {
return false
}
if !(c .ProfileColor .Zero ()) {
return false
}
if !(c .EmojiStatus == nil ) {
return false
}
if !(c .Level == 0 ) {
return false
}
return true
}
func (c *Channel ) String () string {
if c == nil {
return "Channel(nil)"
}
type Alias Channel
return fmt .Sprintf ("Channel%+v" , Alias (*c ))
}
func (c *Channel ) FillFrom (from interface {
GetCreator () (value bool )
GetLeft () (value bool )
GetBroadcast () (value bool )
GetVerified () (value bool )
GetMegagroup () (value bool )
GetRestricted () (value bool )
GetSignatures () (value bool )
GetMin () (value bool )
GetScam () (value bool )
GetHasLink () (value bool )
GetHasGeo () (value bool )
GetSlowmodeEnabled () (value bool )
GetCallActive () (value bool )
GetCallNotEmpty () (value bool )
GetFake () (value bool )
GetGigagroup () (value bool )
GetNoforwards () (value bool )
GetJoinToSend () (value bool )
GetJoinRequest () (value bool )
GetForum () (value bool )
GetStoriesHidden () (value bool )
GetStoriesHiddenMin () (value bool )
GetStoriesUnavailable () (value bool )
GetID () (value int64 )
GetAccessHash () (value int64 , ok bool )
GetTitle () (value string )
GetUsername () (value string , ok bool )
GetPhoto () (value ChatPhotoClass )
GetDate () (value int )
GetRestrictionReason () (value []RestrictionReason , ok bool )
GetAdminRights () (value ChatAdminRights , ok bool )
GetBannedRights () (value ChatBannedRights , ok bool )
GetDefaultBannedRights () (value ChatBannedRights , ok bool )
GetParticipantsCount () (value int , ok bool )
GetUsernames () (value []Username , ok bool )
GetStoriesMaxID () (value int , ok bool )
GetColor () (value PeerColor , ok bool )
GetProfileColor () (value PeerColor , ok bool )
GetEmojiStatus () (value EmojiStatusClass , ok bool )
GetLevel () (value int , ok bool )
}) {
c .Creator = from .GetCreator ()
c .Left = from .GetLeft ()
c .Broadcast = from .GetBroadcast ()
c .Verified = from .GetVerified ()
c .Megagroup = from .GetMegagroup ()
c .Restricted = from .GetRestricted ()
c .Signatures = from .GetSignatures ()
c .Min = from .GetMin ()
c .Scam = from .GetScam ()
c .HasLink = from .GetHasLink ()
c .HasGeo = from .GetHasGeo ()
c .SlowmodeEnabled = from .GetSlowmodeEnabled ()
c .CallActive = from .GetCallActive ()
c .CallNotEmpty = from .GetCallNotEmpty ()
c .Fake = from .GetFake ()
c .Gigagroup = from .GetGigagroup ()
c .Noforwards = from .GetNoforwards ()
c .JoinToSend = from .GetJoinToSend ()
c .JoinRequest = from .GetJoinRequest ()
c .Forum = from .GetForum ()
c .StoriesHidden = from .GetStoriesHidden ()
c .StoriesHiddenMin = from .GetStoriesHiddenMin ()
c .StoriesUnavailable = from .GetStoriesUnavailable ()
c .ID = from .GetID ()
if val , ok := from .GetAccessHash (); ok {
c .AccessHash = val
}
c .Title = from .GetTitle ()
if val , ok := from .GetUsername (); ok {
c .Username = val
}
c .Photo = from .GetPhoto ()
c .Date = from .GetDate ()
if val , ok := from .GetRestrictionReason (); ok {
c .RestrictionReason = val
}
if val , ok := from .GetAdminRights (); ok {
c .AdminRights = val
}
if val , ok := from .GetBannedRights (); ok {
c .BannedRights = val
}
if val , ok := from .GetDefaultBannedRights (); ok {
c .DefaultBannedRights = val
}
if val , ok := from .GetParticipantsCount (); ok {
c .ParticipantsCount = val
}
if val , ok := from .GetUsernames (); ok {
c .Usernames = val
}
if val , ok := from .GetStoriesMaxID (); ok {
c .StoriesMaxID = val
}
if val , ok := from .GetColor (); ok {
c .Color = val
}
if val , ok := from .GetProfileColor (); ok {
c .ProfileColor = val
}
if val , ok := from .GetEmojiStatus (); ok {
c .EmojiStatus = val
}
if val , ok := from .GetLevel (); ok {
c .Level = val
}
}
func (*Channel ) TypeID () uint32 {
return ChannelTypeID
}
func (*Channel ) TypeName () string {
return "channel"
}
func (c *Channel ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "channel" ,
ID : ChannelTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Creator" ,
SchemaName : "creator" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "Left" ,
SchemaName : "left" ,
Null : !c .Flags .Has (2 ),
},
{
Name : "Broadcast" ,
SchemaName : "broadcast" ,
Null : !c .Flags .Has (5 ),
},
{
Name : "Verified" ,
SchemaName : "verified" ,
Null : !c .Flags .Has (7 ),
},
{
Name : "Megagroup" ,
SchemaName : "megagroup" ,
Null : !c .Flags .Has (8 ),
},
{
Name : "Restricted" ,
SchemaName : "restricted" ,
Null : !c .Flags .Has (9 ),
},
{
Name : "Signatures" ,
SchemaName : "signatures" ,
Null : !c .Flags .Has (11 ),
},
{
Name : "Min" ,
SchemaName : "min" ,
Null : !c .Flags .Has (12 ),
},
{
Name : "Scam" ,
SchemaName : "scam" ,
Null : !c .Flags .Has (19 ),
},
{
Name : "HasLink" ,
SchemaName : "has_link" ,
Null : !c .Flags .Has (20 ),
},
{
Name : "HasGeo" ,
SchemaName : "has_geo" ,
Null : !c .Flags .Has (21 ),
},
{
Name : "SlowmodeEnabled" ,
SchemaName : "slowmode_enabled" ,
Null : !c .Flags .Has (22 ),
},
{
Name : "CallActive" ,
SchemaName : "call_active" ,
Null : !c .Flags .Has (23 ),
},
{
Name : "CallNotEmpty" ,
SchemaName : "call_not_empty" ,
Null : !c .Flags .Has (24 ),
},
{
Name : "Fake" ,
SchemaName : "fake" ,
Null : !c .Flags .Has (25 ),
},
{
Name : "Gigagroup" ,
SchemaName : "gigagroup" ,
Null : !c .Flags .Has (26 ),
},
{
Name : "Noforwards" ,
SchemaName : "noforwards" ,
Null : !c .Flags .Has (27 ),
},
{
Name : "JoinToSend" ,
SchemaName : "join_to_send" ,
Null : !c .Flags .Has (28 ),
},
{
Name : "JoinRequest" ,
SchemaName : "join_request" ,
Null : !c .Flags .Has (29 ),
},
{
Name : "Forum" ,
SchemaName : "forum" ,
Null : !c .Flags .Has (30 ),
},
{
Name : "StoriesHidden" ,
SchemaName : "stories_hidden" ,
Null : !c .Flags2 .Has (1 ),
},
{
Name : "StoriesHiddenMin" ,
SchemaName : "stories_hidden_min" ,
Null : !c .Flags2 .Has (2 ),
},
{
Name : "StoriesUnavailable" ,
SchemaName : "stories_unavailable" ,
Null : !c .Flags2 .Has (3 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "AccessHash" ,
SchemaName : "access_hash" ,
Null : !c .Flags .Has (13 ),
},
{
Name : "Title" ,
SchemaName : "title" ,
},
{
Name : "Username" ,
SchemaName : "username" ,
Null : !c .Flags .Has (6 ),
},
{
Name : "Photo" ,
SchemaName : "photo" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "RestrictionReason" ,
SchemaName : "restriction_reason" ,
Null : !c .Flags .Has (9 ),
},
{
Name : "AdminRights" ,
SchemaName : "admin_rights" ,
Null : !c .Flags .Has (14 ),
},
{
Name : "BannedRights" ,
SchemaName : "banned_rights" ,
Null : !c .Flags .Has (15 ),
},
{
Name : "DefaultBannedRights" ,
SchemaName : "default_banned_rights" ,
Null : !c .Flags .Has (18 ),
},
{
Name : "ParticipantsCount" ,
SchemaName : "participants_count" ,
Null : !c .Flags .Has (17 ),
},
{
Name : "Usernames" ,
SchemaName : "usernames" ,
Null : !c .Flags2 .Has (0 ),
},
{
Name : "StoriesMaxID" ,
SchemaName : "stories_max_id" ,
Null : !c .Flags2 .Has (4 ),
},
{
Name : "Color" ,
SchemaName : "color" ,
Null : !c .Flags2 .Has (7 ),
},
{
Name : "ProfileColor" ,
SchemaName : "profile_color" ,
Null : !c .Flags2 .Has (8 ),
},
{
Name : "EmojiStatus" ,
SchemaName : "emoji_status" ,
Null : !c .Flags2 .Has (9 ),
},
{
Name : "Level" ,
SchemaName : "level" ,
Null : !c .Flags2 .Has (10 ),
},
}
return typ
}
func (c *Channel ) SetFlags () {
if !(c .Creator == false ) {
c .Flags .Set (0 )
}
if !(c .Left == false ) {
c .Flags .Set (2 )
}
if !(c .Broadcast == false ) {
c .Flags .Set (5 )
}
if !(c .Verified == false ) {
c .Flags .Set (7 )
}
if !(c .Megagroup == false ) {
c .Flags .Set (8 )
}
if !(c .Restricted == false ) {
c .Flags .Set (9 )
}
if !(c .Signatures == false ) {
c .Flags .Set (11 )
}
if !(c .Min == false ) {
c .Flags .Set (12 )
}
if !(c .Scam == false ) {
c .Flags .Set (19 )
}
if !(c .HasLink == false ) {
c .Flags .Set (20 )
}
if !(c .HasGeo == false ) {
c .Flags .Set (21 )
}
if !(c .SlowmodeEnabled == false ) {
c .Flags .Set (22 )
}
if !(c .CallActive == false ) {
c .Flags .Set (23 )
}
if !(c .CallNotEmpty == false ) {
c .Flags .Set (24 )
}
if !(c .Fake == false ) {
c .Flags .Set (25 )
}
if !(c .Gigagroup == false ) {
c .Flags .Set (26 )
}
if !(c .Noforwards == false ) {
c .Flags .Set (27 )
}
if !(c .JoinToSend == false ) {
c .Flags .Set (28 )
}
if !(c .JoinRequest == false ) {
c .Flags .Set (29 )
}
if !(c .Forum == false ) {
c .Flags .Set (30 )
}
if !(c .StoriesHidden == false ) {
c .Flags2 .Set (1 )
}
if !(c .StoriesHiddenMin == false ) {
c .Flags2 .Set (2 )
}
if !(c .StoriesUnavailable == false ) {
c .Flags2 .Set (3 )
}
if !(c .AccessHash == 0 ) {
c .Flags .Set (13 )
}
if !(c .Username == "" ) {
c .Flags .Set (6 )
}
if !(c .RestrictionReason == nil ) {
c .Flags .Set (9 )
}
if !(c .AdminRights .Zero ()) {
c .Flags .Set (14 )
}
if !(c .BannedRights .Zero ()) {
c .Flags .Set (15 )
}
if !(c .DefaultBannedRights .Zero ()) {
c .Flags .Set (18 )
}
if !(c .ParticipantsCount == 0 ) {
c .Flags .Set (17 )
}
if !(c .Usernames == nil ) {
c .Flags2 .Set (0 )
}
if !(c .StoriesMaxID == 0 ) {
c .Flags2 .Set (4 )
}
if !(c .Color .Zero ()) {
c .Flags2 .Set (7 )
}
if !(c .ProfileColor .Zero ()) {
c .Flags2 .Set (8 )
}
if !(c .EmojiStatus == nil ) {
c .Flags2 .Set (9 )
}
if !(c .Level == 0 ) {
c .Flags2 .Set (10 )
}
}
func (c *Channel ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode channel#aadfc8f as nil" )
}
b .PutID (ChannelTypeID )
return c .EncodeBare (b )
}
func (c *Channel ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode channel#aadfc8f as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channel#aadfc8f: field flags: %w" , err )
}
if err := c .Flags2 .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channel#aadfc8f: field flags2: %w" , err )
}
b .PutLong (c .ID )
if c .Flags .Has (13 ) {
b .PutLong (c .AccessHash )
}
b .PutString (c .Title )
if c .Flags .Has (6 ) {
b .PutString (c .Username )
}
if c .Photo == nil {
return fmt .Errorf ("unable to encode channel#aadfc8f: field photo is nil" )
}
if err := c .Photo .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channel#aadfc8f: field photo: %w" , err )
}
b .PutInt (c .Date )
if c .Flags .Has (9 ) {
b .PutVectorHeader (len (c .RestrictionReason ))
for idx , v := range c .RestrictionReason {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channel#aadfc8f: field restriction_reason element with index %d: %w" , idx , err )
}
}
}
if c .Flags .Has (14 ) {
if err := c .AdminRights .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channel#aadfc8f: field admin_rights: %w" , err )
}
}
if c .Flags .Has (15 ) {
if err := c .BannedRights .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channel#aadfc8f: field banned_rights: %w" , err )
}
}
if c .Flags .Has (18 ) {
if err := c .DefaultBannedRights .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channel#aadfc8f: field default_banned_rights: %w" , err )
}
}
if c .Flags .Has (17 ) {
b .PutInt (c .ParticipantsCount )
}
if c .Flags2 .Has (0 ) {
b .PutVectorHeader (len (c .Usernames ))
for idx , v := range c .Usernames {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channel#aadfc8f: field usernames element with index %d: %w" , idx , err )
}
}
}
if c .Flags2 .Has (4 ) {
b .PutInt (c .StoriesMaxID )
}
if c .Flags2 .Has (7 ) {
if err := c .Color .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channel#aadfc8f: field color: %w" , err )
}
}
if c .Flags2 .Has (8 ) {
if err := c .ProfileColor .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channel#aadfc8f: field profile_color: %w" , err )
}
}
if c .Flags2 .Has (9 ) {
if c .EmojiStatus == nil {
return fmt .Errorf ("unable to encode channel#aadfc8f: field emoji_status is nil" )
}
if err := c .EmojiStatus .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channel#aadfc8f: field emoji_status: %w" , err )
}
}
if c .Flags2 .Has (10 ) {
b .PutInt (c .Level )
}
return nil
}
func (c *Channel ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode channel#aadfc8f to nil" )
}
if err := b .ConsumeID (ChannelTypeID ); err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: %w" , err )
}
return c .DecodeBare (b )
}
func (c *Channel ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode channel#aadfc8f to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: field flags: %w" , err )
}
}
c .Creator = c .Flags .Has (0 )
c .Left = c .Flags .Has (2 )
c .Broadcast = c .Flags .Has (5 )
c .Verified = c .Flags .Has (7 )
c .Megagroup = c .Flags .Has (8 )
c .Restricted = c .Flags .Has (9 )
c .Signatures = c .Flags .Has (11 )
c .Min = c .Flags .Has (12 )
c .Scam = c .Flags .Has (19 )
c .HasLink = c .Flags .Has (20 )
c .HasGeo = c .Flags .Has (21 )
c .SlowmodeEnabled = c .Flags .Has (22 )
c .CallActive = c .Flags .Has (23 )
c .CallNotEmpty = c .Flags .Has (24 )
c .Fake = c .Flags .Has (25 )
c .Gigagroup = c .Flags .Has (26 )
c .Noforwards = c .Flags .Has (27 )
c .JoinToSend = c .Flags .Has (28 )
c .JoinRequest = c .Flags .Has (29 )
c .Forum = c .Flags .Has (30 )
{
if err := c .Flags2 .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: field flags2: %w" , err )
}
}
c .StoriesHidden = c .Flags2 .Has (1 )
c .StoriesHiddenMin = c .Flags2 .Has (2 )
c .StoriesUnavailable = c .Flags2 .Has (3 )
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: field id: %w" , err )
}
c .ID = value
}
if c .Flags .Has (13 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: field access_hash: %w" , err )
}
c .AccessHash = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: field title: %w" , err )
}
c .Title = value
}
if c .Flags .Has (6 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: field username: %w" , err )
}
c .Username = value
}
{
value , err := DecodeChatPhoto (b )
if err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: field photo: %w" , err )
}
c .Photo = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: field date: %w" , err )
}
c .Date = value
}
if c .Flags .Has (9 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: field restriction_reason: %w" , err )
}
if headerLen > 0 {
c .RestrictionReason = make ([]RestrictionReason , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value RestrictionReason
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: field restriction_reason: %w" , err )
}
c .RestrictionReason = append (c .RestrictionReason , value )
}
}
if c .Flags .Has (14 ) {
if err := c .AdminRights .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: field admin_rights: %w" , err )
}
}
if c .Flags .Has (15 ) {
if err := c .BannedRights .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: field banned_rights: %w" , err )
}
}
if c .Flags .Has (18 ) {
if err := c .DefaultBannedRights .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: field default_banned_rights: %w" , err )
}
}
if c .Flags .Has (17 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: field participants_count: %w" , err )
}
c .ParticipantsCount = value
}
if c .Flags2 .Has (0 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: field usernames: %w" , err )
}
if headerLen > 0 {
c .Usernames = make ([]Username , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value Username
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: field usernames: %w" , err )
}
c .Usernames = append (c .Usernames , value )
}
}
if c .Flags2 .Has (4 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: field stories_max_id: %w" , err )
}
c .StoriesMaxID = value
}
if c .Flags2 .Has (7 ) {
if err := c .Color .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: field color: %w" , err )
}
}
if c .Flags2 .Has (8 ) {
if err := c .ProfileColor .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: field profile_color: %w" , err )
}
}
if c .Flags2 .Has (9 ) {
value , err := DecodeEmojiStatus (b )
if err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: field emoji_status: %w" , err )
}
c .EmojiStatus = value
}
if c .Flags2 .Has (10 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode channel#aadfc8f: field level: %w" , err )
}
c .Level = value
}
return nil
}
func (c *Channel ) SetCreator (value bool ) {
if value {
c .Flags .Set (0 )
c .Creator = true
} else {
c .Flags .Unset (0 )
c .Creator = false
}
}
func (c *Channel ) GetCreator () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (0 )
}
func (c *Channel ) SetLeft (value bool ) {
if value {
c .Flags .Set (2 )
c .Left = true
} else {
c .Flags .Unset (2 )
c .Left = false
}
}
func (c *Channel ) GetLeft () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (2 )
}
func (c *Channel ) SetBroadcast (value bool ) {
if value {
c .Flags .Set (5 )
c .Broadcast = true
} else {
c .Flags .Unset (5 )
c .Broadcast = false
}
}
func (c *Channel ) GetBroadcast () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (5 )
}
func (c *Channel ) SetVerified (value bool ) {
if value {
c .Flags .Set (7 )
c .Verified = true
} else {
c .Flags .Unset (7 )
c .Verified = false
}
}
func (c *Channel ) GetVerified () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (7 )
}
func (c *Channel ) SetMegagroup (value bool ) {
if value {
c .Flags .Set (8 )
c .Megagroup = true
} else {
c .Flags .Unset (8 )
c .Megagroup = false
}
}
func (c *Channel ) GetMegagroup () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (8 )
}
func (c *Channel ) SetRestricted (value bool ) {
if value {
c .Flags .Set (9 )
c .Restricted = true
} else {
c .Flags .Unset (9 )
c .Restricted = false
}
}
func (c *Channel ) GetRestricted () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (9 )
}
func (c *Channel ) SetSignatures (value bool ) {
if value {
c .Flags .Set (11 )
c .Signatures = true
} else {
c .Flags .Unset (11 )
c .Signatures = false
}
}
func (c *Channel ) GetSignatures () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (11 )
}
func (c *Channel ) SetMin (value bool ) {
if value {
c .Flags .Set (12 )
c .Min = true
} else {
c .Flags .Unset (12 )
c .Min = false
}
}
func (c *Channel ) GetMin () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (12 )
}
func (c *Channel ) SetScam (value bool ) {
if value {
c .Flags .Set (19 )
c .Scam = true
} else {
c .Flags .Unset (19 )
c .Scam = false
}
}
func (c *Channel ) GetScam () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (19 )
}
func (c *Channel ) SetHasLink (value bool ) {
if value {
c .Flags .Set (20 )
c .HasLink = true
} else {
c .Flags .Unset (20 )
c .HasLink = false
}
}
func (c *Channel ) GetHasLink () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (20 )
}
func (c *Channel ) SetHasGeo (value bool ) {
if value {
c .Flags .Set (21 )
c .HasGeo = true
} else {
c .Flags .Unset (21 )
c .HasGeo = false
}
}
func (c *Channel ) GetHasGeo () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (21 )
}
func (c *Channel ) SetSlowmodeEnabled (value bool ) {
if value {
c .Flags .Set (22 )
c .SlowmodeEnabled = true
} else {
c .Flags .Unset (22 )
c .SlowmodeEnabled = false
}
}
func (c *Channel ) GetSlowmodeEnabled () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (22 )
}
func (c *Channel ) SetCallActive (value bool ) {
if value {
c .Flags .Set (23 )
c .CallActive = true
} else {
c .Flags .Unset (23 )
c .CallActive = false
}
}
func (c *Channel ) GetCallActive () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (23 )
}
func (c *Channel ) SetCallNotEmpty (value bool ) {
if value {
c .Flags .Set (24 )
c .CallNotEmpty = true
} else {
c .Flags .Unset (24 )
c .CallNotEmpty = false
}
}
func (c *Channel ) GetCallNotEmpty () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (24 )
}
func (c *Channel ) SetFake (value bool ) {
if value {
c .Flags .Set (25 )
c .Fake = true
} else {
c .Flags .Unset (25 )
c .Fake = false
}
}
func (c *Channel ) GetFake () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (25 )
}
func (c *Channel ) SetGigagroup (value bool ) {
if value {
c .Flags .Set (26 )
c .Gigagroup = true
} else {
c .Flags .Unset (26 )
c .Gigagroup = false
}
}
func (c *Channel ) GetGigagroup () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (26 )
}
func (c *Channel ) SetNoforwards (value bool ) {
if value {
c .Flags .Set (27 )
c .Noforwards = true
} else {
c .Flags .Unset (27 )
c .Noforwards = false
}
}
func (c *Channel ) GetNoforwards () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (27 )
}
func (c *Channel ) SetJoinToSend (value bool ) {
if value {
c .Flags .Set (28 )
c .JoinToSend = true
} else {
c .Flags .Unset (28 )
c .JoinToSend = false
}
}
func (c *Channel ) GetJoinToSend () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (28 )
}
func (c *Channel ) SetJoinRequest (value bool ) {
if value {
c .Flags .Set (29 )
c .JoinRequest = true
} else {
c .Flags .Unset (29 )
c .JoinRequest = false
}
}
func (c *Channel ) GetJoinRequest () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (29 )
}
func (c *Channel ) SetForum (value bool ) {
if value {
c .Flags .Set (30 )
c .Forum = true
} else {
c .Flags .Unset (30 )
c .Forum = false
}
}
func (c *Channel ) GetForum () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (30 )
}
func (c *Channel ) SetStoriesHidden (value bool ) {
if value {
c .Flags2 .Set (1 )
c .StoriesHidden = true
} else {
c .Flags2 .Unset (1 )
c .StoriesHidden = false
}
}
func (c *Channel ) GetStoriesHidden () (value bool ) {
if c == nil {
return
}
return c .Flags2 .Has (1 )
}
func (c *Channel ) SetStoriesHiddenMin (value bool ) {
if value {
c .Flags2 .Set (2 )
c .StoriesHiddenMin = true
} else {
c .Flags2 .Unset (2 )
c .StoriesHiddenMin = false
}
}
func (c *Channel ) GetStoriesHiddenMin () (value bool ) {
if c == nil {
return
}
return c .Flags2 .Has (2 )
}
func (c *Channel ) SetStoriesUnavailable (value bool ) {
if value {
c .Flags2 .Set (3 )
c .StoriesUnavailable = true
} else {
c .Flags2 .Unset (3 )
c .StoriesUnavailable = false
}
}
func (c *Channel ) GetStoriesUnavailable () (value bool ) {
if c == nil {
return
}
return c .Flags2 .Has (3 )
}
func (c *Channel ) GetID () (value int64 ) {
if c == nil {
return
}
return c .ID
}
func (c *Channel ) SetAccessHash (value int64 ) {
c .Flags .Set (13 )
c .AccessHash = value
}
func (c *Channel ) GetAccessHash () (value int64 , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (13 ) {
return value , false
}
return c .AccessHash , true
}
func (c *Channel ) GetTitle () (value string ) {
if c == nil {
return
}
return c .Title
}
func (c *Channel ) SetUsername (value string ) {
c .Flags .Set (6 )
c .Username = value
}
func (c *Channel ) GetUsername () (value string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (6 ) {
return value , false
}
return c .Username , true
}
func (c *Channel ) GetPhoto () (value ChatPhotoClass ) {
if c == nil {
return
}
return c .Photo
}
func (c *Channel ) GetDate () (value int ) {
if c == nil {
return
}
return c .Date
}
func (c *Channel ) SetRestrictionReason (value []RestrictionReason ) {
c .Flags .Set (9 )
c .RestrictionReason = value
}
func (c *Channel ) GetRestrictionReason () (value []RestrictionReason , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (9 ) {
return value , false
}
return c .RestrictionReason , true
}
func (c *Channel ) SetAdminRights (value ChatAdminRights ) {
c .Flags .Set (14 )
c .AdminRights = value
}
func (c *Channel ) GetAdminRights () (value ChatAdminRights , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (14 ) {
return value , false
}
return c .AdminRights , true
}
func (c *Channel ) SetBannedRights (value ChatBannedRights ) {
c .Flags .Set (15 )
c .BannedRights = value
}
func (c *Channel ) GetBannedRights () (value ChatBannedRights , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (15 ) {
return value , false
}
return c .BannedRights , true
}
func (c *Channel ) SetDefaultBannedRights (value ChatBannedRights ) {
c .Flags .Set (18 )
c .DefaultBannedRights = value
}
func (c *Channel ) GetDefaultBannedRights () (value ChatBannedRights , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (18 ) {
return value , false
}
return c .DefaultBannedRights , true
}
func (c *Channel ) SetParticipantsCount (value int ) {
c .Flags .Set (17 )
c .ParticipantsCount = value
}
func (c *Channel ) GetParticipantsCount () (value int , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (17 ) {
return value , false
}
return c .ParticipantsCount , true
}
func (c *Channel ) SetUsernames (value []Username ) {
c .Flags2 .Set (0 )
c .Usernames = value
}
func (c *Channel ) GetUsernames () (value []Username , ok bool ) {
if c == nil {
return
}
if !c .Flags2 .Has (0 ) {
return value , false
}
return c .Usernames , true
}
func (c *Channel ) SetStoriesMaxID (value int ) {
c .Flags2 .Set (4 )
c .StoriesMaxID = value
}
func (c *Channel ) GetStoriesMaxID () (value int , ok bool ) {
if c == nil {
return
}
if !c .Flags2 .Has (4 ) {
return value , false
}
return c .StoriesMaxID , true
}
func (c *Channel ) SetColor (value PeerColor ) {
c .Flags2 .Set (7 )
c .Color = value
}
func (c *Channel ) GetColor () (value PeerColor , ok bool ) {
if c == nil {
return
}
if !c .Flags2 .Has (7 ) {
return value , false
}
return c .Color , true
}
func (c *Channel ) SetProfileColor (value PeerColor ) {
c .Flags2 .Set (8 )
c .ProfileColor = value
}
func (c *Channel ) GetProfileColor () (value PeerColor , ok bool ) {
if c == nil {
return
}
if !c .Flags2 .Has (8 ) {
return value , false
}
return c .ProfileColor , true
}
func (c *Channel ) SetEmojiStatus (value EmojiStatusClass ) {
c .Flags2 .Set (9 )
c .EmojiStatus = value
}
func (c *Channel ) GetEmojiStatus () (value EmojiStatusClass , ok bool ) {
if c == nil {
return
}
if !c .Flags2 .Has (9 ) {
return value , false
}
return c .EmojiStatus , true
}
func (c *Channel ) SetLevel (value int ) {
c .Flags2 .Set (10 )
c .Level = value
}
func (c *Channel ) GetLevel () (value int , ok bool ) {
if c == nil {
return
}
if !c .Flags2 .Has (10 ) {
return value , false
}
return c .Level , true
}
type ChannelForbidden struct {
Flags bin .Fields
Broadcast bool
Megagroup bool
ID int64
AccessHash int64
Title string
UntilDate int
}
const ChannelForbiddenTypeID = 0x17d493d5
func (c ChannelForbidden ) construct () ChatClass { return &c }
var (
_ bin .Encoder = &ChannelForbidden {}
_ bin .Decoder = &ChannelForbidden {}
_ bin .BareEncoder = &ChannelForbidden {}
_ bin .BareDecoder = &ChannelForbidden {}
_ ChatClass = &ChannelForbidden {}
)
func (c *ChannelForbidden ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .Broadcast == false ) {
return false
}
if !(c .Megagroup == false ) {
return false
}
if !(c .ID == 0 ) {
return false
}
if !(c .AccessHash == 0 ) {
return false
}
if !(c .Title == "" ) {
return false
}
if !(c .UntilDate == 0 ) {
return false
}
return true
}
func (c *ChannelForbidden ) String () string {
if c == nil {
return "ChannelForbidden(nil)"
}
type Alias ChannelForbidden
return fmt .Sprintf ("ChannelForbidden%+v" , Alias (*c ))
}
func (c *ChannelForbidden ) FillFrom (from interface {
GetBroadcast () (value bool )
GetMegagroup () (value bool )
GetID () (value int64 )
GetAccessHash () (value int64 )
GetTitle () (value string )
GetUntilDate () (value int , ok bool )
}) {
c .Broadcast = from .GetBroadcast ()
c .Megagroup = from .GetMegagroup ()
c .ID = from .GetID ()
c .AccessHash = from .GetAccessHash ()
c .Title = from .GetTitle ()
if val , ok := from .GetUntilDate (); ok {
c .UntilDate = val
}
}
func (*ChannelForbidden ) TypeID () uint32 {
return ChannelForbiddenTypeID
}
func (*ChannelForbidden ) TypeName () string {
return "channelForbidden"
}
func (c *ChannelForbidden ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "channelForbidden" ,
ID : ChannelForbiddenTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Broadcast" ,
SchemaName : "broadcast" ,
Null : !c .Flags .Has (5 ),
},
{
Name : "Megagroup" ,
SchemaName : "megagroup" ,
Null : !c .Flags .Has (8 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "AccessHash" ,
SchemaName : "access_hash" ,
},
{
Name : "Title" ,
SchemaName : "title" ,
},
{
Name : "UntilDate" ,
SchemaName : "until_date" ,
Null : !c .Flags .Has (16 ),
},
}
return typ
}
func (c *ChannelForbidden ) SetFlags () {
if !(c .Broadcast == false ) {
c .Flags .Set (5 )
}
if !(c .Megagroup == false ) {
c .Flags .Set (8 )
}
if !(c .UntilDate == 0 ) {
c .Flags .Set (16 )
}
}
func (c *ChannelForbidden ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode channelForbidden#17d493d5 as nil" )
}
b .PutID (ChannelForbiddenTypeID )
return c .EncodeBare (b )
}
func (c *ChannelForbidden ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode channelForbidden#17d493d5 as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channelForbidden#17d493d5: field flags: %w" , err )
}
b .PutLong (c .ID )
b .PutLong (c .AccessHash )
b .PutString (c .Title )
if c .Flags .Has (16 ) {
b .PutInt (c .UntilDate )
}
return nil
}
func (c *ChannelForbidden ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode channelForbidden#17d493d5 to nil" )
}
if err := b .ConsumeID (ChannelForbiddenTypeID ); err != nil {
return fmt .Errorf ("unable to decode channelForbidden#17d493d5: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChannelForbidden ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode channelForbidden#17d493d5 to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode channelForbidden#17d493d5: field flags: %w" , err )
}
}
c .Broadcast = c .Flags .Has (5 )
c .Megagroup = c .Flags .Has (8 )
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode channelForbidden#17d493d5: field id: %w" , err )
}
c .ID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode channelForbidden#17d493d5: field access_hash: %w" , err )
}
c .AccessHash = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode channelForbidden#17d493d5: field title: %w" , err )
}
c .Title = value
}
if c .Flags .Has (16 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode channelForbidden#17d493d5: field until_date: %w" , err )
}
c .UntilDate = value
}
return nil
}
func (c *ChannelForbidden ) SetBroadcast (value bool ) {
if value {
c .Flags .Set (5 )
c .Broadcast = true
} else {
c .Flags .Unset (5 )
c .Broadcast = false
}
}
func (c *ChannelForbidden ) GetBroadcast () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (5 )
}
func (c *ChannelForbidden ) SetMegagroup (value bool ) {
if value {
c .Flags .Set (8 )
c .Megagroup = true
} else {
c .Flags .Unset (8 )
c .Megagroup = false
}
}
func (c *ChannelForbidden ) GetMegagroup () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (8 )
}
func (c *ChannelForbidden ) GetID () (value int64 ) {
if c == nil {
return
}
return c .ID
}
func (c *ChannelForbidden ) GetAccessHash () (value int64 ) {
if c == nil {
return
}
return c .AccessHash
}
func (c *ChannelForbidden ) GetTitle () (value string ) {
if c == nil {
return
}
return c .Title
}
func (c *ChannelForbidden ) SetUntilDate (value int ) {
c .Flags .Set (16 )
c .UntilDate = value
}
func (c *ChannelForbidden ) GetUntilDate () (value int , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (16 ) {
return value , false
}
return c .UntilDate , true
}
const ChatClassName = "Chat"
type ChatClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () ChatClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetID () (value int64 )
AsNotEmpty () (NotEmptyChat , bool )
AsNotForbidden () (NotForbiddenChat , bool )
AsFull () (FullChat , bool )
}
func (c *Chat ) AsInputPeer () *InputPeerChat {
value := new (InputPeerChat )
value .ChatID = c .GetID ()
return value
}
func (c *Channel ) AsInputPeer () *InputPeerChannel {
value := new (InputPeerChannel )
value .ChannelID = c .GetID ()
if fieldValue , ok := c .GetAccessHash (); ok {
value .AccessHash = fieldValue
}
return value
}
func (c *Channel ) AsInput () *InputChannel {
value := new (InputChannel )
value .ChannelID = c .GetID ()
if fieldValue , ok := c .GetAccessHash (); ok {
value .AccessHash = fieldValue
}
return value
}
type NotEmptyChat interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () ChatClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetID () (value int64 )
GetTitle () (value string )
}
func (c *ChatEmpty ) AsNotEmpty () (NotEmptyChat , bool ) {
value , ok := (ChatClass (c )).(NotEmptyChat )
return value , ok
}
func (c *Chat ) AsNotEmpty () (NotEmptyChat , bool ) {
value , ok := (ChatClass (c )).(NotEmptyChat )
return value , ok
}
func (c *ChatForbidden ) AsNotEmpty () (NotEmptyChat , bool ) {
value , ok := (ChatClass (c )).(NotEmptyChat )
return value , ok
}
func (c *Channel ) AsNotEmpty () (NotEmptyChat , bool ) {
value , ok := (ChatClass (c )).(NotEmptyChat )
return value , ok
}
func (c *ChannelForbidden ) AsNotEmpty () (NotEmptyChat , bool ) {
value , ok := (ChatClass (c )).(NotEmptyChat )
return value , ok
}
type NotForbiddenChat interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () ChatClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetID () (value int64 )
}
func (c *ChatEmpty ) AsNotForbidden () (NotForbiddenChat , bool ) {
value , ok := (ChatClass (c )).(NotForbiddenChat )
return value , ok
}
func (c *Chat ) AsNotForbidden () (NotForbiddenChat , bool ) {
value , ok := (ChatClass (c )).(NotForbiddenChat )
return value , ok
}
func (c *ChatForbidden ) AsNotForbidden () (NotForbiddenChat , bool ) {
value , ok := (ChatClass (c )).(NotForbiddenChat )
return value , ok
}
func (c *Channel ) AsNotForbidden () (NotForbiddenChat , bool ) {
value , ok := (ChatClass (c )).(NotForbiddenChat )
return value , ok
}
func (c *ChannelForbidden ) AsNotForbidden () (NotForbiddenChat , bool ) {
value , ok := (ChatClass (c )).(NotForbiddenChat )
return value , ok
}
type FullChat interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () ChatClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetCreator () (value bool )
GetLeft () (value bool )
GetCallActive () (value bool )
GetCallNotEmpty () (value bool )
GetNoforwards () (value bool )
GetID () (value int64 )
GetTitle () (value string )
GetPhoto () (value ChatPhotoClass )
GetDate () (value int )
GetAdminRights () (value ChatAdminRights , ok bool )
GetDefaultBannedRights () (value ChatBannedRights , ok bool )
}
func (c *ChatEmpty ) AsFull () (FullChat , bool ) {
value , ok := (ChatClass (c )).(FullChat )
return value , ok
}
func (c *Chat ) AsFull () (FullChat , bool ) {
value , ok := (ChatClass (c )).(FullChat )
return value , ok
}
func (c *ChatForbidden ) AsFull () (FullChat , bool ) {
value , ok := (ChatClass (c )).(FullChat )
return value , ok
}
func (c *Channel ) AsFull () (FullChat , bool ) {
value , ok := (ChatClass (c )).(FullChat )
return value , ok
}
func (c *ChannelForbidden ) AsFull () (FullChat , bool ) {
value , ok := (ChatClass (c )).(FullChat )
return value , ok
}
func DecodeChat (buf *bin .Buffer ) (ChatClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case ChatEmptyTypeID :
v := ChatEmpty {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChatClass: %w" , err )
}
return &v , nil
case ChatTypeID :
v := Chat {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChatClass: %w" , err )
}
return &v , nil
case ChatForbiddenTypeID :
v := ChatForbidden {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChatClass: %w" , err )
}
return &v , nil
case ChannelTypeID :
v := Channel {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChatClass: %w" , err )
}
return &v , nil
case ChannelForbiddenTypeID :
v := ChannelForbidden {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChatClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode ChatClass: %w" , bin .NewUnexpectedID (id ))
}
}
type ChatBox struct {
Chat ChatClass
}
func (b *ChatBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode ChatBox to nil" )
}
v , err := DecodeChat (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .Chat = v
return nil
}
func (b *ChatBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .Chat == nil {
return fmt .Errorf ("unable to encode ChatClass as nil" )
}
return b .Chat .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 .