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.
city = param_text or "London"
res = libs.HTTP.get(f"https://wttr.in/{city}?format=3")
bot.sendMessage(text=res.text)
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}")
libs.userRes("points").add(10)
total = libs.userRes("points").value()
bot.sendMessage(text=f"+10 points! You now have {int(total)}.")
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
The Telegram user ID of whoever sent the message.
The chat this message came from — use it to reply in group chats too.
The raw text of the incoming message.
List of words after a command. /give apple 5 → params == ['apple', '5']
Everything after the command as one string, unsplit.
Info about the sender. username can be empty — not everyone sets one.
title/type are only set in groups, not private chats.
Sending Messages
Send a text reply.
photo can be a URL, file_id, or raw bytes.
Same pattern as sendPhoto.
Send a native Telegram poll.
E.g. "typing" — shows the typing indicator.
Send to everyone who's ever messaged this specific bot. Returns {'sent': n, 'failed': n}.
Reading Incoming Media
photo is a list (multiple sizes) — [-1] is the largest.
Each has .file_id when present, else None.
Returns the Telegram file path for a file_id.
Returns the raw file bytes.
Keyboards
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.
Regular (non-inline) keyboards.
Available inside a callback-triggered command.
Storage
User.getData(key, default=None)
Per-user storage, scoped to this bot.
bot.getData(key, default=None)
Bot-wide storage (same for every user of this bot). Same as BotData.
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').value()
libs.userRes('coins').cut(5)
Per-user named counter — works for points, coins, XP, anything numeric.
One shared counter across every user of this bot.
Account-wide and admin-scoped variants of the same idea.
Leaderboard — top users by that counter.
Flow Control
The user's very next message routes straight to that command, skipping normal / matching. Great for "what's your name?" style prompts.
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.post(url, data=None, json=None, headers=None, files=None)
Returns an object with .statusCode, .json(), .text, .content.
Chat Administration
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 tocommand_name.bot.setData(key, value)/bot.getData(key, default=None)— quick bot-scoped key/value (wrapsbotData).
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.chat—ChatObjectwithid,type,title.message.from_user—UserObjectwithid,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 tocommand_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 toname.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"])