TelegramPHP Documentation

BotApi

This file is generated from spec/openapi.json (Bot API 10.3) by tools/generate.php.

Do not edit it by hand - run composer spec:build instead.

The bot's own identity and settings - its name, descriptions, command list, default rights, profile photo, and the managed-bot endpoints.

Mixed into Telegram through Methods. Every method is named exactly as the Bot API names it, takes exactly the fields the Bot API documents (use named arguments for the optional ones), and resolves with the hydrated result.

Tags
link
https://core.telegram.org/bots/api
since

v10.3

Table of Contents

Methods

close()  : PromiseInterface<string|int, bool>
Use this method to close the bot instance before moving it from one local server to another. You need to delete the webhook before calling this method to ensure that the bot isn't launched again after server restart. The method will return error 429 in the first 10 minutes after the bot is launched. Returns True on success. Requires no parameters.
deleteMyCommands()  : PromiseInterface<string|int, bool>
Use this method to delete the list of the bot's commands for the given scope and user language.
getChatMenuButton()  : PromiseInterface<string|int, MenuButton>
Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success.
getManagedBotAccessSettings()  : PromiseInterface<string|int, BotAccessSettings>
Use this method to get the access settings of a managed bot. Returns a BotAccessSettings object on success.
getManagedBotToken()  : PromiseInterface<string|int, string>
Use this method to get the token of a managed bot. Returns the token as String on success.
getMe()  : PromiseInterface<string|int, User>
A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a User object.
getMyCommands()  : PromiseInterface<string|int, Collection<string|int, BotCommand>>
Use this method to get the current list of the bot's commands for the given scope and user language. Returns an Array of BotCommand objects. If commands aren't set, an empty list is returned.
getMyDefaultAdministratorRights()  : PromiseInterface<string|int, ChatAdministratorRights>
Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success.
getMyDescription()  : PromiseInterface<string|int, BotDescription>
Use this method to get the current bot description for the given user language. Returns BotDescription on success.
getMyName()  : PromiseInterface<string|int, BotName>
Use this method to get the current bot name for the given user language. Returns BotName on success.
getMyShortDescription()  : PromiseInterface<string|int, BotShortDescription>
Use this method to get the current bot short description for the given user language. Returns BotShortDescription on success.
logOut()  : PromiseInterface<string|int, bool>
Use this method to log out from the cloud Bot API server before launching the bot locally. You must log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. After a successful call, you can immediately log in on a local server, but will not be able to log in back to the cloud Bot API server for 10 minutes. Returns True on success. Requires no parameters.
removeMyProfilePhoto()  : PromiseInterface<string|int, bool>
Removes the profile photo of the bot. Requires no parameters. Returns True on success.
replaceManagedBotToken()  : PromiseInterface<string|int, string>
Use this method to revoke the current token of a managed bot and generate a new one. Returns the new token as String on success.
setChatMenuButton()  : PromiseInterface<string|int, bool>
Use this method to change the bot's menu button in a private chat, or the default menu button.
setManagedBotAccessSettings()  : PromiseInterface<string|int, bool>
Use this method to change the access settings of a managed bot. Returns True on success.
setMyCommands()  : PromiseInterface<string|int, bool>
Use this method to change the list of the bot's commands. See this manual for more details about bot commands. Returns True on success.
setMyDefaultAdministratorRights()  : PromiseInterface<string|int, bool>
Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are free to modify the list before adding the bot. Returns True on success.
setMyDescription()  : PromiseInterface<string|int, bool>
Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. Returns True on success.
setMyName()  : PromiseInterface<string|int, bool>
Use this method to change the bot's name. Returns True on success.
setMyProfilePhoto()  : PromiseInterface<string|int, bool>
Changes the profile photo of the bot. Returns True on success.
setMyShortDescription()  : PromiseInterface<string|int, bool>
Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot. Returns True on success.

Methods

close()

Use this method to close the bot instance before moving it from one local server to another. You need to delete the webhook before calling this method to ensure that the bot isn't launched again after server restart. The method will return error 429 in the first 10 minutes after the bot is launched. Returns True on success. Requires no parameters.

public close() : PromiseInterface<string|int, bool>
Tags
link
https://core.telegram.org/bots/api#close
Return values
PromiseInterface<string|int, bool>

deleteMyCommands()

Use this method to delete the list of the bot's commands for the given scope and user language.

public deleteMyCommands([BotCommandScope|array<string|int, mixed>|null $scope = null ][, string|null $language_code = null ]) : PromiseInterface<string|int, bool>

After deletion, higher level commands will be shown to affected users. Returns True on success.

Parameters
$scope : BotCommandScope|array<string|int, mixed>|null = null

Optional. A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault.

$language_code : string|null = null

Optional. A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands.

Tags
link
https://core.telegram.org/bots/api#deletemycommands
Return values
PromiseInterface<string|int, bool>

getChatMenuButton()

Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success.

public getChatMenuButton([int|null $chat_id = null ]) : PromiseInterface<string|int, MenuButton>
Parameters
$chat_id : int|null = null

Optional. Unique identifier for the target private chat. If not specified, the bot's default menu button will be returned.

Tags
link
https://core.telegram.org/bots/api#getchatmenubutton
Return values
PromiseInterface<string|int, MenuButton>

getManagedBotToken()

Use this method to get the token of a managed bot. Returns the token as String on success.

public getManagedBotToken(int $user_id) : PromiseInterface<string|int, string>
Parameters
$user_id : int

User identifier of the managed bot whose token will be returned

Tags
link
https://core.telegram.org/bots/api#getmanagedbottoken
Return values
PromiseInterface<string|int, string>

getMe()

A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a User object.

public getMe() : PromiseInterface<string|int, User>
Tags
link
https://core.telegram.org/bots/api#getme
Return values
PromiseInterface<string|int, User>

getMyCommands()

Use this method to get the current list of the bot's commands for the given scope and user language. Returns an Array of BotCommand objects. If commands aren't set, an empty list is returned.

public getMyCommands([BotCommandScope|array<string|int, mixed>|null $scope = null ][, string|null $language_code = null ]) : PromiseInterface<string|int, Collection<string|int, BotCommand>>
Parameters
$scope : BotCommandScope|array<string|int, mixed>|null = null

Optional. A JSON-serialized object, describing scope of users. Defaults to BotCommandScopeDefault.

$language_code : string|null = null

Optional. A two-letter ISO 639-1 language code or an empty string

Tags
link
https://core.telegram.org/bots/api#getmycommands
Return values
PromiseInterface<string|int, Collection<string|int, BotCommand>>

getMyDefaultAdministratorRights()

Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success.

public getMyDefaultAdministratorRights([bool|null $for_channels = null ]) : PromiseInterface<string|int, ChatAdministratorRights>
Parameters
$for_channels : bool|null = null

Optional. Pass True to get default administrator rights of the bot in channels. Otherwise, default administrator rights of the bot for groups and supergroups will be returned.

Tags
link
https://core.telegram.org/bots/api#getmydefaultadministratorrights
Return values
PromiseInterface<string|int, ChatAdministratorRights>

getMyDescription()

Use this method to get the current bot description for the given user language. Returns BotDescription on success.

public getMyDescription([string|null $language_code = null ]) : PromiseInterface<string|int, BotDescription>
Parameters
$language_code : string|null = null

Optional. A two-letter ISO 639-1 language code or an empty string

Tags
link
https://core.telegram.org/bots/api#getmydescription
Return values
PromiseInterface<string|int, BotDescription>

getMyName()

Use this method to get the current bot name for the given user language. Returns BotName on success.

public getMyName([string|null $language_code = null ]) : PromiseInterface<string|int, BotName>
Parameters
$language_code : string|null = null

Optional. A two-letter ISO 639-1 language code or an empty string

Tags
link
https://core.telegram.org/bots/api#getmyname
Return values
PromiseInterface<string|int, BotName>

getMyShortDescription()

Use this method to get the current bot short description for the given user language. Returns BotShortDescription on success.

public getMyShortDescription([string|null $language_code = null ]) : PromiseInterface<string|int, BotShortDescription>
Parameters
$language_code : string|null = null

Optional. A two-letter ISO 639-1 language code or an empty string

Tags
link
https://core.telegram.org/bots/api#getmyshortdescription
Return values
PromiseInterface<string|int, BotShortDescription>

logOut()

Use this method to log out from the cloud Bot API server before launching the bot locally. You must log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. After a successful call, you can immediately log in on a local server, but will not be able to log in back to the cloud Bot API server for 10 minutes. Returns True on success. Requires no parameters.

public logOut() : PromiseInterface<string|int, bool>
Tags
link
https://core.telegram.org/bots/api#logout
Return values
PromiseInterface<string|int, bool>

replaceManagedBotToken()

Use this method to revoke the current token of a managed bot and generate a new one. Returns the new token as String on success.

public replaceManagedBotToken(int $user_id) : PromiseInterface<string|int, string>
Parameters
$user_id : int

User identifier of the managed bot whose token will be replaced

Tags
link
https://core.telegram.org/bots/api#replacemanagedbottoken
Return values
PromiseInterface<string|int, string>

setChatMenuButton()

Use this method to change the bot's menu button in a private chat, or the default menu button.

public setChatMenuButton([int|null $chat_id = null ][, MenuButton|array<string|int, mixed>|null $menu_button = null ]) : PromiseInterface<string|int, bool>

Returns True on success.

Parameters
$chat_id : int|null = null

Optional. Unique identifier for the target private chat. If not specified, the bot's default menu button will be changed.

$menu_button : MenuButton|array<string|int, mixed>|null = null

Optional. A JSON-serialized object for the bot's new menu button. Defaults to MenuButtonDefault.

Tags
link
https://core.telegram.org/bots/api#setchatmenubutton
Return values
PromiseInterface<string|int, bool>

setManagedBotAccessSettings()

Use this method to change the access settings of a managed bot. Returns True on success.

public setManagedBotAccessSettings(int $user_id, bool $is_access_restricted[, array<int, int>|null $added_user_ids = null ]) : PromiseInterface<string|int, bool>
Parameters
$user_id : int

User identifier of the managed bot whose access settings will be changed

$is_access_restricted : bool

Pass True if only selected users can access the bot. The bot's owner can always access it.

$added_user_ids : array<int, int>|null = null

Optional. A JSON-serialized list of up to 10 identifiers of users who will have access to the bot in addition to its owner. Ignored if is_access_restricted is False.

Tags
link
https://core.telegram.org/bots/api#setmanagedbotaccesssettings
Return values
PromiseInterface<string|int, bool>

setMyCommands()

Use this method to change the list of the bot's commands. See this manual for more details about bot commands. Returns True on success.

public setMyCommands(array<int, BotCommand|array<string|int, mixed>> $commands[, BotCommandScope|array<string|int, mixed>|null $scope = null ][, string|null $language_code = null ]) : PromiseInterface<string|int, bool>
Parameters
$commands : array<int, BotCommand|array<string|int, mixed>>

A JSON-serialized list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified.

$scope : BotCommandScope|array<string|int, mixed>|null = null

Optional. A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault.

$language_code : string|null = null

Optional. A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands.

Tags
link
https://core.telegram.org/bots/api#setmycommands
Return values
PromiseInterface<string|int, bool>

setMyDefaultAdministratorRights()

Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are free to modify the list before adding the bot. Returns True on success.

public setMyDefaultAdministratorRights([ChatAdministratorRights|array<string|int, mixed>|null $rights = null ][, bool|null $for_channels = null ]) : PromiseInterface<string|int, bool>
Parameters
$rights : ChatAdministratorRights|array<string|int, mixed>|null = null

Optional. A JSON-serialized object describing new default administrator rights. If not specified, the default administrator rights will be cleared.

$for_channels : bool|null = null

Optional. Pass True to change the default administrator rights of the bot in channels. Otherwise, the default administrator rights of the bot for groups and supergroups will be changed.

Tags
link
https://core.telegram.org/bots/api#setmydefaultadministratorrights
Return values
PromiseInterface<string|int, bool>

setMyDescription()

Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. Returns True on success.

public setMyDescription([string|null $description = null ][, string|null $language_code = null ]) : PromiseInterface<string|int, bool>
Parameters
$description : string|null = null

Optional. New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language.

$language_code : string|null = null

Optional. A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description.

Tags
link
https://core.telegram.org/bots/api#setmydescription
Return values
PromiseInterface<string|int, bool>

setMyName()

Use this method to change the bot's name. Returns True on success.

public setMyName([string|null $name = null ][, string|null $language_code = null ]) : PromiseInterface<string|int, bool>
Parameters
$name : string|null = null

Optional. New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.

$language_code : string|null = null

Optional. A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.

Tags
link
https://core.telegram.org/bots/api#setmyname
Return values
PromiseInterface<string|int, bool>

setMyShortDescription()

Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot. Returns True on success.

public setMyShortDescription([string|null $short_description = null ][, string|null $language_code = null ]) : PromiseInterface<string|int, bool>
Parameters
$short_description : string|null = null

Optional. New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language.

$language_code : string|null = null

Optional. A two-letter ISO 639-1 language code. If empty, the short description will be applied to all users for whose language there is no dedicated short description.

Tags
link
https://core.telegram.org/bots/api#setmyshortdescription
Return values
PromiseInterface<string|int, bool>
On this page

Search results