Dev mode
A key-protected zone for administration commands. It is off by default.
With dev mode active you can use the database (.setdb, .getdb, .deldb, .listdb) and install or remove addons with .install and .uninstall (see Plugins).
Enabling it
In the .env set DEV_MODE=true and a long, unique key that you don't use anywhere else, and restart:
DEV_MODE=true DEV_KEY=una_clave_larga_y_unica
With DEV_MODE=false, or without DEV_KEY, the dev mode commands reply with a notice that says what is missing.
Unlocking it from Telegram
| Command | What it does |
|---|---|
.dev yourkey |
Activates dev mode for 10 minutes. The message with the key is deleted automatically |
.dev |
Shows whether it is active and how long is left before it locks |
.dev off |
Locks it immediately |
It locks by itself after 10 minutes and on restart. After 3 wrong keys in a row it locks for 5 minutes. Activations, locks and failed attempts are recorded in the logs group.
The key can't be off, because .dev off is the command to lock.
Database
With dev mode active you can store values without touching files. It needs neither MongoDB nor Redis: they are stored in data/state.json, in a section of their own separate from the bot token.
| Command | What it does |
|---|---|
.setdb key value |
Saves a value |
.getdb key |
Shows a value |
.deldb key |
Deletes a key |
.listdb |
Lists the stored keys |
Keys accept letters, numbers and _ . - (up to 64 characters). Values are stored as text, up to 3500 characters.
Using it from a plugin
# kitdev/plugins/saludo.py
from kitdev.core import db
from kitdev.core.decorators import cmd
from kitdev.core.devmode import dev_only
@cmd("saludo", "Muestra el saludo guardado (dev)")
@dev_only
async def saludo(client, message):
texto = db.get_key("saludo", "no hay saludo guardado")
await message.edit_text(texto)db offers get_key, set_key, del_key and all_keys. The @dev_only decorator goes below @cmd and makes the command only work with dev mode active.
The key protects your account if someone uses your open Telegram without permission, but not if someone already has access to your server, where the key is in the .env next to the session.
Even though the message with the key is deleted, it may be visible for a moment in notifications on other devices. Use a key exclusive to this.
If something doesn't work, see Troubleshooting.