• Stars
    star
    454
  • Rank 96,373 (Top 2 %)
  • Language
    Python
  • License
    GNU General Publi...
  • Created about 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Telegram Bot to verify if users joining a group are human. The Bot sends an image captcha for each new user and kicks any of them who can't solve the captcha in a specified time.

TLG_JoinCaptchaBot

Bot to verify if a new user, who joins a group, is a human. The Bot sends an image captcha for each new user, and kicks any of them that can't solve the captcha in a specified amount of time. Also, any message that contains an URL sent by a new "user" before captcha completion will be considered Spam and will be deleted.

Donate

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

Paypal:

https://www.paypal.me/josrios

Installation

Note: Use Python 3.6 or above to install and run the Bot, previous 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 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 https://github.com/J-Rios/TLG_JoinCaptchaBot
    python3 -m pip install -r TLG_JoinCaptchaBot/requirements.txt
  3. Go to project sources and give execution permission to usage scripts:

    cd TLG_JoinCaptchaBot/sources
    chmod +x run status kill
  4. Specify Telegram Bot account Token (get it from @BotFather) in "settings.py" file:

    'TOKEN' : 'XXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

Usage

To ease usage a run, status, and kill scripts have been provided.

  • Launch the Bot:

    ./run
  • Check if the script is running:

    ./status
  • Stop the Bot:

    ./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/bot.service

File content:

[Unit]
Description=Bot Telegram Daemon
Wants=network-online.target
After=network-online.target

[Service]
Type=forking
WorkingDirectory=/path/to/dir/sources/
ExecStart=/path/to/dir/sources/run
ExecReload=/path/to/dir/sources/kill

[Install]
WantedBy=multi-user.target

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

systemctl enable --now bot.service

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

systemctl disable bot.service

Docker

You can also run the bot on Docker. This allows easy server migration and automates the download of all dependencies. 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 allow groups where the Bot can be used) or /allowuserlist (to make Bot don't ask for captcha to some users, useful for blind users).

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

"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 "settings.py" file:

"BOT_PRIVATE" : True,

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 (requests and get 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 a Webhook instead if you expect to handle a large number of users/groups.

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 "settings.py" file to point to expected Webhook Host address, port and certificate file:

"WEBHOOK_HOST": "Current system IP/DNS here",
"WEBHOOK_PORT": 8443,
"WEBHOOK_CERT" : SCRIPT_PATH + "/cert.pem",
"WEBHOOK_CERT_PRIV_KEY" : SCRIPT_PATH + "/private.key",

To use Polling instead Webhook, just set host value back to none:

"WEBHOOK_HOST": "None",

Environment Variables Setup

You can setup some Bot properties manually changing their values in settings.py file, but also 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).

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

More Repositories

1

Digispark_SoftSerial-INT0

SoftSerial library modified to use INT0 instead PCINT0 interrupt. It allows digispark uses DigiMouse/DigiKeyboard/DigiJoystick at same time SoftSerial. With this, for example, you can use a Bluetooth module to control the mouse or keyboard functionality.
C++
51
star
2

Arduino-esp32sshclient

Arduino library for ESP32 that implements an SSH client to connect and execute commands in a remote Server.
C
36
star
3

uTLGBotLib

Universal Telegram Bot library for Arduino, ESP-IDF and Native (Windows and Linux) devices, that let you create Telegram Bots. You can use it with ESP8266 and ESP32 microcontrollers.
C
17
star
4

TLG_AntiJoin2SpamBot

Telegram Bot that figths against Spammers who join groups to publish their annoying and unwanted info. The Bot will watch for all new users that join the group and don't let them to publish messages that contains URLs until they have been in the group long as an specific time, and they have written an enough number of messages (configurable).
Python
16
star
5

Digispark_DigiUSB-SoftSerial

DigiUSB (V-USB) library modified to allow digispark uses DigiMouse/DigiKeyboard/DigiJoystick with SoftSerial (SoftwareSerial) library at the same time. It provides, for example, to use a Bluetooth module to control the mouse or keyboard.
C
15
star
6

uTLGBotLib-arduino

Micro Telegram Bot library for Arduino, ESP-IDF and Native (Windows and Linux) devices, that let you create Telegram Bots. You can use it with ESP8266 and ESP32 microcontrollers.
C++
9
star
7

TelegramBots

Repository that contains Telegram Bots implemented in Python
Python
7
star
8

Sunxi-Tools-Win

Windows bin2fex & fex2bin converter with GUI
6
star
9

TLG_myrssbot

Telegram Bot that let you subscribe and follow customs RSS, ADF and ATOM Feeds.
Python
6
star
10

ESP8266_UDP

ESP8266 UDP Basic examples
Arduino
6
star
11

Sunxi-Tools-Win-src

Sunxi Tools (bin2fex & fex2bin) base sources for Windows (Non GUI)
Batchfile
5
star
12

TLG_export_chat

Python script that use the Telegram Client API to get all chat messages and export them to a file
Python
4
star
13

ESP32SerialLogger

Connect multiples Serial devices to ESP32 UARTs and access them through a builtin WebServer.
C++
4
star
14

Arduino-RFScomm

Arduino library for secure RF communication with Manchester encode and AES-256 encryption
C++
4
star
15

TLG_export_chat_data

Python script that use the Telegram Client API to get a basic usefull data of a group/channel/chat and export them in json files (chat data, members data and messages data)
Python
4
star
16

minbasecli

A minimal Command Line Interface C++ library implementation with HAL emphasis to be used in different kind of devices and frameworks.
C++
3
star
17

Digispark_Unbricking

How to unbrick digisparks that have fused incorrectly (reset disable) by burning micronucleus bootloader with a High Voltage Programmer
3
star
18

wd_ssh_logins

Linux tool that periodically monitorize and check for successfull SSH logins in the actual system, determine if a new login has occurred, and run the response subprograms (plugins) to act accordingly when a login has been detected.
Python
3
star
19

SUSTerm

An open-source Simple Universal Serial Terminal developed using QT, which is focused in be minimalist and efficiently fast and easy to use.
C++
3
star
20

markdown-pandoc-workbench

Basic workbench skelleton for plain text based documentation generation.
Shell
2
star
21

WiFiStatusLight

RGB Light to monitorize and shows WiFi and Internet status and/or monitorize a remote Server.
C++
2
star
22

METEO

METEO - Environmental monitoring platform (Final Master Project)
C#
2
star
23

OPi_FanTempControl

Orange Pi automatic fan speed controlled by temperature
C
2
star
24

BashTool_ROPI_RCA

BASH Tool to setup HDMI or RCA Video/Audio output in RetrorangePi
Shell
2
star
25

vscode-skelly-c

C/C++ example project skelleton to work and debug with Visual Studio Code using a custom Makefile.
C
2
star
26

bash_serial_ports

Bash scripts to manage list, check, open, close and log from Serial ports
Shell
2
star
27

Attiny85_BT-Relay

Attiny85 based custom board to control a relay via bluetooth (with Arduino code)
Eagle
2
star
28

esp-idf-libssh2

Generate libssh2 library as esp-idf component lib to be compatible and use it in esp-idf projects.
C
2
star
29

ArduinoSerialRubberDucky

Arduino Leonardo/Micro Rubber Ducky device that execute Ducky Script commands received from serial ports.
C++
2
star
30

Attiny85_Rand-Sounds

Attiny85 system that play pseudo-random sounds in a pseudo-random time
Arduino
2
star
31

ESP8266_TelegramBot_Terminal

Basic Telegram Bot Terminal example implementation on the ESP8266 SOC
Arduino
1
star
32

Arduino_ShiftOut

Arduino library for easy control serial-in to parallel-out shift registers (i.e. 74hc595) with Mutex-safe for ESP32 FreeRTOS projects support.
C++
1
star
33

ESP32_Eclipse_Template

Eclipse Template for ESP32-IDF SDK projects
C
1
star
34

tlg-tv-remote

Send IR signal to control TV through a telegram bot using a ESP8266 or ESP32 microcontroller
C++
1
star
35

BashTool_GSerial

BASH Tool to setup USB-OTG Serial Gadget (g_serial)
Shell
1
star
36

UsefulFunctions

Recopilation of usefull functions
C++
1
star
37

ease-imu-lib

IMU ease control class for I2Cdevlib (MP6050)
C++
1
star
38

esp-bt-terios-t3-receiver

ESP32 Bluetooth HID Host to connect, receive and parse data from Terios T3 Bluetooth Gamepad
C
1
star
39

Arduino_RF433_SkipJack

Arduino example of RF-433MHz communication with Manchester encoding and SkipJack encryption
C++
1
star
40

ESP8266_TelegramBot

Basic Telegram Bot example implementation on the ESP8266 SOC
Arduino
1
star
41

cdp-lib

Library to ease binary data encoding/decoding using Conditional DePhase (CDP), also known as Differential Manchester Code (DMC).
C++
1
star
42

AndroidBasic

Recopilation of Basics Android Apps developed with Android Studio
Java
1
star
43

multisterm

Python Serial Terminal for access same port by multiple instances.
Python
1
star
44

ESP8266_NFCRead_Telegram

ESP8266 Read NFC Tags with MFRC522 and send the UID to telegram Bot
Arduino
1
star
45

mqtt_fuota_duino

Let's update the firmware of your IoT devices through MQTT protocol! This is a C++ library that provides the functionality of doing Firmware Update Over The Air (FUOTA), through MQTT protocol, for IoT devices based on Arduino software core, like Espressif ESP32 devices.
C++
1
star
46

TLG_TheKnowThatBot

Telegram Bot to request info about anything, and it search and response with the first Wikipedia sentence of that thing.
Python
1
star
47

easymtproxy

Easy tool to simplify installation and setup of MTProxy for Telegram.
Shell
1
star