forked from mxssl/tg-captcha-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add config file and translate README to English
- Loading branch information
Showing
510 changed files
with
249,188 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
FROM golang:alpine as builder | ||
|
||
# Устанавливаем зависимости | ||
RUN apk add --no-cache ca-certificates curl git | ||
|
||
# Получаем внешние пакеты и компилируем бинарник | ||
WORKDIR /go/src/go-app | ||
WORKDIR /go/src/github.com/mxssl/tg-captcha-bot | ||
COPY . . | ||
RUN go get -u gopkg.in/tucnak/telebot.v2 | ||
RUN CGO_ENABLED=0 GOOS=`go env GOHOSTOS` GOARCH=`go env GOHOSTARCH` go build -o gobot | ||
|
||
# Копируем бинарник в чистый образ Alpine Linux | ||
# install dep package manager | ||
RUN apk add --no-cache ca-certificates curl git | ||
RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh | ||
RUN dep ensure | ||
RUN CGO_ENABLED=0 GOOS=`go env GOHOSTOS` GOARCH=`go env GOHOSTARCH` go build -o bot | ||
|
||
# Copy compiled binary to clear Alpine Linux image | ||
FROM alpine:latest | ||
WORKDIR / | ||
RUN apk add --no-cache ca-certificates | ||
COPY --from=builder /go/src/go-app/gobot . | ||
RUN chmod +x gobot | ||
CMD ["./gobot"] | ||
COPY --from=builder /go/src/github.com/mxssl/tg-captcha-bot . | ||
RUN chmod +x bot | ||
CMD ["./bot"] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Gopkg.toml example | ||
# | ||
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html | ||
# for detailed Gopkg.toml documentation. | ||
# | ||
# required = ["github.com/user/thing/cmd/thing"] | ||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project" | ||
# version = "1.0.0" | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project2" | ||
# branch = "dev" | ||
# source = "github.com/myfork/project2" | ||
# | ||
# [[override]] | ||
# name = "github.com/x/y" | ||
# version = "2.4.0" | ||
# | ||
# [prune] | ||
# non-go = false | ||
# go-tests = true | ||
# unused-packages = true | ||
|
||
|
||
[[constraint]] | ||
branch = "v2" | ||
name = "gopkg.in/tucnak/telebot.v2" | ||
|
||
[prune] | ||
go-tests = true | ||
unused-packages = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
BINARY_NAME=bot | ||
|
||
.PHONY: all build clean lint test dep build-linux build-darwin | ||
|
||
all: build | ||
|
||
build: | ||
go build -o ${BINARY_NAME} -v | ||
|
||
clean: | ||
rm -f ${BINARY_NAME} | ||
|
||
lint: | ||
golangci-lint run -v | ||
|
||
test: | ||
go test -v ./... | ||
|
||
dep: | ||
dep ensure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Telegram Captcha Bot | ||
|
||
Бот для Telegram, который позволяет проверять всех новых посетителей вашей группы на принадлежность к настоящим людям :) | ||
Работает по тому же принципу, что и обычная captcha. | ||
|
||
## Как работает | ||
На каждого нового посетителя бот вешает рестрикт на отправку сообщений и предлагает нажать на кнопку. Если в течении 30ти секунд новый посетитель на кнопку не нажимает, тогда бот банит нового посетителя. Для работы боту надо дать права администратора в группе. | ||
|
||
## Как запустить | ||
Основным способом использования бота является Docker контейнер. Получить инструкцию по установке Docker можно по [ссылке](https://docs.docker.com/install/). Перед началом работы вам нужно получить token у [@BotFather](https://t.me/BotFather) | ||
|
||
#### Скачиваем репозиторий и переходим в директорию | ||
``` | ||
git clone https://github.com/mxssl/tg-captcha-bot.git | ||
cd tg-captcha-bot | ||
``` | ||
|
||
#### Билдим Docker образ | ||
``` | ||
docker build --tag tg-captcha-bot . | ||
``` | ||
|
||
#### Запускаем бота | ||
``` | ||
docker container run \ | ||
--rm \ | ||
--detach \ | ||
--name captcha-bot \ | ||
--env TGTOKEN="Тут указываем токен, который получили от BotFather" \ | ||
tg-captcha-bot | ||
``` | ||
|
||
Посмотреть логи можно командой `docker container logs captcha-bot` | ||
|
||
После запуска контейнера с ботом, можно добавлять бота в нужную группу и выдавать ему административные права. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,63 @@ | ||
# Telegram Captcha Bot | ||
|
||
Бот для Telegram, который позволяет проверять всех новых посетителей вашей группы на принадлежность к настоящим людям :) | ||
Работает по тому же принципу, что и обычная captcha. | ||
|
||
## Как работает | ||
На каждого нового посетителя бот вешает рестрикт на отправку сообщений и предлагает нажать на кнопку. Если в течении 30ти секунд новый посетитель на кнопку не нажимает, тогда бот банит нового посетителя. Для работы боту надо дать права администратора в группе. | ||
|
||
## Как запустить | ||
Основным способом использования бота является Docker контейнер. Получить инструкцию по установке Docker можно по [ссылке](https://docs.docker.com/install/). Перед началом работы вам нужно получить token у [@BotFather](https://t.me/BotFather) | ||
|
||
#### Скачиваем репозиторий и переходим в директорию | ||
This telegram bot validates new users that enter supergroup. Validation works like a simple captcha. | ||
|
||
## How it works | ||
0. Promote bot for administrator privileges in your group | ||
1. New user enter the supergroup | ||
2. Bot restricts new user's ability to send messages | ||
3. Bot show welcome message and captcha button to the user | ||
4. Bot waits 30 seconds for the user to press the button | ||
5. Bot bans the user if she/he didn't press the button within 30 seconds | ||
|
||
## How to run | ||
0. Obtain bot token from [@BotFather](https://t.me/BotFather) | ||
1. Main method to run this bot is Docker container | ||
2. Install [Docker](https://docs.docker.com/install) | ||
3. Install [Docker Compose](https://docs.docker.com/compose/install) | ||
|
||
#### Clone repo | ||
``` | ||
git clone https://github.com/mxssl/tg-captcha-bot.git | ||
cd tg-captcha-bot | ||
``` | ||
|
||
#### Билдим Docker образ | ||
#### Add token from BotFather to env variable in docker-compose.yml | ||
``` | ||
version: '3' | ||
services: | ||
tg-captcha-bot: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
image: tg-captcha-bot:latest | ||
volumes: | ||
- ./config.toml:/config.toml | ||
environment: | ||
- TGTOKEN="your_token" | ||
``` | ||
|
||
#### Build Docker container | ||
``` | ||
docker build --tag tg-captcha-bot . | ||
docker-compose build | ||
``` | ||
|
||
#### Запускаем бота | ||
#### Run container | ||
``` | ||
docker-compose up -d | ||
``` | ||
docker container run \ | ||
--rm \ | ||
--detach \ | ||
--name captcha-bot \ | ||
--env TGTOKEN="Тут указываем токен, который получили от BotFather" \ | ||
tg-captcha-bot | ||
|
||
#### Check that everything is OK | ||
``` | ||
docker-compose ps | ||
docker-compose logs | ||
``` | ||
|
||
Add bot to your supergroup and give it administrator privileges. | ||
|
||
Посмотреть логи можно командой `docker container logs captcha-bot` | ||
#### Customize bot | ||
You can change several bot's settings through the configuration file `config.toml` | ||
|
||
После запуска контейнера с ботом, можно добавлять бота в нужную группу и выдавать ему административные права. | ||
## Contacts | ||
If you have questions feel free to ask me [@mxssl](https://t.me/mxssl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Config file for Telegram Captcha Bot | ||
|
||
# Button text | ||
button_text = "I'm not a robot!" | ||
|
||
# Bot sends this message to new users | ||
welcome_message = "Hello! This is spam protection system. Please press the button in 30 seconds or you will be banned!" | ||
|
||
# Edit welcome message with this text if user passed validation | ||
after_success_message = "User passed the validation." | ||
|
||
# Edit welcome message with this text if user failed validation | ||
after_fail_message = "User didn't pass the validation and banned." | ||
|
||
# Show success and failure messages or delete them. Pick "show" or "del" | ||
print_success_and_fail_messages_strategy = "show" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: '3' | ||
|
||
services: | ||
tg-captcha-bot: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
image: tg-captcha-bot:latest | ||
environment: | ||
- TGTOKEN="your_token" |
Oops, something went wrong.