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 UserEmpty struct {
ID int64
}
const UserEmptyTypeID = 0xd3bc4b7a
func (u UserEmpty ) construct () UserClass { return &u }
var (
_ bin .Encoder = &UserEmpty {}
_ bin .Decoder = &UserEmpty {}
_ bin .BareEncoder = &UserEmpty {}
_ bin .BareDecoder = &UserEmpty {}
_ UserClass = &UserEmpty {}
)
func (u *UserEmpty ) Zero () bool {
if u == nil {
return true
}
if !(u .ID == 0 ) {
return false
}
return true
}
func (u *UserEmpty ) String () string {
if u == nil {
return "UserEmpty(nil)"
}
type Alias UserEmpty
return fmt .Sprintf ("UserEmpty%+v" , Alias (*u ))
}
func (u *UserEmpty ) FillFrom (from interface {
GetID () (value int64 )
}) {
u .ID = from .GetID ()
}
func (*UserEmpty ) TypeID () uint32 {
return UserEmptyTypeID
}
func (*UserEmpty ) TypeName () string {
return "userEmpty"
}
func (u *UserEmpty ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "userEmpty" ,
ID : UserEmptyTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
}
return typ
}
func (u *UserEmpty ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode userEmpty#d3bc4b7a as nil" )
}
b .PutID (UserEmptyTypeID )
return u .EncodeBare (b )
}
func (u *UserEmpty ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode userEmpty#d3bc4b7a as nil" )
}
b .PutLong (u .ID )
return nil
}
func (u *UserEmpty ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode userEmpty#d3bc4b7a to nil" )
}
if err := b .ConsumeID (UserEmptyTypeID ); err != nil {
return fmt .Errorf ("unable to decode userEmpty#d3bc4b7a: %w" , err )
}
return u .DecodeBare (b )
}
func (u *UserEmpty ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode userEmpty#d3bc4b7a to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode userEmpty#d3bc4b7a: field id: %w" , err )
}
u .ID = value
}
return nil
}
func (u *UserEmpty ) GetID () (value int64 ) {
if u == nil {
return
}
return u .ID
}
type User struct {
Flags bin .Fields
Self bool
Contact bool
MutualContact bool
Deleted bool
Bot bool
BotChatHistory bool
BotNochats bool
Verified bool
Restricted bool
Min bool
BotInlineGeo bool
Support bool
Scam bool
ApplyMinPhoto bool
Fake bool
BotAttachMenu bool
Premium bool
AttachMenuEnabled bool
Flags2 bin .Fields
BotCanEdit bool
CloseFriend bool
StoriesHidden bool
StoriesUnavailable bool
ID int64
AccessHash int64
FirstName string
LastName string
Username string
Phone string
Photo UserProfilePhotoClass
Status UserStatusClass
BotInfoVersion int
RestrictionReason []RestrictionReason
BotInlinePlaceholder string
LangCode string
EmojiStatus EmojiStatusClass
Usernames []Username
StoriesMaxID int
Color PeerColor
ProfileColor PeerColor
}
const UserTypeID = 0x215c4438
func (u User ) construct () UserClass { return &u }
var (
_ bin .Encoder = &User {}
_ bin .Decoder = &User {}
_ bin .BareEncoder = &User {}
_ bin .BareDecoder = &User {}
_ UserClass = &User {}
)
func (u *User ) Zero () bool {
if u == nil {
return true
}
if !(u .Flags .Zero ()) {
return false
}
if !(u .Self == false ) {
return false
}
if !(u .Contact == false ) {
return false
}
if !(u .MutualContact == false ) {
return false
}
if !(u .Deleted == false ) {
return false
}
if !(u .Bot == false ) {
return false
}
if !(u .BotChatHistory == false ) {
return false
}
if !(u .BotNochats == false ) {
return false
}
if !(u .Verified == false ) {
return false
}
if !(u .Restricted == false ) {
return false
}
if !(u .Min == false ) {
return false
}
if !(u .BotInlineGeo == false ) {
return false
}
if !(u .Support == false ) {
return false
}
if !(u .Scam == false ) {
return false
}
if !(u .ApplyMinPhoto == false ) {
return false
}
if !(u .Fake == false ) {
return false
}
if !(u .BotAttachMenu == false ) {
return false
}
if !(u .Premium == false ) {
return false
}
if !(u .AttachMenuEnabled == false ) {
return false
}
if !(u .Flags2 .Zero ()) {
return false
}
if !(u .BotCanEdit == false ) {
return false
}
if !(u .CloseFriend == false ) {
return false
}
if !(u .StoriesHidden == false ) {
return false
}
if !(u .StoriesUnavailable == false ) {
return false
}
if !(u .ID == 0 ) {
return false
}
if !(u .AccessHash == 0 ) {
return false
}
if !(u .FirstName == "" ) {
return false
}
if !(u .LastName == "" ) {
return false
}
if !(u .Username == "" ) {
return false
}
if !(u .Phone == "" ) {
return false
}
if !(u .Photo == nil ) {
return false
}
if !(u .Status == nil ) {
return false
}
if !(u .BotInfoVersion == 0 ) {
return false
}
if !(u .RestrictionReason == nil ) {
return false
}
if !(u .BotInlinePlaceholder == "" ) {
return false
}
if !(u .LangCode == "" ) {
return false
}
if !(u .EmojiStatus == nil ) {
return false
}
if !(u .Usernames == nil ) {
return false
}
if !(u .StoriesMaxID == 0 ) {
return false
}
if !(u .Color .Zero ()) {
return false
}
if !(u .ProfileColor .Zero ()) {
return false
}
return true
}
func (u *User ) String () string {
if u == nil {
return "User(nil)"
}
type Alias User
return fmt .Sprintf ("User%+v" , Alias (*u ))
}
func (u *User ) FillFrom (from interface {
GetSelf () (value bool )
GetContact () (value bool )
GetMutualContact () (value bool )
GetDeleted () (value bool )
GetBot () (value bool )
GetBotChatHistory () (value bool )
GetBotNochats () (value bool )
GetVerified () (value bool )
GetRestricted () (value bool )
GetMin () (value bool )
GetBotInlineGeo () (value bool )
GetSupport () (value bool )
GetScam () (value bool )
GetApplyMinPhoto () (value bool )
GetFake () (value bool )
GetBotAttachMenu () (value bool )
GetPremium () (value bool )
GetAttachMenuEnabled () (value bool )
GetBotCanEdit () (value bool )
GetCloseFriend () (value bool )
GetStoriesHidden () (value bool )
GetStoriesUnavailable () (value bool )
GetID () (value int64 )
GetAccessHash () (value int64 , ok bool )
GetFirstName () (value string , ok bool )
GetLastName () (value string , ok bool )
GetUsername () (value string , ok bool )
GetPhone () (value string , ok bool )
GetPhoto () (value UserProfilePhotoClass , ok bool )
GetStatus () (value UserStatusClass , ok bool )
GetBotInfoVersion () (value int , ok bool )
GetRestrictionReason () (value []RestrictionReason , ok bool )
GetBotInlinePlaceholder () (value string , ok bool )
GetLangCode () (value string , ok bool )
GetEmojiStatus () (value EmojiStatusClass , ok bool )
GetUsernames () (value []Username , ok bool )
GetStoriesMaxID () (value int , ok bool )
GetColor () (value PeerColor , ok bool )
GetProfileColor () (value PeerColor , ok bool )
}) {
u .Self = from .GetSelf ()
u .Contact = from .GetContact ()
u .MutualContact = from .GetMutualContact ()
u .Deleted = from .GetDeleted ()
u .Bot = from .GetBot ()
u .BotChatHistory = from .GetBotChatHistory ()
u .BotNochats = from .GetBotNochats ()
u .Verified = from .GetVerified ()
u .Restricted = from .GetRestricted ()
u .Min = from .GetMin ()
u .BotInlineGeo = from .GetBotInlineGeo ()
u .Support = from .GetSupport ()
u .Scam = from .GetScam ()
u .ApplyMinPhoto = from .GetApplyMinPhoto ()
u .Fake = from .GetFake ()
u .BotAttachMenu = from .GetBotAttachMenu ()
u .Premium = from .GetPremium ()
u .AttachMenuEnabled = from .GetAttachMenuEnabled ()
u .BotCanEdit = from .GetBotCanEdit ()
u .CloseFriend = from .GetCloseFriend ()
u .StoriesHidden = from .GetStoriesHidden ()
u .StoriesUnavailable = from .GetStoriesUnavailable ()
u .ID = from .GetID ()
if val , ok := from .GetAccessHash (); ok {
u .AccessHash = val
}
if val , ok := from .GetFirstName (); ok {
u .FirstName = val
}
if val , ok := from .GetLastName (); ok {
u .LastName = val
}
if val , ok := from .GetUsername (); ok {
u .Username = val
}
if val , ok := from .GetPhone (); ok {
u .Phone = val
}
if val , ok := from .GetPhoto (); ok {
u .Photo = val
}
if val , ok := from .GetStatus (); ok {
u .Status = val
}
if val , ok := from .GetBotInfoVersion (); ok {
u .BotInfoVersion = val
}
if val , ok := from .GetRestrictionReason (); ok {
u .RestrictionReason = val
}
if val , ok := from .GetBotInlinePlaceholder (); ok {
u .BotInlinePlaceholder = val
}
if val , ok := from .GetLangCode (); ok {
u .LangCode = val
}
if val , ok := from .GetEmojiStatus (); ok {
u .EmojiStatus = val
}
if val , ok := from .GetUsernames (); ok {
u .Usernames = val
}
if val , ok := from .GetStoriesMaxID (); ok {
u .StoriesMaxID = val
}
if val , ok := from .GetColor (); ok {
u .Color = val
}
if val , ok := from .GetProfileColor (); ok {
u .ProfileColor = val
}
}
func (*User ) TypeID () uint32 {
return UserTypeID
}
func (*User ) TypeName () string {
return "user"
}
func (u *User ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "user" ,
ID : UserTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Self" ,
SchemaName : "self" ,
Null : !u .Flags .Has (10 ),
},
{
Name : "Contact" ,
SchemaName : "contact" ,
Null : !u .Flags .Has (11 ),
},
{
Name : "MutualContact" ,
SchemaName : "mutual_contact" ,
Null : !u .Flags .Has (12 ),
},
{
Name : "Deleted" ,
SchemaName : "deleted" ,
Null : !u .Flags .Has (13 ),
},
{
Name : "Bot" ,
SchemaName : "bot" ,
Null : !u .Flags .Has (14 ),
},
{
Name : "BotChatHistory" ,
SchemaName : "bot_chat_history" ,
Null : !u .Flags .Has (15 ),
},
{
Name : "BotNochats" ,
SchemaName : "bot_nochats" ,
Null : !u .Flags .Has (16 ),
},
{
Name : "Verified" ,
SchemaName : "verified" ,
Null : !u .Flags .Has (17 ),
},
{
Name : "Restricted" ,
SchemaName : "restricted" ,
Null : !u .Flags .Has (18 ),
},
{
Name : "Min" ,
SchemaName : "min" ,
Null : !u .Flags .Has (20 ),
},
{
Name : "BotInlineGeo" ,
SchemaName : "bot_inline_geo" ,
Null : !u .Flags .Has (21 ),
},
{
Name : "Support" ,
SchemaName : "support" ,
Null : !u .Flags .Has (23 ),
},
{
Name : "Scam" ,
SchemaName : "scam" ,
Null : !u .Flags .Has (24 ),
},
{
Name : "ApplyMinPhoto" ,
SchemaName : "apply_min_photo" ,
Null : !u .Flags .Has (25 ),
},
{
Name : "Fake" ,
SchemaName : "fake" ,
Null : !u .Flags .Has (26 ),
},
{
Name : "BotAttachMenu" ,
SchemaName : "bot_attach_menu" ,
Null : !u .Flags .Has (27 ),
},
{
Name : "Premium" ,
SchemaName : "premium" ,
Null : !u .Flags .Has (28 ),
},
{
Name : "AttachMenuEnabled" ,
SchemaName : "attach_menu_enabled" ,
Null : !u .Flags .Has (29 ),
},
{
Name : "BotCanEdit" ,
SchemaName : "bot_can_edit" ,
Null : !u .Flags2 .Has (1 ),
},
{
Name : "CloseFriend" ,
SchemaName : "close_friend" ,
Null : !u .Flags2 .Has (2 ),
},
{
Name : "StoriesHidden" ,
SchemaName : "stories_hidden" ,
Null : !u .Flags2 .Has (3 ),
},
{
Name : "StoriesUnavailable" ,
SchemaName : "stories_unavailable" ,
Null : !u .Flags2 .Has (4 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "AccessHash" ,
SchemaName : "access_hash" ,
Null : !u .Flags .Has (0 ),
},
{
Name : "FirstName" ,
SchemaName : "first_name" ,
Null : !u .Flags .Has (1 ),
},
{
Name : "LastName" ,
SchemaName : "last_name" ,
Null : !u .Flags .Has (2 ),
},
{
Name : "Username" ,
SchemaName : "username" ,
Null : !u .Flags .Has (3 ),
},
{
Name : "Phone" ,
SchemaName : "phone" ,
Null : !u .Flags .Has (4 ),
},
{
Name : "Photo" ,
SchemaName : "photo" ,
Null : !u .Flags .Has (5 ),
},
{
Name : "Status" ,
SchemaName : "status" ,
Null : !u .Flags .Has (6 ),
},
{
Name : "BotInfoVersion" ,
SchemaName : "bot_info_version" ,
Null : !u .Flags .Has (14 ),
},
{
Name : "RestrictionReason" ,
SchemaName : "restriction_reason" ,
Null : !u .Flags .Has (18 ),
},
{
Name : "BotInlinePlaceholder" ,
SchemaName : "bot_inline_placeholder" ,
Null : !u .Flags .Has (19 ),
},
{
Name : "LangCode" ,
SchemaName : "lang_code" ,
Null : !u .Flags .Has (22 ),
},
{
Name : "EmojiStatus" ,
SchemaName : "emoji_status" ,
Null : !u .Flags .Has (30 ),
},
{
Name : "Usernames" ,
SchemaName : "usernames" ,
Null : !u .Flags2 .Has (0 ),
},
{
Name : "StoriesMaxID" ,
SchemaName : "stories_max_id" ,
Null : !u .Flags2 .Has (5 ),
},
{
Name : "Color" ,
SchemaName : "color" ,
Null : !u .Flags2 .Has (8 ),
},
{
Name : "ProfileColor" ,
SchemaName : "profile_color" ,
Null : !u .Flags2 .Has (9 ),
},
}
return typ
}
func (u *User ) SetFlags () {
if !(u .Self == false ) {
u .Flags .Set (10 )
}
if !(u .Contact == false ) {
u .Flags .Set (11 )
}
if !(u .MutualContact == false ) {
u .Flags .Set (12 )
}
if !(u .Deleted == false ) {
u .Flags .Set (13 )
}
if !(u .Bot == false ) {
u .Flags .Set (14 )
}
if !(u .BotChatHistory == false ) {
u .Flags .Set (15 )
}
if !(u .BotNochats == false ) {
u .Flags .Set (16 )
}
if !(u .Verified == false ) {
u .Flags .Set (17 )
}
if !(u .Restricted == false ) {
u .Flags .Set (18 )
}
if !(u .Min == false ) {
u .Flags .Set (20 )
}
if !(u .BotInlineGeo == false ) {
u .Flags .Set (21 )
}
if !(u .Support == false ) {
u .Flags .Set (23 )
}
if !(u .Scam == false ) {
u .Flags .Set (24 )
}
if !(u .ApplyMinPhoto == false ) {
u .Flags .Set (25 )
}
if !(u .Fake == false ) {
u .Flags .Set (26 )
}
if !(u .BotAttachMenu == false ) {
u .Flags .Set (27 )
}
if !(u .Premium == false ) {
u .Flags .Set (28 )
}
if !(u .AttachMenuEnabled == false ) {
u .Flags .Set (29 )
}
if !(u .BotCanEdit == false ) {
u .Flags2 .Set (1 )
}
if !(u .CloseFriend == false ) {
u .Flags2 .Set (2 )
}
if !(u .StoriesHidden == false ) {
u .Flags2 .Set (3 )
}
if !(u .StoriesUnavailable == false ) {
u .Flags2 .Set (4 )
}
if !(u .AccessHash == 0 ) {
u .Flags .Set (0 )
}
if !(u .FirstName == "" ) {
u .Flags .Set (1 )
}
if !(u .LastName == "" ) {
u .Flags .Set (2 )
}
if !(u .Username == "" ) {
u .Flags .Set (3 )
}
if !(u .Phone == "" ) {
u .Flags .Set (4 )
}
if !(u .Photo == nil ) {
u .Flags .Set (5 )
}
if !(u .Status == nil ) {
u .Flags .Set (6 )
}
if !(u .BotInfoVersion == 0 ) {
u .Flags .Set (14 )
}
if !(u .RestrictionReason == nil ) {
u .Flags .Set (18 )
}
if !(u .BotInlinePlaceholder == "" ) {
u .Flags .Set (19 )
}
if !(u .LangCode == "" ) {
u .Flags .Set (22 )
}
if !(u .EmojiStatus == nil ) {
u .Flags .Set (30 )
}
if !(u .Usernames == nil ) {
u .Flags2 .Set (0 )
}
if !(u .StoriesMaxID == 0 ) {
u .Flags2 .Set (5 )
}
if !(u .Color .Zero ()) {
u .Flags2 .Set (8 )
}
if !(u .ProfileColor .Zero ()) {
u .Flags2 .Set (9 )
}
}
func (u *User ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode user#215c4438 as nil" )
}
b .PutID (UserTypeID )
return u .EncodeBare (b )
}
func (u *User ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode user#215c4438 as nil" )
}
u .SetFlags ()
if err := u .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode user#215c4438: field flags: %w" , err )
}
if err := u .Flags2 .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode user#215c4438: field flags2: %w" , err )
}
b .PutLong (u .ID )
if u .Flags .Has (0 ) {
b .PutLong (u .AccessHash )
}
if u .Flags .Has (1 ) {
b .PutString (u .FirstName )
}
if u .Flags .Has (2 ) {
b .PutString (u .LastName )
}
if u .Flags .Has (3 ) {
b .PutString (u .Username )
}
if u .Flags .Has (4 ) {
b .PutString (u .Phone )
}
if u .Flags .Has (5 ) {
if u .Photo == nil {
return fmt .Errorf ("unable to encode user#215c4438: field photo is nil" )
}
if err := u .Photo .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode user#215c4438: field photo: %w" , err )
}
}
if u .Flags .Has (6 ) {
if u .Status == nil {
return fmt .Errorf ("unable to encode user#215c4438: field status is nil" )
}
if err := u .Status .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode user#215c4438: field status: %w" , err )
}
}
if u .Flags .Has (14 ) {
b .PutInt (u .BotInfoVersion )
}
if u .Flags .Has (18 ) {
b .PutVectorHeader (len (u .RestrictionReason ))
for idx , v := range u .RestrictionReason {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode user#215c4438: field restriction_reason element with index %d: %w" , idx , err )
}
}
}
if u .Flags .Has (19 ) {
b .PutString (u .BotInlinePlaceholder )
}
if u .Flags .Has (22 ) {
b .PutString (u .LangCode )
}
if u .Flags .Has (30 ) {
if u .EmojiStatus == nil {
return fmt .Errorf ("unable to encode user#215c4438: field emoji_status is nil" )
}
if err := u .EmojiStatus .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode user#215c4438: field emoji_status: %w" , err )
}
}
if u .Flags2 .Has (0 ) {
b .PutVectorHeader (len (u .Usernames ))
for idx , v := range u .Usernames {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode user#215c4438: field usernames element with index %d: %w" , idx , err )
}
}
}
if u .Flags2 .Has (5 ) {
b .PutInt (u .StoriesMaxID )
}
if u .Flags2 .Has (8 ) {
if err := u .Color .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode user#215c4438: field color: %w" , err )
}
}
if u .Flags2 .Has (9 ) {
if err := u .ProfileColor .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode user#215c4438: field profile_color: %w" , err )
}
}
return nil
}
func (u *User ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode user#215c4438 to nil" )
}
if err := b .ConsumeID (UserTypeID ); err != nil {
return fmt .Errorf ("unable to decode user#215c4438: %w" , err )
}
return u .DecodeBare (b )
}
func (u *User ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode user#215c4438 to nil" )
}
{
if err := u .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode user#215c4438: field flags: %w" , err )
}
}
u .Self = u .Flags .Has (10 )
u .Contact = u .Flags .Has (11 )
u .MutualContact = u .Flags .Has (12 )
u .Deleted = u .Flags .Has (13 )
u .Bot = u .Flags .Has (14 )
u .BotChatHistory = u .Flags .Has (15 )
u .BotNochats = u .Flags .Has (16 )
u .Verified = u .Flags .Has (17 )
u .Restricted = u .Flags .Has (18 )
u .Min = u .Flags .Has (20 )
u .BotInlineGeo = u .Flags .Has (21 )
u .Support = u .Flags .Has (23 )
u .Scam = u .Flags .Has (24 )
u .ApplyMinPhoto = u .Flags .Has (25 )
u .Fake = u .Flags .Has (26 )
u .BotAttachMenu = u .Flags .Has (27 )
u .Premium = u .Flags .Has (28 )
u .AttachMenuEnabled = u .Flags .Has (29 )
{
if err := u .Flags2 .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode user#215c4438: field flags2: %w" , err )
}
}
u .BotCanEdit = u .Flags2 .Has (1 )
u .CloseFriend = u .Flags2 .Has (2 )
u .StoriesHidden = u .Flags2 .Has (3 )
u .StoriesUnavailable = u .Flags2 .Has (4 )
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode user#215c4438: field id: %w" , err )
}
u .ID = value
}
if u .Flags .Has (0 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode user#215c4438: field access_hash: %w" , err )
}
u .AccessHash = value
}
if u .Flags .Has (1 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode user#215c4438: field first_name: %w" , err )
}
u .FirstName = value
}
if u .Flags .Has (2 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode user#215c4438: field last_name: %w" , err )
}
u .LastName = value
}
if u .Flags .Has (3 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode user#215c4438: field username: %w" , err )
}
u .Username = value
}
if u .Flags .Has (4 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode user#215c4438: field phone: %w" , err )
}
u .Phone = value
}
if u .Flags .Has (5 ) {
value , err := DecodeUserProfilePhoto (b )
if err != nil {
return fmt .Errorf ("unable to decode user#215c4438: field photo: %w" , err )
}
u .Photo = value
}
if u .Flags .Has (6 ) {
value , err := DecodeUserStatus (b )
if err != nil {
return fmt .Errorf ("unable to decode user#215c4438: field status: %w" , err )
}
u .Status = value
}
if u .Flags .Has (14 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode user#215c4438: field bot_info_version: %w" , err )
}
u .BotInfoVersion = value
}
if u .Flags .Has (18 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode user#215c4438: field restriction_reason: %w" , err )
}
if headerLen > 0 {
u .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 user#215c4438: field restriction_reason: %w" , err )
}
u .RestrictionReason = append (u .RestrictionReason , value )
}
}
if u .Flags .Has (19 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode user#215c4438: field bot_inline_placeholder: %w" , err )
}
u .BotInlinePlaceholder = value
}
if u .Flags .Has (22 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode user#215c4438: field lang_code: %w" , err )
}
u .LangCode = value
}
if u .Flags .Has (30 ) {
value , err := DecodeEmojiStatus (b )
if err != nil {
return fmt .Errorf ("unable to decode user#215c4438: field emoji_status: %w" , err )
}
u .EmojiStatus = value
}
if u .Flags2 .Has (0 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode user#215c4438: field usernames: %w" , err )
}
if headerLen > 0 {
u .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 user#215c4438: field usernames: %w" , err )
}
u .Usernames = append (u .Usernames , value )
}
}
if u .Flags2 .Has (5 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode user#215c4438: field stories_max_id: %w" , err )
}
u .StoriesMaxID = value
}
if u .Flags2 .Has (8 ) {
if err := u .Color .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode user#215c4438: field color: %w" , err )
}
}
if u .Flags2 .Has (9 ) {
if err := u .ProfileColor .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode user#215c4438: field profile_color: %w" , err )
}
}
return nil
}
func (u *User ) SetSelf (value bool ) {
if value {
u .Flags .Set (10 )
u .Self = true
} else {
u .Flags .Unset (10 )
u .Self = false
}
}
func (u *User ) GetSelf () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (10 )
}
func (u *User ) SetContact (value bool ) {
if value {
u .Flags .Set (11 )
u .Contact = true
} else {
u .Flags .Unset (11 )
u .Contact = false
}
}
func (u *User ) GetContact () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (11 )
}
func (u *User ) SetMutualContact (value bool ) {
if value {
u .Flags .Set (12 )
u .MutualContact = true
} else {
u .Flags .Unset (12 )
u .MutualContact = false
}
}
func (u *User ) GetMutualContact () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (12 )
}
func (u *User ) SetDeleted (value bool ) {
if value {
u .Flags .Set (13 )
u .Deleted = true
} else {
u .Flags .Unset (13 )
u .Deleted = false
}
}
func (u *User ) GetDeleted () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (13 )
}
func (u *User ) SetBot (value bool ) {
if value {
u .Flags .Set (14 )
u .Bot = true
} else {
u .Flags .Unset (14 )
u .Bot = false
}
}
func (u *User ) GetBot () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (14 )
}
func (u *User ) SetBotChatHistory (value bool ) {
if value {
u .Flags .Set (15 )
u .BotChatHistory = true
} else {
u .Flags .Unset (15 )
u .BotChatHistory = false
}
}
func (u *User ) GetBotChatHistory () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (15 )
}
func (u *User ) SetBotNochats (value bool ) {
if value {
u .Flags .Set (16 )
u .BotNochats = true
} else {
u .Flags .Unset (16 )
u .BotNochats = false
}
}
func (u *User ) GetBotNochats () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (16 )
}
func (u *User ) SetVerified (value bool ) {
if value {
u .Flags .Set (17 )
u .Verified = true
} else {
u .Flags .Unset (17 )
u .Verified = false
}
}
func (u *User ) GetVerified () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (17 )
}
func (u *User ) SetRestricted (value bool ) {
if value {
u .Flags .Set (18 )
u .Restricted = true
} else {
u .Flags .Unset (18 )
u .Restricted = false
}
}
func (u *User ) GetRestricted () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (18 )
}
func (u *User ) SetMin (value bool ) {
if value {
u .Flags .Set (20 )
u .Min = true
} else {
u .Flags .Unset (20 )
u .Min = false
}
}
func (u *User ) GetMin () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (20 )
}
func (u *User ) SetBotInlineGeo (value bool ) {
if value {
u .Flags .Set (21 )
u .BotInlineGeo = true
} else {
u .Flags .Unset (21 )
u .BotInlineGeo = false
}
}
func (u *User ) GetBotInlineGeo () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (21 )
}
func (u *User ) SetSupport (value bool ) {
if value {
u .Flags .Set (23 )
u .Support = true
} else {
u .Flags .Unset (23 )
u .Support = false
}
}
func (u *User ) GetSupport () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (23 )
}
func (u *User ) SetScam (value bool ) {
if value {
u .Flags .Set (24 )
u .Scam = true
} else {
u .Flags .Unset (24 )
u .Scam = false
}
}
func (u *User ) GetScam () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (24 )
}
func (u *User ) SetApplyMinPhoto (value bool ) {
if value {
u .Flags .Set (25 )
u .ApplyMinPhoto = true
} else {
u .Flags .Unset (25 )
u .ApplyMinPhoto = false
}
}
func (u *User ) GetApplyMinPhoto () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (25 )
}
func (u *User ) SetFake (value bool ) {
if value {
u .Flags .Set (26 )
u .Fake = true
} else {
u .Flags .Unset (26 )
u .Fake = false
}
}
func (u *User ) GetFake () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (26 )
}
func (u *User ) SetBotAttachMenu (value bool ) {
if value {
u .Flags .Set (27 )
u .BotAttachMenu = true
} else {
u .Flags .Unset (27 )
u .BotAttachMenu = false
}
}
func (u *User ) GetBotAttachMenu () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (27 )
}
func (u *User ) SetPremium (value bool ) {
if value {
u .Flags .Set (28 )
u .Premium = true
} else {
u .Flags .Unset (28 )
u .Premium = false
}
}
func (u *User ) GetPremium () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (28 )
}
func (u *User ) SetAttachMenuEnabled (value bool ) {
if value {
u .Flags .Set (29 )
u .AttachMenuEnabled = true
} else {
u .Flags .Unset (29 )
u .AttachMenuEnabled = false
}
}
func (u *User ) GetAttachMenuEnabled () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (29 )
}
func (u *User ) SetBotCanEdit (value bool ) {
if value {
u .Flags2 .Set (1 )
u .BotCanEdit = true
} else {
u .Flags2 .Unset (1 )
u .BotCanEdit = false
}
}
func (u *User ) GetBotCanEdit () (value bool ) {
if u == nil {
return
}
return u .Flags2 .Has (1 )
}
func (u *User ) SetCloseFriend (value bool ) {
if value {
u .Flags2 .Set (2 )
u .CloseFriend = true
} else {
u .Flags2 .Unset (2 )
u .CloseFriend = false
}
}
func (u *User ) GetCloseFriend () (value bool ) {
if u == nil {
return
}
return u .Flags2 .Has (2 )
}
func (u *User ) SetStoriesHidden (value bool ) {
if value {
u .Flags2 .Set (3 )
u .StoriesHidden = true
} else {
u .Flags2 .Unset (3 )
u .StoriesHidden = false
}
}
func (u *User ) GetStoriesHidden () (value bool ) {
if u == nil {
return
}
return u .Flags2 .Has (3 )
}
func (u *User ) SetStoriesUnavailable (value bool ) {
if value {
u .Flags2 .Set (4 )
u .StoriesUnavailable = true
} else {
u .Flags2 .Unset (4 )
u .StoriesUnavailable = false
}
}
func (u *User ) GetStoriesUnavailable () (value bool ) {
if u == nil {
return
}
return u .Flags2 .Has (4 )
}
func (u *User ) GetID () (value int64 ) {
if u == nil {
return
}
return u .ID
}
func (u *User ) SetAccessHash (value int64 ) {
u .Flags .Set (0 )
u .AccessHash = value
}
func (u *User ) GetAccessHash () (value int64 , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (0 ) {
return value , false
}
return u .AccessHash , true
}
func (u *User ) SetFirstName (value string ) {
u .Flags .Set (1 )
u .FirstName = value
}
func (u *User ) GetFirstName () (value string , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (1 ) {
return value , false
}
return u .FirstName , true
}
func (u *User ) SetLastName (value string ) {
u .Flags .Set (2 )
u .LastName = value
}
func (u *User ) GetLastName () (value string , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (2 ) {
return value , false
}
return u .LastName , true
}
func (u *User ) SetUsername (value string ) {
u .Flags .Set (3 )
u .Username = value
}
func (u *User ) GetUsername () (value string , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (3 ) {
return value , false
}
return u .Username , true
}
func (u *User ) SetPhone (value string ) {
u .Flags .Set (4 )
u .Phone = value
}
func (u *User ) GetPhone () (value string , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (4 ) {
return value , false
}
return u .Phone , true
}
func (u *User ) SetPhoto (value UserProfilePhotoClass ) {
u .Flags .Set (5 )
u .Photo = value
}
func (u *User ) GetPhoto () (value UserProfilePhotoClass , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (5 ) {
return value , false
}
return u .Photo , true
}
func (u *User ) SetStatus (value UserStatusClass ) {
u .Flags .Set (6 )
u .Status = value
}
func (u *User ) GetStatus () (value UserStatusClass , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (6 ) {
return value , false
}
return u .Status , true
}
func (u *User ) SetBotInfoVersion (value int ) {
u .Flags .Set (14 )
u .BotInfoVersion = value
}
func (u *User ) GetBotInfoVersion () (value int , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (14 ) {
return value , false
}
return u .BotInfoVersion , true
}
func (u *User ) SetRestrictionReason (value []RestrictionReason ) {
u .Flags .Set (18 )
u .RestrictionReason = value
}
func (u *User ) GetRestrictionReason () (value []RestrictionReason , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (18 ) {
return value , false
}
return u .RestrictionReason , true
}
func (u *User ) SetBotInlinePlaceholder (value string ) {
u .Flags .Set (19 )
u .BotInlinePlaceholder = value
}
func (u *User ) GetBotInlinePlaceholder () (value string , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (19 ) {
return value , false
}
return u .BotInlinePlaceholder , true
}
func (u *User ) SetLangCode (value string ) {
u .Flags .Set (22 )
u .LangCode = value
}
func (u *User ) GetLangCode () (value string , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (22 ) {
return value , false
}
return u .LangCode , true
}
func (u *User ) SetEmojiStatus (value EmojiStatusClass ) {
u .Flags .Set (30 )
u .EmojiStatus = value
}
func (u *User ) GetEmojiStatus () (value EmojiStatusClass , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (30 ) {
return value , false
}
return u .EmojiStatus , true
}
func (u *User ) SetUsernames (value []Username ) {
u .Flags2 .Set (0 )
u .Usernames = value
}
func (u *User ) GetUsernames () (value []Username , ok bool ) {
if u == nil {
return
}
if !u .Flags2 .Has (0 ) {
return value , false
}
return u .Usernames , true
}
func (u *User ) SetStoriesMaxID (value int ) {
u .Flags2 .Set (5 )
u .StoriesMaxID = value
}
func (u *User ) GetStoriesMaxID () (value int , ok bool ) {
if u == nil {
return
}
if !u .Flags2 .Has (5 ) {
return value , false
}
return u .StoriesMaxID , true
}
func (u *User ) SetColor (value PeerColor ) {
u .Flags2 .Set (8 )
u .Color = value
}
func (u *User ) GetColor () (value PeerColor , ok bool ) {
if u == nil {
return
}
if !u .Flags2 .Has (8 ) {
return value , false
}
return u .Color , true
}
func (u *User ) SetProfileColor (value PeerColor ) {
u .Flags2 .Set (9 )
u .ProfileColor = value
}
func (u *User ) GetProfileColor () (value PeerColor , ok bool ) {
if u == nil {
return
}
if !u .Flags2 .Has (9 ) {
return value , false
}
return u .ProfileColor , true
}
const UserClassName = "User"
type UserClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () UserClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetID () (value int64 )
AsNotEmpty () (*User , bool )
}
func (u *User ) AsInputPeer () *InputPeerUser {
value := new (InputPeerUser )
value .UserID = u .GetID ()
if fieldValue , ok := u .GetAccessHash (); ok {
value .AccessHash = fieldValue
}
return value
}
func (u *User ) AsInput () *InputUser {
value := new (InputUser )
value .UserID = u .GetID ()
if fieldValue , ok := u .GetAccessHash (); ok {
value .AccessHash = fieldValue
}
return value
}
func (u *UserEmpty ) AsNotEmpty () (*User , bool ) {
return nil , false
}
func (u *User ) AsNotEmpty () (*User , bool ) {
return u , true
}
func DecodeUser (buf *bin .Buffer ) (UserClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case UserEmptyTypeID :
v := UserEmpty {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode UserClass: %w" , err )
}
return &v , nil
case UserTypeID :
v := User {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode UserClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode UserClass: %w" , bin .NewUnexpectedID (id ))
}
}
type UserBox struct {
User UserClass
}
func (b *UserBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode UserBox to nil" )
}
v , err := DecodeUser (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .User = v
return nil
}
func (b *UserBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .User == nil {
return fmt .Errorf ("unable to encode UserClass as nil" )
}
return b .User .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 .