KitDev / Guides / Group administration
Group administration
The same moderation commands work in two ways:
- With your account (the userbot): they are typed with
.(or yourPREFIX), for example.ban. Your account must be an admin of the group. - With the assistant bot: they are typed with
/, for example/ban. The bot must be an admin of the group. It is enabled in the settings (below).
They only work in groups. Warnings are shared: if you warn with one, the count continues with the other.
How to indicate the person
- Replying to their message:
.ban spam(what follows is the reason). - With their
@usernameor ID:.ban @username spam.
Time. In ban and mute you can put a time after the person: 30m, 2h, 1d or 1w (seconds s, minutes m, hours h, days d, weeks w). Without a time, it is forever. Examples: .mute @username 30m noise, or replying: .mute 2h.
Protections and hierarchy. They don't act on you or on the group owner. With admins, Telegram's hierarchy rules: if your account is the group owner, it can ban, kick, mute and warn any admin; if it is only an admin, it can do so with the admins it promoted (directly or indirectly) and not with the others. Someone with normal sudo can't act on admins; a fullsudo can, with your account's hierarchy. If Telegram rejects an action, the command explains it instead of failing.
Commands
| Command | What it does |
|---|---|
ban [@user] [time] [reason] |
Bans. You can ban someone who has already left |
unban @user |
Unbans |
kick [@user] [reason] |
Kicks (they can join again) |
mute [@user] [time] [reason] |
Mutes: they can't write |
unmute [@user] |
Removes the mute and gives back the group's permissions |
pin [silent] |
Pins the message you reply to. With silent, without notifying |
unpin [all] |
Unpins the message you reply to, or all with all |
purge |
Deletes the messages from the one you reply to up to your command (maximum 1000) |
purgeuser [@user] [-y] |
Deletes all the messages of that person in the group, like Telegram's "Delete all from this user". It asks for confirmation with buttons; with -y it skips it. Only with your account (.) and in supergroups. Writing .purgeuser all also works: all is optional |
del |
Deletes only the message you reply to (and your command) |
The brackets [ ] are optional.
Warnings
| Command | What it does |
|---|---|
warn [@user] [reason] |
Gives a warning |
unwarn [@user] |
Removes the last one |
warns [@user] |
Shows the warnings and their reasons |
resetwarns [@user] |
Deletes them all |
warnlimit 3 |
Warning limit, from 1 to 10 (default 3) |
warnmode ban |
What happens when the limit is reached: ban, kick or mute (default ban) |
When the limit is reached, the penalty is applied and that person's warnings are reset. If the penalty fails (for example, for lack of permissions), the count is not lost.
The limit and the penalty are global: they apply to all groups. Warnings are stored in data/kitdev.sqlite3.
Promoting and removing admins
Only in supergroups (most current groups).
| Command | What it does |
|---|---|
promote [@user] [title] |
Makes admin with the permissions Telegram gives by default |
fullpromote [@user] [title] |
Makes admin with all permissions, including adding administrators |
demote [@user] |
Removes their admin |
title [@user] title |
Changes an admin's title |
Permissions. promote gives: change group info, delete messages, ban users, invite users via link, pin messages and manage voice chats (and manage topics in groups with topics). fullpromote adds add administrators. Neither gives the permission to remain anonymous.
Title. It is optional and can have several words: .promote @user Moderator. Telegram allows up to 16 characters and doesn't allow emojis. If the title fails, the person is still left as admin and the message says so.
Telegram rules:
promotedoesn't touch someone who is already an admin (it could remove permissions by accident). To give them everything usefullpromote, and to remove their role,demote.- You can only remove the admin (or change the title) of someone you promoted.
- The group owner can't be changed.
- Nobody can give permissions they don't have. With the assistant bot, the ones that can't be given are skipped and the message says which were left out.
Assistant bot administrator mode
The assistant bot can use these commands with / in the groups where you add it.
- In the assistant:
/start→ ⚙️ Settings → 🛡 Admin → Enable. - Add the bot to the group and make it admin with the permissions you will need (table below).
- Type the command, for example
/ban @user spam.
When disabled, the bot ignores all commands in groups. It is enabled and disabled instantly.
Who can use them
By default, only you. The bot doesn't answer anyone else. The 👥 Group admins button lets the group's admins use them too, each with the permission the command asks for; if they lack it, the bot tells them. warnlimit and warnmode are always yours only, because they change global settings.
When an admin uses the bot to promote someone, they can only give the permissions they themselves have.
People with sudo use the moderation commands from their list with the bot without needing to be admins, with the bot's permissions; with fullsudo, every command of the bot.
Permissions the bot needs
If the bot lacks a permission, it replies which one. For example: "I'm missing the «Delete messages» permission to use /purge". If it is not an admin, it says it needs to be one and with which permission.
| Bot permission in the group | Commands |
|---|---|
| Ban users | ban, unban, kick, mute, unmute, warn |
| Pin messages | pin, unpin |
| Delete messages | purge, del |
| Add administrators | promote, fullpromote, demote, title |
| None | warns, unwarn, resetwarns, warnlimit, warnmode |
If the bot lacks any of the permissions promote wants to give (for example, pin messages), it gives the ones it can and warns which were left out.
Where it doesn't work
- In the private chat with the bot.
- In KitDev's logs group: there
/banand/unbanare those of PM Bot.
Telegram limits with bots
- A bot can't look up by ID someone it hasn't seen. With
@usernameor replying to their message it always works. - Telegram limits bots' deletion of old messages (about 48 hours), so
/purgemay delete less than expected. - The bot replies with a new message (it can't edit yours). In
purgeit deletes its reply and your command after a few seconds, if it has permission.
If something doesn't work, see Troubleshooting.
Global ban (gban)
Bans someone in all the groups where you are an admin with permission to ban, all at once, and keeps them banned.
| Command | What it does |
|---|---|
gban [@user] [reason] |
Asks with Yes / Cancel buttons and, if you confirm, bans the person in all your groups and adds them to the watched list |
ungban [@user] |
Removes them from the list and unbans them in your groups |
gbans |
Shows the list of global bans |
gbansync |
Checks all your groups now and bans again anyone who lost the ban |
Confirmation. gban doesn't ban immediately: it shows a question with buttons (Yes in green, Cancel in red). If the assistant bot is an admin of the group where you type the command, the question is ephemeral and only you see it; otherwise, it is a normal bot message and only you can press the buttons. Your message with the command is deleted, and the final result also goes to the logs group. The question expires after 5 minutes. Without the assistant there are no buttons: add -y to the command (.gban @user reason -y) to ban without asking.
How the ban is maintained. There are two mechanisms at once:
- On appearing: if someone on the list joins or writes in a group where you can ban, they are banned instantly (and their message is deleted if possible). Each time it happens, a notice reaches the logs group with who it was, where, whether they joined or wrote, the gban reason and whether their message was deleted.
- Every 30 minutes: KitDev checks the banned list of each group and bans again anyone who is no longer there, for example if another admin removed the ban by hand. It also runs once shortly after starting. If it reapplies any ban, it notifies you in the logs group.
Limits. It can't ban group admins (they are counted as "is admin there") or where you don't have the ban permission. The list is stored in data/kitdev.sqlite3. If you restart KitDev, Telegram may not yet know someone you haven't seen in that session: in that case the ban is retried in the next check or when they appear.