From time to time the owners of Telegram groups are faced with the fact that malicious citizens begin to behave not particularly culturally and pour thousands of bots into your group.
In addition to the fact that it leads to paralysis of any communication in the group due to spam messages "So-and-so joined the group
" and messages from the bots themselves, and it can also end rather sadly if the bots "trained" to leave the group by pressing the "complain" button. If you complain enough, you can lose your Telegram chat! 😱
So what to do if one "beautiful" day you see that you began to add to your group packs of unknown users?
Our defense tactics will consist of three things:
- Adding to a group admin botwhich will automatically ban all new users
- Clearing all those who have already managed to join, before the time when the bot-administrator was added
- Creating difficulties for repeated attacks
Let's go!
Adding an admin bot
If you have a big enough telegram chat and still do not have a bot with which it can be administered and moderate users, it's a big mistake!
There are a dozen solutions to this problem on the market, I personally chose for myself ChatKeeper bot. Bot quite handy, a lot of settings, there is a web interface, in short - I recommend it.
After you add him to your group and make him an administrator, you can send commands to the bot. Just write them in the chat, the bot responds to them. With the full list you you can check it out herebut we are only interested in one at the moment: /kickall
. See the description👇
So, after turning on "attack mode", your newfound admin will ban all the bots that keep pouring into your group. Great, we've stopped the influx of new bots, but what about those who have already joined us?
Cleaning up the bots that entered
First of all, take note of the time when you translated admin bot into attack mode. Let's say it was 12:15. Next, scroll through your group and look for the moment when inarticulate users began to be added to it. Let's say it was at 10:42.
Any new users added between 10:42 and 12:15 must be removed. How do I get a list of these users?
To solve this problem, Telegram provides us with a full log of the actions that took place in the channel. It is called "Recent Actions
"and is available in the group menu.
If you go into this log, there is a button at the top right that allows you to filter the log by different types of actions. We are interested in the action "New members
«.
After applying the filter, we will see a log of all new users added to our group. But what if several thousand bots have managed to get to you? We won't search for them all in the log and delete them by ourselves, will we?
Конечно же нет. Специально для этой задачи мне пришлось написать небольшое консольное приложение, работающее как под Windows так и под MacOS/Linux. Оно делает ровно то, о чём я написал выше: читает лог действий группы за заданный промежуток времени и удаляет новых пользователей.
WARNING: The group's log is stored on Telegram's servers for 48 hours, after which it is deleted, so start clearing it as soon as possible!
The app lives here and this is how to work with it:
- Скачиваете из раздела Releases архив под нужную вам платформу
- Разархивируете в любую папку
- Открываете в этой папке терминал и запускаете программу
Программа запросит все нужные данные:
- Your phone number - everything is quite obvious here.
- Название вашего чата/канала в телеграме. Без собаки!
- The initial date from which the software will purge users. The format is as follows: year, month, day, hours, minutes, seconds. WARNING: the time zone here is UTC+0!!! So if you have, for example, +3, you have to subtract 3 hours to get the right date.
- End date, format is the same as the initial date
- app Id и app Hash — число и хэш для доступа к API Телеграма от вашего лица. Их нужно take it from here.
- Если ваш аккаунт защищён 2FA-паролем, то введите его на соответствующем шаге, иначе просто нажмите Enter.
После того, как вы всё ввели, программа запросит у вас код доступа, который придёт вам в Телеграм. Введите его в консоли.
Then the software starts cleaning all users in a given period of time, and it looks something like this👇
The cleanup rate is 300 users in 13 minutes, which is about 1,500 users per hour. Unfortunately, you won't be able to do it any faster, because Telegram restricts repetitive API requests. So just run the program in the background and let it run.
Note: If you are a programmer, you can speed up the program by adding more admins to the group, then get apiId and apiHash for them, then clean up the group with all the admin accounts you have.
After the software finishes removing bots, go to the third part of the Marlesonian ballet.
Making it more difficult to carry out subsequent attacks on your group
Unless you have non-professionals working against you, the most effective way to limit the inflow of bots to your group is to set some kind of check for new users.
Проверки могут быть разнообразными: нажатие на кнопку «Войти», решение несложной математической задачки, капча и т.п. Мы с вам разберём самый простой вариант — кнопку «Войти».
To implement it, we need the same ChatKeeper bot administrator. Go to the web interface of the bot, select "Settings" - "Greeting"
and put everything approximately as in the screenshot below:
Then save the settings. All, now all users who do not pass the test (ie, do not press the button) will be deleted!
Если вы хотите ещё более сложную для прохождения ботами защиту — вам поможет бот AiLadin. Он запускает отдельный MiniApp в котором выводит стандартную капчу Яндекса.
Другие проверенные автором боты, помогающие с защитой и очисткой Телеграм-каналов/групп:
Conclusion
Поздравляю! Вы только что сделали всё необходимое, чтобы защитить вашу Telegram-группу, желаю ей процветать и здравствовать, успехов!