Skip to main content
Bots Limited uses a custom execution environment called BLP (Bots.LT Python). BLP is built on top of standard Python 3, but with specific security restrictions to ensure safe execution on our cloud platform.

What is Restricted Python?

When you write commands in Bots Limited, you are writing Python code. However, you cannot use operations that could compromise the server:
  • import statements are blocked.
  • open(), eval(), and exec() are blocked.
  • Infinite loops (while True) are heavily restricted or blocked to prevent execution timeouts.
Instead of importing modules, Bots Limited injects safe Built-in Objects and Variables directly into your code.

Global Variables

Whenever a command runs, the following variables are automatically available in your code. You do NOT need to define or import them.

User & Chat Identification

chat_id / u

An integer representing the Telegram ID of the user or group that triggered the command. Both chat_id and u are identical and can be used interchangeably.
BLP Example

message

A dictionary containing the raw Telegram Message object.
  • message.text: The text the user sent.
  • message.message_id: The ID of the message.
  • message.from.id: The sender’s user ID.
  • message.from.first_name: The sender’s first name.
  • message.from.username: The sender’s username.

call

If the command was triggered by an Inline Keyboard Button click (Callback Query), this variable contains the Telegram CallbackQuery object. Otherwise, it is None.
  • call.id: The unique ID for the query.
  • call.data: The callback data attached to the button.

Bot Details

You can access your bot’s dynamic details using these injected variables:

bot_username

The Telegram username of your bot (e.g., my_awesome_bot).

bot_token

Your bot’s private API token.

bot_name

The display name of your bot.

bot_id

The unique identifier of your bot on the Bots Limited platform. Note: You can also access these variables via the Bot object (e.g., Bot.username, Bot.token, Bot.first_name, Bot.userstat, Bot.owner_email).

Bot vs bot (The Core Bot Object)

In BLP, the Telegram engine is injected as the Bot object (which handles all API calls like Bot.sendMessage). For convenience and flexibility, Bot and bot are 100% interchangeable aliases. Every method that works on Bot also works identically on bot.
BLP Example

Commands & Inputs

command

The raw string of the command that was matched.

params

Any text that comes after the command. For example, if the user sends /start 12345, the command variable is /start and params is 12345.

Built-in Modules

We provide safe wrappers for common Python functionalities.

time

A safe wrapper for time functions.
  • time.time(): Returns the current UNIX timestamp.

re / regex

The standard Python re module for regular expressions.

hashlib & base64

For cryptography and encoding.

jsondumps & bf_json

Functions for parsing and formatting JSON strings safely.

Data Storage Scopes

You do not need an external database. Bots Limited provides a blazing-fast built-in Key-Value (KV) store accessible via three scopes:

1. User (User Scope)

Data is saved for the specific user (chat_id) interacting with the bot.
BLP Example

2. Bot (Bot Scope)

Data is saved globally for the entire bot (e.g., global stats, settings).
BLP Example

3. Api (Global/Developer Scope)

Used for data shared across multiple bots owned by the same developer.
BLP Example