Telegram bot that sends reCAPTCHA styled image when someone joins a chat.
At first you need to install dependencies:
Ubuntu:
cd ./recaptcha-tg-bot
python3 -m venv env
source ./env/bin/activate
pip install -r requirements.txt
Windows:
cd .\recaptcha-tg-bot
python -m venv env
.\env\Scripts\activate
pip install -r .\requirements.txt
Then you can run the bot:
python -m captcha_bot
But at the first launch it will raise an error, that says you need to fill values in just created settings.json
file. More on this below in Settings File section.
Next step you need to create images
directory. In it create other directories with images on some theme. The name of each directory will be used as captcha image caption.
After all you will be able to run it.
In Telegram add the bot to your chat (also make sure that chats_id
array in settings file has its ID or that it's empty) and promote it to admin.
If you want to get some captcha images, you can direct message the bot (your Telegram ID must be in owner_id
in settings file). It will send you all its commands on the /start
command.
All bot settings stored in settings.json
file. After the first launch there will be placeholders and some of them you will need to replace.
token
- your bot token from BotFatherowner_id
- your Telegram IDchats_id
- chats where bot will work, leave the array empty to make the bot work in any chatinclude_directories
- directory names inimages
directory that will be used in the captcha, leave the array empty to use all directoriesexclude_directories
- directory names inimages
directory that won't be used in the captcha, leave the array empty to use all directoriesno_caption_directories
- directory names inimages
directory that will be used in the captcha, but won't be used as caption of it, leave the array empty to use all directorieskick_delay
- the number of minutes that must pass before the bot kicks the user, if it's0
, bot will never kick the usermessages_text
joined
- text used as caption of the captcha image (allowed keys:username
,first_name
,full_name
,answers
)answer
- text used when user tried to solve the captcha (allowed keys:username
,first_name
,full_name
,correct
,incorrect
,congrats
)no_nums
- congrats when there is no numbers in the user answerno_text
- congrats when there is no text in the user answer<n>_correct
- congrats when there is<n>
correct answersincorrect
- congrats when there is 4 correct and more than 2 incorrect answers
Some of message texts can be formatted with some keys:
username
- '@' symbol with user's usernamefirst_name
- user's first namefull_name
- user's first and last nameanswers
- list of correct captcha answerscorrect
- number of user correct answersincorrect
- number of user incorrect answerscongrats
- text based on number of correct and incorrect answers
For example this text:
some text... {username} | {first_name} | {full_name} | {answers} | {correct} | {incorrect} | {congrats}
will be formatted as:
some text... @dofoerix | Dofoerix | Dofoerix Second Name | 1, 4, 5, 9 | 3 | 1 | Not bad!
This bot uses Roboto font by Christian Robertson. It's licensed under the Apache License, Version 2.0.
Bot itself licensed under the MIT license.