Link Search Menu Expand Document

Constructor: user

Back to constructors index

Indicates info about a certain user.

Unless specified otherwise, when updating the local peer database, 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 here » for an implementation of the logic to use when updating the local user peer database.

Attributes:

NameTypeRequiredDescription
selfBoolOptionalWhether this user indicates the currently logged in user
contactBoolOptionalWhether this user is a contact
When updating the local peer database, do not apply changes to this field if the min flag is set.
mutual_contactBoolOptionalWhether this user is a mutual contact.
When updating the local peer database, do not apply changes to this field if the min flag is set.
deletedBoolOptionalWhether the account of this user was deleted.
Changes to this flag should invalidate the local userFull cache for this user ID, see here » for more info.
botBoolOptionalIs this user a bot?
Changes to this flag should invalidate the local userFull cache for this user ID, see here » for more info.
bot_chat_historyBoolOptionalCan the bot see all messages in groups?
bot_nochatsBoolOptionalCan the bot be added to groups?
verifiedBoolOptionalWhether this user is verified
restrictedBoolOptionalAccess to this user must be restricted for the reason specified in restriction_reason
minBoolOptionalSee min
bot_inline_geoBoolOptionalWhether the bot can request our geolocation in inline mode
supportBoolOptionalWhether this is an official support user
scamBoolOptionalThis may be a scam user
apply_min_photoBoolOptionalIf set and min is set, the value of photo can be used to update the local database, see the documentation of that flag for more info.
fakeBoolOptionalIf set, this user was reported by many users as a fake or scam user: be careful when interacting with them.
bot_attach_menuBoolOptionalWhether this bot offers an attachment menu web app
premiumBoolOptionalWhether this user is a Telegram Premium user
Changes to this flag should invalidate the local userFull cache for this user ID, see here » for more info.
Changes to this flag if the self flag is set should also trigger the following calls, to refresh the respective caches:
- The help.getConfig cache
- The messages.getTopReactions cache if the bot flag is not set
attach_menu_enabledBoolOptionalWhether we installed the attachment menu web app offered by this bot.
When updating the local peer database, do not apply changes to this field if the min flag is set.
bot_can_editBoolOptional
close_friendBoolOptional
stories_hiddenBoolOptional
stories_unavailableBoolOptional
contact_require_premiumBoolOptional
bot_businessBoolOptional
bot_has_main_appBoolOptional
idlongYesID of the user, see here » for more info.
access_hashlongOptionalAccess hash of the user, see here » for more info.
If this flag is set, when updating the local peer database, generate a virtual flag called min_access_hash, which is:
- Set to true if min is set AND
-- The phone flag is not set OR
-- The phone flag is set and the associated phone number string is non-empty
- Set to false otherwise.

Then, apply both access_hash and min_access_hash to the local database if:
- min_access_hash is false OR
- min_access_hash is true AND
-- There is no locally cached object for this user OR
-- There is no access_hash in the local cache OR
-- The cached object’s min_access_hash is also true

If the final merged object stored to the database has the min_access_hash field set to true, the related access_hash is only suitable to use in inputPeerPhotoFileLocation », to directly download the profile pictures of users, everywhere else a inputPeer*FromMessage constructor will have to be generated as specified here ».
Bots can also use min access hashes in some conditions, by passing 0 instead of the min access hash.
first_namestringOptionalFirst name.
When updating the local peer database, apply changes to this field only if:
- The min flag is not set OR
- The min flag is set AND
-- The min flag of the locally cached user entry is set.
last_namestringOptionalLast name.
When updating the local peer database, apply changes to this field only if:
- The min flag is not set OR
- The min flag is set AND
-- The min flag of the locally cached user entry is set.
usernamestringOptionalMain active username.
When updating the local peer database, apply changes to this field only if:
- The min flag is not set OR
- The min flag is set AND
-- The min flag of the locally cached user entry is set.
Changes to this flag should invalidate the local userFull cache for this user ID if the above conditions are respected and the bot_can_edit flag is also set.
phonestringOptionalPhone number.
When updating the local peer database, apply changes to this field only if:
- The min flag is not set OR
- The min flag is set AND
-- The min flag of the locally cached user entry is set.
photoUserProfilePhotoOptionalProfile picture of user.
When updating the local peer database, apply changes to this field only if:
- The min flag is not set OR
- The min flag is set AND
-- The apply_min_photo flag is set OR
-- The min flag of the locally cached user entry is set.
statusUserStatusOptionalOnline status of user.
When updating the local peer database, apply changes to this field only if:
- The min flag is not set OR
- The min flag is set AND
-- The min flag of the locally cached user entry is set OR
-- The locally cached user entry is equal to userStatusEmpty.
bot_info_versionintOptionalVersion of the bot_info field in userFull, incremented every time it changes.
Changes to this flag should invalidate the local userFull cache for this user ID, see here » for more info.
restriction_reasonArray of RestrictionReasonOptionalContains the reason why access to this user must be restricted.
bot_inline_placeholderstringOptionalInline placeholder for this inline bot
lang_codestringOptionalLanguage code of the user
emoji_statusEmojiStatusOptionalEmoji status
usernamesArray of UsernameOptional
stories_max_idintOptional
colorPeerColorOptional
profile_colorPeerColorOptional
bot_active_usersintOptional
bot_verification_iconlongOptional

Type: User

Example:

$user = ['_' => 'user', 'self' => Bool, 'contact' => Bool, 'mutual_contact' => Bool, 'deleted' => Bool, 'bot' => Bool, 'bot_chat_history' => Bool, 'bot_nochats' => Bool, 'verified' => Bool, 'restricted' => Bool, 'min' => Bool, 'bot_inline_geo' => Bool, 'support' => Bool, 'scam' => Bool, 'apply_min_photo' => Bool, 'fake' => Bool, 'bot_attach_menu' => Bool, 'premium' => Bool, 'attach_menu_enabled' => Bool, 'bot_can_edit' => Bool, 'close_friend' => Bool, 'stories_hidden' => Bool, 'stories_unavailable' => Bool, 'contact_require_premium' => Bool, 'bot_business' => Bool, 'bot_has_main_app' => Bool, 'id' => long, 'access_hash' => long, 'first_name' => 'string', 'last_name' => 'string', 'username' => 'string', 'phone' => 'string', 'photo' => UserProfilePhoto, 'status' => UserStatus, 'bot_info_version' => int, 'restriction_reason' => [RestrictionReason, RestrictionReason], 'bot_inline_placeholder' => 'string', 'lang_code' => 'string', 'emoji_status' => EmojiStatus, 'usernames' => [Username, Username], 'stories_max_id' => int, 'color' => PeerColor, 'profile_color' => PeerColor, 'bot_active_users' => int, 'bot_verification_icon' => long];