Bot:: Library Functions
The Bot:: class provides built-in helper functions to simplify working with your Telegram bots in PHP. Here's a list of available methods you can use inside your command code editor:
π¨ Bot::sendMessage()
Bot::sendMessage()Bot::sendMessage($chatId, $message, $parse_type = 'HTML');Description: Sends a text message to a user or group.
Parameters:
chatId(int|string) β The Telegram chat ID to send the message tomessage(string) β The message textparse_type(string) β Message format ("HTML","Markdown")
Example:
Bot::sendMessage($chatId, "Hello <b>World</b>!", "HTML");πΎ Bot::setProperty()
Bot::setProperty()Bot::setProperty('key', 'value');Description: Stores a value using a key. This is useful for saving data like user states, progress, or preferences.
Parameters:
key(string) β The identifier for the datavalue(mixed) β The value to store
Example:
π Bot::getProperty()
Bot::getProperty()Description:
Retrieves a previously stored value using setProperty().
Parameters:
key(string) β The key used when saving the value
Returns:
Stored value (or null if not found)
Example:
β Bot::deleteProperty()
Bot::deleteProperty()Description: Deletes a previously stored property.
Parameters:
key(string) β The key to delete
Example:
π€ Bot::getUser()
Bot::getUser()Description: Gets the stored data of another user by their Telegram chat ID.
Parameters:
chat_id(int|string) β The Telegram chat ID of the user
Returns:
User data array or null if user not found.
Example:
π Bot::getAllUser()
Bot::getAllUser()Description: Retrieves a list of all users that have interacted with the bot.
Returns: Array of user data.
Example:
π’ Bot::runAll()
Bot::runAll()Description: Schedules or runs a command for all users, optionally filtering by chat type.
Parameters:
command(string) β The command to executechat_type(string|null) β Optional: Filter byprivate,group,chanel, etc.time(int|null) β Optional: Unix timestamp of when to run the commandoptions(array) β Optional: Extra data to pass to the command
Example:
π§© Bot::runCommand()
Bot::runCommand()Description: Runs a command as a specific user, optionally scheduled for later.
Parameters:
command(string) β The command nameuserId(int|string) β The user to run the command astime(int|null) β Optional: Unix timestamp to delay executionoptions(array) β Optional: Extra data to include
Example:
π Bot::getPublicCommandUrl()
Bot::getPublicCommandUrl()Description: Generates a public webhook URL to execute a specific command with POST data.
Parameters:
command_id(string) β The command ID to expose via public URL
Returns: A public URL string
Example:
π Bot::getBotLink()
Bot::getBotLink()Description:
Gets the current bot's public Telegram link (e.g., https://t.me/MyBotName).
Returns: A string URL of the bot.
Example:
Last updated