// <auto-generated/>
// ReSharper disable All

namespace MyTelegram.Schema;

///<summary>
/// Indicates info about a certain user.Unless specified otherwise, when updating the <a href="https://corefork.telegram.org/api/peers">local peer database</a>, all fields from the newly received constructor take priority over the old constructor cached locally (including by removing fields that aren't set in the new constructor).See <a href="https://github.com/tdlib/td/blob/cb164927417f22811c74cd8678ed4a5ab7cb80ba/td/telegram/UserManager.cpp#L2267">here »</a> for an implementation of the logic to use when updating the <a href="https://corefork.telegram.org/api/peers">local user peer database</a>.
/// See <a href="https://corefork.telegram.org/constructor/user" />
///</summary>
[TlObject(0x20b1422)]
public sealed class TUser : IUser, ILayeredUser
{
    public uint ConstructorId => 0x20b1422;
    ///<summary>
    /// Flags, see <a href="https://corefork.telegram.org/mtproto/TL-combinators#conditional-fields">TL conditional fields</a>
    ///</summary>
    public int Flags { get; set; }

    ///<summary>
    /// Whether this user indicates the currently logged in user
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Self { get; set; }

    ///<summary>
    /// Whether this user is a contact <br>When updating the <a href="https://corefork.telegram.org/api/peers">local peer database</a>, do not apply changes to this field if the <code>min</code> flag is set.
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Contact { get; set; }

    ///<summary>
    /// Whether this user is a mutual contact. <br>When updating the <a href="https://corefork.telegram.org/api/peers">local peer database</a>, do not apply changes to this field if the <code>min</code> flag is set.
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool MutualContact { get; set; }

    ///<summary>
    /// Whether the account of this user was deleted. <br>Changes to this flag should invalidate the local <a href="https://corefork.telegram.org/constructor/userFull">userFull</a> cache for this user ID, see <a href="https://corefork.telegram.org/api/peers#full-info-database">here »</a> for more info.
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Deleted { get; set; }

    ///<summary>
    /// Is this user a bot? <br>Changes to this flag should invalidate the local <a href="https://corefork.telegram.org/constructor/userFull">userFull</a> cache for this user ID, see <a href="https://corefork.telegram.org/api/peers#full-info-database">here »</a> for more info.
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Bot { get; set; }

    ///<summary>
    /// Can the bot see all messages in groups?
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool BotChatHistory { get; set; }

    ///<summary>
    /// Can the bot be added to groups?
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool BotNochats { get; set; }

    ///<summary>
    /// Whether this user is verified
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Verified { get; set; }

    ///<summary>
    /// Access to this user must be restricted for the reason specified in <code>restriction_reason</code>
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Restricted { get; set; }

    ///<summary>
    /// See <a href="https://corefork.telegram.org/api/min">min</a>
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Min { get; set; }

    ///<summary>
    /// Whether the bot can request our geolocation in inline mode
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool BotInlineGeo { get; set; }

    ///<summary>
    /// Whether this is an official support user
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Support { get; set; }

    ///<summary>
    /// This may be a scam user
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Scam { get; set; }

    ///<summary>
    /// If set and <code>min</code> is set, the value of <code>photo</code> can be used to update the local database, see the documentation of that flag for more info.
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool ApplyMinPhoto { get; set; }

    ///<summary>
    /// If set, this user was reported by many users as a fake or scam user: be careful when interacting with them.
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Fake { get; set; }

    ///<summary>
    /// Whether this bot offers an <a href="https://corefork.telegram.org/api/bots/attach">attachment menu web app</a>
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool BotAttachMenu { get; set; }

    ///<summary>
    /// Whether this user is a Telegram Premium user <br>Changes to this flag should invalidate the local <a href="https://corefork.telegram.org/constructor/userFull">userFull</a> cache for this user ID, see <a href="https://corefork.telegram.org/api/peers#full-info-database">here »</a> for more info. <br>Changes to this flag if the <code>self</code> flag is set should also trigger the following calls, to refresh the respective caches: <br>- The <a href="https://corefork.telegram.org/method/help.getConfig">help.getConfig</a> cache <br>- The <a href="https://corefork.telegram.org/method/messages.getTopReactions">messages.getTopReactions</a> cache if the <code>bot</code> flag is <strong>not</strong> set
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Premium { get; set; }

    ///<summary>
    /// Whether we installed the <a href="https://corefork.telegram.org/api/bots/attach">attachment menu web app</a> offered by this bot. <br>When updating the <a href="https://corefork.telegram.org/api/peers">local peer database</a>, do not apply changes to this field if the <code>min</code> flag is set.
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool AttachMenuEnabled { get; set; }

    ///<summary>
    /// Flags, see <a href="https://corefork.telegram.org/mtproto/TL-combinators#conditional-fields">TL conditional fields</a>
    ///</summary>
    public int Flags2 { get; set; }

    ///<summary>
    /// Whether we can edit the profile picture, name, about text and description of this bot because we own it. <br>When updating the <a href="https://corefork.telegram.org/api/peers">local peer database</a>, do not apply changes to this field if the <code>min</code> flag is set. <br>Changes to this flag (if <code>min</code> is not set) should invalidate the local <a href="https://corefork.telegram.org/constructor/userFull">userFull</a> cache for this user ID.
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool BotCanEdit { get; set; }

    ///<summary>
    /// Whether we marked this user as a <a href="https://corefork.telegram.org/api/privacy">close friend, see here » for more info</a>. <br>When updating the <a href="https://corefork.telegram.org/api/peers">local peer database</a>, do not apply changes to this field if the <code>min</code> flag is set.
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool CloseFriend { get; set; }

    ///<summary>
    /// Whether we have <a href="https://corefork.telegram.org/api/stories#hiding-stories-of-other-users">hidden »</a> all active stories of this user. <br>When updating the <a href="https://corefork.telegram.org/api/peers">local peer database</a>, do not apply changes to this field if the <code>min</code> flag is set.
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool StoriesHidden { get; set; }

    ///<summary>
    /// No stories from this user are visible.
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool StoriesUnavailable { get; set; }

    ///<summary>
    /// If set, we can only write to this user if they have already sent some messages to us, if we are subscribed to <a href="https://corefork.telegram.org/api/premium">Telegram Premium</a>, or if they're a mutual contact (<a href="https://corefork.telegram.org/constructor/user">user</a>.<code>mutual_contact</code>).  <br>All the secondary conditions listed above must be checked separately to verify whether we can still write to the user, even if this flag is set (i.e. a mutual contact will have this flag set even if we can still write to them, and so on...); to avoid doing these extra checks if we haven't yet cached all the required information (for example while displaying the chat list in the sharing UI) the <a href="https://corefork.telegram.org/method/users.getIsPremiumRequiredToContact">users.getIsPremiumRequiredToContact</a> method may be invoked instead, passing the list of users currently visible in the UI, returning a list of booleans that directly specify whether we can or cannot write to each user; alternatively, the <a href="https://corefork.telegram.org/constructor/userFull">userFull</a>.<code>contact_require_premium</code> flag contains the same (fully checked, i.e. it's not just a copy of this flag) info returned by <a href="https://corefork.telegram.org/method/users.getIsPremiumRequiredToContact">users.getIsPremiumRequiredToContact</a>. <br>To set this flag for ourselves invoke <a href="https://corefork.telegram.org/method/account.setGlobalPrivacySettings">account.setGlobalPrivacySettings</a>, setting the <code>settings.new_noncontact_peers_require_premium</code> flag.
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool ContactRequirePremium { get; set; }

    ///<summary>
    /// Whether this bot can be <a href="https://corefork.telegram.org/api/business#connected-bots">connected to a user as specified here »</a>.
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool BotBusiness { get; set; }

    ///<summary>
    /// If set, this bot has configured a <a href="https://corefork.telegram.org/api/bots/webapps#main-mini-apps">Main Mini App »</a>.
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool BotHasMainApp { get; set; }

    ///<summary>
    /// ID of the user, see <a href="https://corefork.telegram.org/api/peers#peer-id">here »</a> for more info.
    ///</summary>
    public long Id { get; set; }

    ///<summary>
    /// Access hash of the user, see <a href="https://corefork.telegram.org/api/peers#access-hash">here »</a> for more info. <br>If this flag is set, when updating the <a href="https://corefork.telegram.org/api/peers">local peer database</a>, generate a virtual flag called <code>min_access_hash</code>, which is: <br>- Set to <code>true</code> if <code>min</code> is set AND <br>-- The <code>phone</code> flag is <strong>not</strong> set OR <br>-- The <code>phone</code> flag is set and the associated phone number string is non-empty <br>- Set to <code>false</code> otherwise. <br><br>Then, apply both <code>access_hash</code> and <code>min_access_hash</code> to the local database if: <br>- <code>min_access_hash</code> is false OR <br>- <code>min_access_hash</code> is true AND <br>-- There is no locally cached object for this user OR <br>-- There is no <code>access_hash</code> in the local cache OR <br>-- The cached object's <code>min_access_hash</code> is also true <br><br>If the final merged object stored to the database has the <code>min_access_hash</code> field set to true, the related <code>access_hash</code> is <strong>only</strong> suitable to use in <a href="https://corefork.telegram.org/constructor/inputPeerPhotoFileLocation"><code>inputPeerPhotoFileLocation</code> »</a>, to directly <a href="https://corefork.telegram.org/api/files">download the profile pictures</a> of users, everywhere else a <code>inputPeer*FromMessage</code> constructor will have to be generated as specified <a href="https://corefork.telegram.org/api/min">here »</a>. <br>Bots can also use min access hashes in some conditions, by passing <code>0</code> instead of the min access hash.
    ///</summary>
    public long? AccessHash { get; set; }

    ///<summary>
    /// First name. <br>When updating the <a href="https://corefork.telegram.org/api/peers">local peer database</a>, apply changes to this field only if: <br>- The <code>min</code> flag is not set OR <br>- The <code>min</code> flag is set AND <br>-- The <code>min</code> flag of the locally cached user entry is set.
    ///</summary>
    public string? FirstName { get; set; }

    ///<summary>
    /// Last name. <br>When updating the <a href="https://corefork.telegram.org/api/peers">local peer database</a>, apply changes to this field only if: <br>- The <code>min</code> flag is not set OR <br>- The <code>min</code> flag is set AND <br>-- The <code>min</code> flag of the locally cached user entry is set.
    ///</summary>
    public string? LastName { get; set; }

    ///<summary>
    /// Main active username. <br>When updating the <a href="https://corefork.telegram.org/api/peers">local peer database</a>, apply changes to this field only if: <br>- The <code>min</code> flag is not set OR <br>- The <code>min</code> flag is set AND <br>-- The <code>min</code> flag of the locally cached user entry is set. <br>Changes to this flag should invalidate the local <a href="https://corefork.telegram.org/constructor/userFull">userFull</a> cache for this user ID if the above conditions are respected and the <code>bot_can_edit</code> flag is also set.
    ///</summary>
    public string? Username { get; set; }

    ///<summary>
    /// Phone number. <br>When updating the <a href="https://corefork.telegram.org/api/peers">local peer database</a>, apply changes to this field only if: <br>- The <code>min</code> flag is not set OR <br>- The <code>min</code> flag is set AND <br>-- The <code>min</code> flag of the locally cached user entry is set.
    ///</summary>
    public string? Phone { get; set; }

    ///<summary>
    /// Profile picture of user. <br>When updating the <a href="https://corefork.telegram.org/api/peers">local peer database</a>, apply changes to this field only if: <br>- The <code>min</code> flag is not set OR <br>- The <code>min</code> flag is set AND <br>-- The <code>apply_min_photo</code> flag is set OR <br>-- The <code>min</code> flag of the locally cached user entry is set.
    /// See <a href="https://corefork.telegram.org/type/UserProfilePhoto" />
    ///</summary>
    public MyTelegram.Schema.IUserProfilePhoto? Photo { get; set; }

    ///<summary>
    /// Online status of user. <br>When updating the <a href="https://corefork.telegram.org/api/peers">local peer database</a>, apply changes to this field only if: <br>- The <code>min</code> flag is not set OR <br>- The <code>min</code> flag is set AND <br>-- The <code>min</code> flag of the locally cached user entry is set OR <br>-- The locally cached user entry is equal to <a href="https://corefork.telegram.org/constructor/userStatusEmpty">userStatusEmpty</a>.
    /// See <a href="https://corefork.telegram.org/type/UserStatus" />
    ///</summary>
    public MyTelegram.Schema.IUserStatus? Status { get; set; }

    ///<summary>
    /// Version of the <a href="https://corefork.telegram.org/constructor/userFull">bot_info field in userFull</a>, incremented every time it changes. <br>Changes to this flag should invalidate the local <a href="https://corefork.telegram.org/constructor/userFull">userFull</a> cache for this user ID, see <a href="https://corefork.telegram.org/api/peers#full-info-database">here »</a> for more info.
    ///</summary>
    public int? BotInfoVersion { get; set; }

    ///<summary>
    /// Contains the reason why access to this user must be restricted.
    ///</summary>
    public TVector<MyTelegram.Schema.IRestrictionReason>? RestrictionReason { get; set; }

    ///<summary>
    /// Inline placeholder for this inline bot
    ///</summary>
    public string? BotInlinePlaceholder { get; set; }

    ///<summary>
    /// Language code of the user
    ///</summary>
    public string? LangCode { get; set; }

    ///<summary>
    /// <a href="https://corefork.telegram.org/api/emoji-status">Emoji status</a>
    /// See <a href="https://corefork.telegram.org/type/EmojiStatus" />
    ///</summary>
    public MyTelegram.Schema.IEmojiStatus? EmojiStatus { get; set; }

    ///<summary>
    /// Additional usernames. <br>When updating the <a href="https://corefork.telegram.org/api/peers">local peer database</a>, apply changes to this field only if: <br>- The <code>min</code> flag is not set OR <br>- The <code>min</code> flag is set AND <br>-- The <code>min</code> flag of the locally cached user entry is set. <br>Changes to this flag (if the above conditions are respected) should invalidate the local <a href="https://corefork.telegram.org/constructor/userFull">userFull</a> cache for this user ID.
    ///</summary>
    public TVector<MyTelegram.Schema.IUsername>? Usernames { get; set; }

    ///<summary>
    /// ID of the maximum read <a href="https://corefork.telegram.org/api/stories">story</a>.  <br>When updating the <a href="https://corefork.telegram.org/api/peers">local peer database</a>, do not apply changes to this field if the <code>min</code> flag of the incoming constructor is set.
    ///</summary>
    public int? StoriesMaxId { get; set; }

    ///<summary>
    /// The user's <a href="https://corefork.telegram.org/api/colors">accent color</a>.
    /// See <a href="https://corefork.telegram.org/type/PeerColor" />
    ///</summary>
    public MyTelegram.Schema.IPeerColor? Color { get; set; }

    ///<summary>
    /// The user's <a href="https://corefork.telegram.org/api/colors">profile color</a>.
    /// See <a href="https://corefork.telegram.org/type/PeerColor" />
    ///</summary>
    public MyTelegram.Schema.IPeerColor? ProfileColor { get; set; }

    ///<summary>
    /// Monthly Active Users (MAU) of this bot (may be absent for small bots).
    ///</summary>
    public int? BotActiveUsers { get; set; }
    public long? BotVerificationIcon { get; set; }
    public long? SendPaidMessagesStars { get; set; }

    public void ComputeFlag()
    {
        if (Self) { Flags = Flags.SetBit(10); }
        if (Contact) { Flags = Flags.SetBit(11); }
        if (MutualContact) { Flags = Flags.SetBit(12); }
        if (Deleted) { Flags = Flags.SetBit(13); }
        if (Bot) { Flags = Flags.SetBit(14); }
        if (BotChatHistory) { Flags = Flags.SetBit(15); }
        if (BotNochats) { Flags = Flags.SetBit(16); }
        if (Verified) { Flags = Flags.SetBit(17); }
        if (Restricted) { Flags = Flags.SetBit(18); }
        if (Min) { Flags = Flags.SetBit(20); }
        if (BotInlineGeo) { Flags = Flags.SetBit(21); }
        if (Support) { Flags = Flags.SetBit(23); }
        if (Scam) { Flags = Flags.SetBit(24); }
        if (ApplyMinPhoto) { Flags = Flags.SetBit(25); }
        if (Fake) { Flags = Flags.SetBit(26); }
        if (BotAttachMenu) { Flags = Flags.SetBit(27); }
        if (Premium) { Flags = Flags.SetBit(28); }
        if (AttachMenuEnabled) { Flags = Flags.SetBit(29); }
        if (BotCanEdit) { Flags2 = Flags2.SetBit(1); }
        if (CloseFriend) { Flags2 = Flags2.SetBit(2); }
        if (StoriesHidden) { Flags2 = Flags2.SetBit(3); }
        if (StoriesUnavailable) { Flags2 = Flags2.SetBit(4); }
        if (ContactRequirePremium) { Flags2 = Flags2.SetBit(10); }
        if (BotBusiness) { Flags2 = Flags2.SetBit(11); }
        if (BotHasMainApp) { Flags2 = Flags2.SetBit(13); }
        if (/*AccessHash != 0 &&*/ AccessHash.HasValue) { Flags = Flags.SetBit(0); }
        if (FirstName != null) { Flags = Flags.SetBit(1); }
        if (LastName != null) { Flags = Flags.SetBit(2); }
        if (Username != null) { Flags = Flags.SetBit(3); }
        if (Phone != null) { Flags = Flags.SetBit(4); }
        if (Photo != null) { Flags = Flags.SetBit(5); }
        if (Status != null) { Flags = Flags.SetBit(6); }
        if (/*BotInfoVersion != 0 && */BotInfoVersion.HasValue) { Flags = Flags.SetBit(14); }
        if (RestrictionReason?.Count > 0) { Flags = Flags.SetBit(18); }
        if (BotInlinePlaceholder != null) { Flags = Flags.SetBit(19); }
        if (LangCode != null) { Flags = Flags.SetBit(22); }
        if (EmojiStatus != null) { Flags = Flags.SetBit(30); }
        if (Usernames?.Count > 0) { Flags2 = Flags2.SetBit(0); }
        if (/*StoriesMaxId != 0 && */StoriesMaxId.HasValue) { Flags2 = Flags2.SetBit(5); }
        if (Color != null) { Flags2 = Flags2.SetBit(8); }
        if (ProfileColor != null) { Flags2 = Flags2.SetBit(9); }
        if (/*BotActiveUsers != 0 && */BotActiveUsers.HasValue) { Flags2 = Flags2.SetBit(12); }
        if (/*BotVerificationIcon != 0 &&*/ BotVerificationIcon.HasValue) { Flags2 = Flags2.SetBit(14); }
        if (/*SendPaidMessagesStars != 0 &&*/ SendPaidMessagesStars.HasValue) { Flags2 = Flags2.SetBit(15); }
    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(Flags);
        writer.Write(Flags2);
        writer.Write(Id);
        if (Flags.IsBitSet(0)) { writer.Write(AccessHash.Value); }
        if (Flags.IsBitSet(1)) { writer.Write(FirstName); }
        if (Flags.IsBitSet(2)) { writer.Write(LastName); }
        if (Flags.IsBitSet(3)) { writer.Write(Username); }
        if (Flags.IsBitSet(4)) { writer.Write(Phone); }
        if (Flags.IsBitSet(5)) { writer.Write(Photo); }
        if (Flags.IsBitSet(6)) { writer.Write(Status); }
        if (Flags.IsBitSet(14)) { writer.Write(BotInfoVersion.Value); }
        if (Flags.IsBitSet(18)) { writer.Write(RestrictionReason); }
        if (Flags.IsBitSet(19)) { writer.Write(BotInlinePlaceholder); }
        if (Flags.IsBitSet(22)) { writer.Write(LangCode); }
        if (Flags.IsBitSet(30)) { writer.Write(EmojiStatus); }
        if (Flags2.IsBitSet(0)) { writer.Write(Usernames); }
        if (Flags2.IsBitSet(5)) { writer.Write(StoriesMaxId.Value); }
        if (Flags2.IsBitSet(8)) { writer.Write(Color); }
        if (Flags2.IsBitSet(9)) { writer.Write(ProfileColor); }
        if (Flags2.IsBitSet(12)) { writer.Write(BotActiveUsers.Value); }
        if (Flags2.IsBitSet(14)) { writer.Write(BotVerificationIcon.Value); }
        if (Flags2.IsBitSet(15)) { writer.Write(SendPaidMessagesStars.Value); }
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(10)) { Self = true; }
        if (Flags.IsBitSet(11)) { Contact = true; }
        if (Flags.IsBitSet(12)) { MutualContact = true; }
        if (Flags.IsBitSet(13)) { Deleted = true; }
        if (Flags.IsBitSet(14)) { Bot = true; }
        if (Flags.IsBitSet(15)) { BotChatHistory = true; }
        if (Flags.IsBitSet(16)) { BotNochats = true; }
        if (Flags.IsBitSet(17)) { Verified = true; }
        if (Flags.IsBitSet(18)) { Restricted = true; }
        if (Flags.IsBitSet(20)) { Min = true; }
        if (Flags.IsBitSet(21)) { BotInlineGeo = true; }
        if (Flags.IsBitSet(23)) { Support = true; }
        if (Flags.IsBitSet(24)) { Scam = true; }
        if (Flags.IsBitSet(25)) { ApplyMinPhoto = true; }
        if (Flags.IsBitSet(26)) { Fake = true; }
        if (Flags.IsBitSet(27)) { BotAttachMenu = true; }
        if (Flags.IsBitSet(28)) { Premium = true; }
        if (Flags.IsBitSet(29)) { AttachMenuEnabled = true; }
        Flags2 = buffer.ReadInt32();
        if (Flags2.IsBitSet(1)) { BotCanEdit = true; }
        if (Flags2.IsBitSet(2)) { CloseFriend = true; }
        if (Flags2.IsBitSet(3)) { StoriesHidden = true; }
        if (Flags2.IsBitSet(4)) { StoriesUnavailable = true; }
        if (Flags2.IsBitSet(10)) { ContactRequirePremium = true; }
        if (Flags2.IsBitSet(11)) { BotBusiness = true; }
        if (Flags2.IsBitSet(13)) { BotHasMainApp = true; }
        Id = buffer.ReadInt64();
        if (Flags.IsBitSet(0)) { AccessHash = buffer.ReadInt64(); }
        if (Flags.IsBitSet(1)) { FirstName = buffer.ReadString(); }
        if (Flags.IsBitSet(2)) { LastName = buffer.ReadString(); }
        if (Flags.IsBitSet(3)) { Username = buffer.ReadString(); }
        if (Flags.IsBitSet(4)) { Phone = buffer.ReadString(); }
        if (Flags.IsBitSet(5)) { Photo = buffer.Read<MyTelegram.Schema.IUserProfilePhoto>(); }
        if (Flags.IsBitSet(6)) { Status = buffer.Read<MyTelegram.Schema.IUserStatus>(); }
        if (Flags.IsBitSet(14)) { BotInfoVersion = buffer.ReadInt32(); }
        if (Flags.IsBitSet(18)) { RestrictionReason = buffer.Read<TVector<MyTelegram.Schema.IRestrictionReason>>(); }
        if (Flags.IsBitSet(19)) { BotInlinePlaceholder = buffer.ReadString(); }
        if (Flags.IsBitSet(22)) { LangCode = buffer.ReadString(); }
        if (Flags.IsBitSet(30)) { EmojiStatus = buffer.Read<MyTelegram.Schema.IEmojiStatus>(); }
        if (Flags2.IsBitSet(0)) { Usernames = buffer.Read<TVector<MyTelegram.Schema.IUsername>>(); }
        if (Flags2.IsBitSet(5)) { StoriesMaxId = buffer.ReadInt32(); }
        if (Flags2.IsBitSet(8)) { Color = buffer.Read<MyTelegram.Schema.IPeerColor>(); }
        if (Flags2.IsBitSet(9)) { ProfileColor = buffer.Read<MyTelegram.Schema.IPeerColor>(); }
        if (Flags2.IsBitSet(12)) { BotActiveUsers = buffer.ReadInt32(); }
        if (Flags2.IsBitSet(14)) { BotVerificationIcon = buffer.ReadInt64(); }
        if (Flags2.IsBitSet(15)) { SendPaidMessagesStars = buffer.ReadInt64(); }
    }
}