Python: Bot Object
The Bot global — bot-wide data, running commands, scheduling, and broadcasting.
Use Bot for anything that applies to the whole bot rather than a single user.
Bot-wide data
Store and read values that apply to the whole bot — settings, counters, feature flags.
Running commands
Trigger another command from inside your current one, or hand off to the "waiting for next message" flow used for multi-step input.
Scheduling
Run a command later. runCommandAfter survives a restart, so use it for reminders, timeouts, and delayed follow-ups.
Broadcasting
Send a message to every user of the bot.
Pass callback_url to get a webhook notification once the broadcast finishes, with delivery totals.
Bot info
Bot.info() returns your bot's Telegram profile — id, username, and token.
Method reference
| Method | Signature | Notes |
|---|---|---|
Bot.getData | getData(key) | Read a bot-wide value. |
Bot.saveData | saveData(key, value) | Write a bot-wide value. |
Bot.deleteData | deleteData(key) | Remove a bot-wide value. |
Bot.runCommand | runCommand(name) | Run another command immediately. |
Bot.handleNextCommand | handleNextCommand(name) | Route the user’s next message to a given command. |
Bot.runCommandAfter | runCommandAfter(timeout_ms, command, options=None) | Schedule a command to run later. Survives a restart. |
Bot.cancelCommandAfter | cancelCommandAfter(job_id) | Cancel a scheduled command. |
Bot.broadcast | broadcast(payload, callback_url=None) | Send a message to every user of the bot. |
Bot.info | info() | Returns the bot’s Telegram profile, including `.token`. |
Last updated August 11, 2026
Was this page helpful?