KitDev / Guides / Sudo and fullsudo
Sudo and fullsudo
They give other people access to your userbot and your assistant bot without handing over your account. There are two levels:
| Level | What it can do |
|---|---|
| sudo | Only the list of commands below: lookups and group moderation |
| fullsudo | Every command (addons included), the assistant's settings and its buttons. It is dangerous |
⚠️ A sudo command runs with your account, so it carries your admin rights in every group where you are an admin. A fullsudo can do almost everything you can, including .install (running code on your account), .backup, .restore or .restart. Give it only to someone you fully trust.
Commands
You type these yourself, with your prefix (.). A fullsudo cannot add or remove sudos.
| Command | What it does |
|---|---|
.addsudo [@user\|ID] |
Gives sudo |
.fullsudo [@user\|ID] |
Gives fullsudo |
.delsudo [@user\|ID] |
Removes sudo or fullsudo |
.listsudo |
Table with name (mention), ID, username and level. You, or a fullsudo with !listsudo |
They work with a @user, an ID or by replying to a message from the person. If they already have a level, .addsudo and .fullsudo change it (up or down) and tell you. You can't give sudo to a bot or to yourself. .delsudo @user also works for someone Telegram can no longer resolve, as long as they were on the list. The person is stored by their ID, not their username, which can change.
.listsudo is sent as a table by the assistant; without the assistant (or if Telegram rejects the table) it comes out as a text list.
Sudo panel
Everything the commands do can also be done from the assistant: /start → ⚙️ Settings → 🔑 Sudo. It is a rich message with a compact table (name, ID, username and level) and colored buttons: 🔑 blue for sudo, 👑 red for fullsudo and green for adding.
- Tapping a person opens their card, with ⬆️ Make fullsudo, ⬇️ Make sudo or 🗑 Remove.
- ➕ Sudo and ➕ Fullsudo ask you for the person's
@useror ID, or for you to forward a message from them (it doesn't work if they hide forwarding). - Giving fullsudo from the panel always asks for confirmation, with green (Yes, give fullsudo) and red (Cancel) buttons, both with ➕ Fullsudo and with ⬆️. The commands, on the other hand, give it right away:
.fullsudodoesn't ask. - Only the owner sees the 🔑 Sudo button and can use this section: a fullsudo gets into the other settings, but not this one.
- If Telegram doesn't support the rich message, the panel comes out as normal text with the same colored buttons.
The commands and the panel use the same list, so they can be combined.
What a sudo can use
The person types the command with the sudo prefix, which is ! by default (changed with SUDO_PREFIX in the .env), for example !ban @user spam. That way it is not confused with your own commands, which keep using .: if a sudo types .ban, nothing happens. They type it in a group or in your private chat; your userbot runs it and replies to their message (it can't edit it).
| Type | Commands |
|---|---|
| Lookups | ping, id, info, gifts, help, alive, gbans, warns, toimg, getsticker, stickerinfo, packinfo |
| Moderation | ban, unban, kick, mute, unmute, warn, unwarn, resetwarns, pin, unpin, del, title |
Everything else is refused with a notice (purge, purgeuser, promote, gban, install, restart, backup, restore, snip, settings, PM Permit…), and they can never use an addon's commands. Also:
- A regular sudo cannot act on other people with sudo (for example, ban a fullsudo).
- Nobody can ban you: the command is refused if the target is your account.
- If they ask for
!help, they get the text summary, not the menu with buttons (the buttons are only yours). That summary and some command notices show the.prefix: it is yours, not the one they should type. - If the command fails, the error notice is sent to them as a reply.
The list is ALLOWED in kitdev/core/sudo.py; if you want to give them another command, add it there.
With the assistant
If you enabled the bot's administrator mode, a sudo can use the moderation commands from the list with / (/ban, /mute, /warn, /pin, /del…) in groups where the bot is an admin, with the bot's permissions and without needing to be an admin themselves. The ones not on the list (/purge, /promote…) are still governed by the 👥 Group admins option.
A fullsudo can use every command of the bot and enter the assistant: /start, the menu, settings, broadcast and all its buttons, including confirmations, the update button and the PM Permit and sticker buttons. The confirmations you see as an ephemeral message are shown to a fullsudo as a normal bot message.
What is not opened to a fullsudo: the sudo panel, forwarding of PM Bot messages and replying to them (they stay yours alone) and other people's secret messages.
Things to keep in mind
- PM Permit and AFK: a sudo's command does not go through them. If someone with sudo writes to you in private in any other way, it does; accept them with
.approveif you don't want them to get the notice. - The list is stored in the
sudotable ofdata/kitdev.sqlite3, so it goes into.backupand comes back with.restore. If you restore that backup on another account, those IDs will still have access: check.listsudo. - If you remove someone, they lose access instantly, with no restart.