Skip to main content

User

This object represents a Bale user or bot.

📝 Schema

FieldTypeDescription
idintUnique identifier for this user or bot. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.
is_botboolTrue, if this user is a bot
first_namestringUser's or bot's first name.
last_namestringOptional. User's or bot's last name.
usernamestringOptional. User's or bot's username.
language_codestringOptional. IETF language tag of the user's language
NOTE

While the official Bale documentation states that the language_code field is part of the User object, the Bale API itself does not include this field in its responses. Be mindful of this discrepancy when designing your application.

⚙️ Get methods

getId()

Retrieves the User ID.

$userId = $userObject->getId();

getIsBot()

Checks if the user is a bot.

$userIsBot = $userObject->getIsBot();

getFirstName()

Retrieves the first name of the user.

$userFirstName = $userObject->getFirstName();

getLastName()

Retrieves the last name of the user (if available).

$userLastName = $userObject->getLastName();

getUsername()

Retrieves the username of the user (if available).

$userUsername = $userObject->getUsername();

getLanguageCode()

Retrieves the language code associated with the user's language (if available).

$userLanguageCode = $userObject->getLanguageCode();

➕ More

tip

For further information, refer to the official Bale documentation for more details.