Dream Bot Builder Dream Bot Builder

Dream Bot Python (DBP) Reference

Every command's code runs in DBP — no import statements needed or allowed. Everything below is available directly.

Copyable Examples

Full, working commands — paste directly into the editor.

Weather lookup
city = param_text or "London"
res = libs.HTTP.get(f"https://wttr.in/{city}?format=3")
bot.sendMessage(text=res.text)
POST to API
res = libs.HTTP.post(
    "https://httpbin.org/post",
    json={"user_id": user_id, "message": text}
)
if res.statusCode == 200:
    bot.sendMessage(text="Sent successfully!")
else:
    bot.sendMessage(text=f"Failed: {res.statusCode}")
Points / Leaderboard
libs.userRes("points").add(10)
total = libs.userRes("points").value()
bot.sendMessage(text=f"+10 points! You now have {int(total)}.")
Multi-step conversation
bot.sendMessage(text="What's your name?")
bot.handleNextCommand("/save_name")

# --- separate command named exactly /save_name ---
User.saveData("name", text)
bot.sendMessage(text=f"Nice to meet you, {text}!")

Basics

user_id

The Telegram user ID of whoever sent the message.

chat_id

The chat this message came from — use it to reply in group chats too.

text

The raw text of the incoming message.

params

List of words after a command. /give apple 5params == ['apple', '5']

param_text

Everything after the command as one string, unsplit.

user.first_name / user.last_name / user.username / user.id

Info about the sender. username can be empty — not everyone sets one.

chat.id / chat.title / chat.type

title/type are only set in groups, not private chats.

Sending Messages

bot.sendMessage(text, reply_markup=None, parse_mode=None)

Send a text reply.

bot.sendPhoto(photo, caption='')

photo can be a URL, file_id, or raw bytes.

bot.sendVideo / sendAudio / sendDocument / sendAnimation / sendSticker

Same pattern as sendPhoto.

bot.sendPoll(question, options)

Send a native Telegram poll.

bot.sendLocation(latitude, longitude)
bot.sendChatAction(action)

E.g. "typing" — shows the typing indicator.

bot.editMessageText(text, message_id=...)
bot.deleteMessage(message_id)
bot.broadcast(text)

Send to everyone who's ever messaged this specific bot. Returns {'sent': n, 'failed': n}.

Reading Incoming Media

message.photo[-1].file_id

photo is a list (multiple sizes) — [-1] is the largest.

message.document / .video / .voice / .audio / .sticker / .animation

Each has .file_id when present, else None.

message.location.latitude / .longitude
message.contact.phone_number / .first_name
bot.getFilePath(file_id)

Returns the Telegram file path for a file_id.

bot.downloadFile(file_path)

Returns the raw file bytes.

Keyboards

kb = InlineKeyboard()
kb.add(InlineKeyboardButton("Text", callback_data="my_id"))
bot.sendMessage(text="...", reply_markup=kb)

Give a command that exact same name as the callback_data to handle the button press.

ReplyKeyboard() / KeyboardButton(...) / ReplyKeyboardRemove()

Regular (non-inline) keyboards.

callback_data / callback_id

Available inside a callback-triggered command.

Storage

User.saveData(key, value)
User.getData(key, default=None)

Per-user storage, scoped to this bot.

bot.setData(key, value)
bot.getData(key, default=None)

Bot-wide storage (same for every user of this bot). Same as BotData.

User.getAllUsers() / User.getAllDataOfUser(user_id)

All of this is also viewable/editable from the bot's User Data / Bot Data tabs in the editor — no code needed to inspect it.

Resources (points, balances, counters)

libs.userRes('coins').add(10)
libs.userRes('coins').value()
libs.userRes('coins').cut(5)

Per-user named counter — works for points, coins, XP, anything numeric.

libs.globalRes('total_visits').add(1)

One shared counter across every user of this bot.

libs.accountRes('name') / libs.adminRes('name')

Account-wide and admin-scoped variants of the same idea.

libs.userRes('coins').getAllData(limit=10)

Leaderboard — top users by that counter.

Flow Control

bot.handleNextCommand('/some_command')

The user's very next message routes straight to that command, skipping normal / matching. Great for "what's your name?" style prompts.

bot.runCommand(name, options={}, delay=0)

Trigger another command right now, or after delay seconds (runs in the background — doesn't block your current reply). options is available as the options dict inside the target command.

HTTP / CSV / Time / Crypto

libs.HTTP.get(url, headers=None)
libs.HTTP.post(url, data=None, json=None, headers=None, files=None)

Returns an object with .statusCode, .json(), .text, .content.

libs.DateAndTime.now('UTC') / .date_now() / .time()
libs.CSV.add_row(name, row) / .get(name, index) / .edit_row(...) / .delete(...)
libs.Crypto.get_price(symbol) / .convert(from, to, amount)

Chat Administration

bot.banChatMember(user_id) / bot.unbanChatMember(user_id)
bot.getChatMember(user_id)
bot.pinChatMessage(message_id) / bot.unpinChatMessage()
bot.forwardMessage(from_chat_id, message_id)

Complete Function Reference

Every helper injected into your command's execution environment. Grouped by object with a one-line brief and a tiny example.

bot — Telegram messaging & chat control

The main handle. Everything you send back to the user goes through bot.

  • bot.sendMessage(text, reply_markup=None, parse_mode=None) — send a text message. Example: bot.sendMessage("Hello!")
  • bot.sendPhoto(photo, caption="") — send a photo by URL, file_id, or bytes.
  • bot.sendVideo(video, caption=None) — send a video.
  • bot.sendDocument(document, caption=None) — send a file/document.
  • bot.sendAudio(audio, caption=None) — send an audio track.
  • bot.sendSticker(sticker) — send a sticker by file_id.
  • bot.sendAnimation(animation, caption=None) — send a GIF/animation.
  • bot.sendPoll(question, options) — send a poll. Example: bot.sendPoll("Pick one", ["A","B"])
  • bot.sendDice(emoji="🎲") — send an animated dice/emoji roll.
  • bot.sendChatAction(action) — show "typing…", "uploading photo…" etc.
  • bot.sendLocation(latitude, longitude) — send a map pin.
  • bot.sendContact(phone_number, first_name) — send a contact card.
  • bot.sendMediaGroup(media) — send an album (2–10 media items).
  • bot.editMessageText(text, message_id=None) — edit a message you sent earlier.
  • bot.deleteMessage(message_id) — delete a message by id.
  • bot.forwardMessage(from_chat_id, message_id) — forward from another chat.
  • bot.answerCallbackQuery(callback_query_id, text="", show_alert=False) — reply to an inline-keyboard tap.
  • bot.answerInlineQuery(inline_query_id, results) — answer inline queries (@yourbot search).
  • bot.pinChatMessage(message_id) / bot.unpinChatMessage(message_id=None)
  • bot.banChatMember(user_id) / bot.unbanChatMember(user_id) — group moderation.
  • bot.getChatMember(user_id) — fetch a member's role/status in the chat.
  • bot.getFilePath(file_id) / bot.downloadFile(file_path) — download attachments.
  • bot.setMenuButton(text, url, chat_id=None) — set the blue web-app menu button.
  • bot.broadcast(text, reply_markup=None, parse_mode=None) — send to every known bot user. Use with care.
  • bot.runCommand(command_name, options=None, delay=0, user_id=None, chat_id=None) — invoke another command in this bot.
  • bot.handleNextCommand(command_name) — shortcut: route this user's next message to command_name.
  • bot.setData(key, value) / bot.getData(key, default=None) — quick bot-scoped key/value (wraps botData).

message — the incoming update

  • message.text — raw message text.
  • message.chat_id — chat identifier (user or group).
  • message.user_id — sender's Telegram id.
  • message.username — sender's @username, if any.
  • message.chatChatObject with id, type, title.
  • message.from_userUserObject with id, first_name, last_name, username, language_code.

userData — per-user key/value store

  • userData.saveData(key, value, user=None) — save a value for the current (or specified) user.
  • userData.getData(key, default=None, user=None) — fetch a saved value.
  • userData.deleteData(key, user=None) — remove one key.
  • userData.getAllUsers() — list every user_id that has stored data.
  • userData.getAllDataOfUser(user) — full document for a user.
  • userData.deleteAllData() — wipe everything (all users).
  • userData.deleteAllDataOfUser(user) — wipe one user.
userData.saveData("name", "Alice")
name = userData.getData("name", default="friend")
bot.sendMessage(f"Hi {name}!")

botData — bot-wide key/value store

  • botData.saveData(key, value) — persist a value at the bot level.
  • botData.getData(key, default=None) — read it back.
  • botData.deleteData(key) — remove one key.
  • botData.getAllData() — dict of everything.
  • botData.deleteAll() — wipe every key.

userRes / accountRes / globalRes / adminRes — numeric resources

Counters and balances with atomic add/cut. Scope decides who owns the value.

  • Libs.userRes(name).value() — read the current user's counter.
  • .set(value) — set an exact number.
  • .add(amount) — atomically add.
  • .cut(amount) — atomically subtract.
  • .reset() — set to 0.
  • .delete() — remove the record entirely.
  • .getAllData(limit=100) — top holders (for leaderboards).
coins = Libs.userRes("coins")
coins.add(10)
bot.sendMessage(f"You now have {coins.value()} coins")

nextCommand — multi-step conversations

  • nextCommand.handleNextCommand(command_name, user_id=None) — route the user's next message to command_name.
  • nextCommand.checkNextCommand(user_id) — see what's queued for this user.
bot.sendMessage("What's your name?")
nextCommand.handleNextCommand("save_name")

Libs.CSV — CSV file helper

  • Libs.CSV.add_row(name, row) — append a row to name.csv.
  • Libs.CSV.get(name, index) — read row by index.
  • Libs.CSV.edit_row(name, index, row) — overwrite a row.
  • Libs.CSV.delete(name, index) — remove a row.

Libs.DateTime — dates & times

  • Libs.DateTime.now(tz="UTC") — full ISO datetime string.
  • Libs.DateTime.date_now() — today's date.
  • Libs.DateTime.time() — current time.

Libs.Crypto — crypto prices & conversion

  • Libs.Crypto.get_price(symbol) — spot price for a symbol (e.g. "BTC").
  • Libs.Crypto.convert(from_curr, to_curr, amount) — convert between currencies.

Libs.HTTP — outbound HTTP

  • Libs.HTTP.get(url, headers=None) — GET request.
  • Libs.HTTP.post(url, data=None, json=None, headers=None) — POST request.
  • Libs.HTTP.put / patch / delete(...) — full REST toolkit.
  • Every call returns an HTTPResponse — use .json(), .text, .status_code.
r = Libs.HTTP.get("https://api.example.com/user/42")
data = r.json()
bot.sendMessage(data["name"])
// Copy snippet function function copySnippet(btn) { const pre = btn.closest('.docs-example-card').querySelector('pre'); const code = pre.textContent; navigator.clipboard.writeText(code).then(() => { const original = btn.textContent; btn.textContent = '✓ Copied!'; setTimeout(() => btn.textContent = original, 1500); }); } // Search functionality document.getElementById('docsSearch').addEventListener('input', function(e) { const query = e.target.value.toLowerCase(); const sections = document.querySelectorAll('.docs-section'); const navLinks = document.querySelectorAll('.docs-nav a'); sections.forEach(section => { const text = section.textContent.toLowerCase(); if (text.includes(query) || query === '') { section.style.display = 'block'; } else { section.style.display = 'none'; } }); // Highlight matching nav links navLinks.forEach(link => { const href = link.getAttribute('href'); if (href) { const target = document.querySelector(href); if (target && target.style.display !== 'none') { link.style.display = 'block'; } else if (query !== '') { link.style.display = 'none'; } else { link.style.display = 'block'; } } }); }); // Active nav highlighting on scroll document.addEventListener('scroll', function() { const sections = document.querySelectorAll('.docs-section'); const navLinks = document.querySelectorAll('.docs-nav a'); let current = ''; sections.forEach(section => { const sectionTop = section.offsetTop - 100; if (window.scrollY >= sectionTop) { current = section.getAttribute('id'); } }); navLinks.forEach(link => { link.classList.remove('active'); if (link.getAttribute('href') === '#' + current) { link.classList.add('active'); } }); });