Telegram Bot to verify if users joining a group are human.
Go to file
J-Rios 36a396f6fd
Language Support: Serbo-Croatian
2024-05-22 20:03:44 +02:00
.github Rename 'sources' directory to 'src' 2024-05-18 23:51:51 +02:00
docker Makefile for usage & move scripts to 'tools' directory 2024-05-19 00:06:08 +02:00
src Language Support: Serbo-Croatian 2024-05-22 20:03:44 +02:00
tools Stats and support scripts 2024-05-19 13:30:28 +02:00
.gitignore Save & Restore all captcha process at Bot restart 2021-09-25 21:02:11 +02:00
LICENSE Initial commit 2018-09-09 22:05:45 +02:00
Makefile Stats and support scripts 2024-05-19 13:30:28 +02:00 Language Support: Serbo-Croatian 2024-05-22 20:03:44 +02:00
dev_requirements.txt Added development Requirements file 2023-12-17 00:50:01 +01:00
requirements.txt Requirements list ordered by alphabet 2023-12-17 00:49:04 +01:00


Telegram Bot to verify if a new member joining a group is a human. Upon a new user join a group, the Bot send an image-based captcha challenge that must be solved to allow the user stay in the group. If the new user fails to solve the captcha within a set time limit, they are removed from the group. Additionally, any message from a new user that includes a URL prior to the completion of the captcha will be considered Spam and will be deleted.


Do you like this Bot? Buy me a coffee :)



Note: Use Python 3.6 or above to install and run the Bot, previous python version are unsupported.

To generate Captchas, the Bot uses multicolor_captcha_generator library, which uses Pillow to generate the images.

  1. Install Pillow prerequisites:

    sudo apt update
    sudo apt install -y libtiff5-dev libjpeg62-turbo-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk
  2. Get the project and install JoinCaptchaBot requirements:

    git clone
    cd TLG_JoinCaptchaBot
    python3 -m pip install -r requirements.txt
  3. Set Telegram Bot account Token (get it from @BotFather) in "src/" file:



All Bot configurations can be done easily by modifying them in the "src/settings.json" file.

For more experienced users, you can use environment variables to setup all that properties (this is really useful for advance deployment when using Virtual Environments and/or Docker to isolate the Bot process execution).


To ease it usage in Linux, a Makefile is provided.

  • Check usage help information:

  • Launch the Bot:

    make run
  • Check if the Bot is running:

    make status
  • Stop the Bot:

    make kill

Systemd service

For systemd based systems, you can setup the Bot as daemon service.

To do that, you need to create a new service description file for the Bot as follow:

[vim or nano] /etc/systemd/system/tlg_joincaptcha_bot.service

File content:

Description=Telegram Join Captcha Bot Daemon



Then, to add the new service into systemd, you should enable it:

systemctl enable --now tlg_joincaptcha_bot.service

Now, you can start the service (Bot) by:

systemctl start tlg_joincaptcha_bot.service

You can check if the service (Bot) is running by:

systemctl status tlg_joincaptcha_bot.service

Remember that, if you wan't to disable it, you should execute:

systemctl disable tlg_joincaptcha_bot.service


You can also run the bot on Docker. This allows easy server migration and automates the installation and setup. Look at the docker specific documentation for more details about how to create a Docker Container for Captcha Bot.

Bot Owner

The Bot Owner can run special commands that no one else can use, like /allowgroup (if the Bot is private, this set allowed groups where the Bot can be used) or /allowuserlist (to make Bot don't ask for captcha to some users, useful for example for blind users).

You can setup a Bot Owner by specifying the Telegram User ID or Alias in "" file. For example:

"BOT_OWNER": "@JoseTLG",

Make Bot Private

By default, the Bot is Public, so any Telegram user can add and use the Bot in any group, but you can set it to be Private so the Bot just can be used in allowed groups (Bot owner allows them with /allow_group command).

You can set Bot to be Private in "" file:


Note: If you have a Public Bot and set it to Private, it will leave any group where is not allowed to be used when a new user joins.

Note: Telegram Private Groups could changes their chat ID when it become a public super-group, so the Bot will leave the group and the owner has to set the new group chat ID with /allow_group.

Scalability (Polling or Webhook)

By default, Bot checks and receives updates from Telegram Servers by Polling (it periodically requests and gets from Telegram Server if there is any new updates in the Bot account corresponding to that Bot Token), this is really simple and can be used for low to median scale Bots. However, you can configure the Bot to use Webhook instead if you expect to handle a large number of users/groups (with webhook, the Telegram Server is the one that will connect to you machine and send updates to the Bot when there is any new update).

To use Webhook instead Polling, you need a signed certificate file in the system, you can create the key file and self-sign the cert through openssl tool:

openssl req -newkey rsa:2048 -sha256 -nodes -keyout private.key -x509 -days 3650 -out cert.pem

Once you have the key and cert files, setup the next lines in "" file to point to expected host system address, port, path and certificate files:

"WEBHOOK_PATH": "/TLG_JoinCaptchaBot"
"WEBHOOK_CERT" : SCRIPT_PATH + "/cert.pem",

(Optional) In case you want to use a reverse proxy between Telegram Server and the system that runs the Bot, you need to setup the Proxy Webhook URL setting:


Then, you need to change Bot connection mode from polling to webhook by setting to True the next configuration:


To go back and use Polling instead Webhook, just set the config back to False:


Adding a New Language

Actual language support is based on external JSON files that contain all bot texts for each language.

To add support for a new language you must follow this steps:

  1. Fork the project repository, clone it and create a new branch to work on it (i.e. named language-support-en).

  2. Copy from one of the existing language JSON files from here to a new one.

  3. Change the name of that file for the language ISO Code of the language that you want.

  4. Translate each text from JSON key values of the file without breaking the JSON format/structure (it should be valid for JSON parsers) and maintaining JSON key names. Keep command names in english (i.e. don't translate "START", "HELP"... /start /help ...) and don't remove special characters (like {}, ", ', \n...) too!

  5. Make a pull request of that branch with the new language file into this repository and wait for it to be accepted.

  6. Then, I will make the integration into source code and actual Bot account (@join_captcha_bot).

  7. Enjoy the new language :)

Languages Contributors