Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
assimon committed May 29, 2022
0 parents commit 632a657
Show file tree
Hide file tree
Showing 23 changed files with 4,852 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.idea/
runtime/
.env
dist/
config.toml
db/geecaptcha.db
45 changes: 45 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This is an example 1.yml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
project_name: captcha-bot
before:
hooks:
# You may remove this if you don't use go modules.
#- go mod tidy
# you may remove this if you don't need go generate
#- go generate ./...
builds:
- env:
- CGO_ENABLED=0
goos:
- darwin
- freebsd
- linux
- netbsd
- openbsd
- windows
goarch:
- 386
- amd64
- arm
archives:
- name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
files:
- LICENSE
- .env.example
- README.md
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM debian:bullseye-slim
RUN apt-get update -y \
&& apt-get install -y libsqlite3-dev \
&& apt-get install -y sqlite3 \
&& apt-get install -y libc6 \
&& apt-get install -y libc6-dev
RUN mkdir /app
ADD cacert.pem /etc/ssl/certs/
WORKDIR /app
ENTRYPOINT ["/captcha-bot"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 assimon/captcha-bot

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
80 changes: 80 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@

## captcha-bot

用于[Telegram](https://telegram.org/) 加群验证机器人,采用golang编写,支持全平台编译运行。

<p align="center">
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-blue" alt="license MIT"></a>
<a href="https://golang.org"><img src="https://img.shields.io/badge/Golang-1.17-red" alt="Go version 1.17"></a>
<a href="https://github.com/tucnak/telebot"><img src="https://img.shields.io/badge/Telebot Framework-v3-lightgrey" alt="telebot v3"></a>
<a href="https://github.com/assimon/captcha-bot/releases/tag/1.0.0"><img src="https://img.shields.io/badge/version-1.0.0-green" alt="version 1.0.0"></a>
</p>


## 项目初衷
`Telegram`(简称:小飞机),全球知名的非常方便且优雅的匿名IM工具(比微信更伟大的产品)。
但由于该软件的匿名性,导致该软件上各种加群推广机器人满天飞,我们无法无时无刻的判断加入群组的“某个人”是否为推广机器人。
还好`Telegram`为我们提供了非常强大的`Api`,我们可以利用这些Api开发出自动验证的机器人。

如果你是`Telegram`的群组管理员,你可以直接使用本项目部署私有化的验证机器人。
如果你是`开发者`,你可以利用本项目熟悉`Go语言``Telegram`的交互式开发,以便后续利用`Api`开发出自己的机器人!

文档参考:
Telegram Api文档:[Telegram Api](https://core.telegram.org/bots/api)
机器人开发框架:[Telebot](https://github.com/tucnak/telebot)

## 使用方式

### 一、自行编译
此安装方式多用于开发者,需电脑上安装`go语言`环境。
[go语言官网](https://golang.org/)

下载:
```shell
# 下载项目
git clone https://github.com/assimon/captcha-bot && cd captcha-bot && cp .env.example .env
```
编译:
```shell
# 编译
go build -o cbot
# 给予执行权限
chmod +x ./cbot
```
配置:
```shell
cp .example.config.toml config.toml
```
执行:
```shell
# 调试启动
./cbot
# nohup
nohup ./cbot >> run.log 2>&1 &
```

### 二、下载已经编译好的二进制程序
此方式可以直接使用,用于服务器生产环境。
进入打包好的版本列表,下载程序:[https://github.com/assimon/captcha-bot/releases](https://github.com/assimon/captcha-bot/releases)
配置:
```shell
cp .env.example .env
```
运行:
```shell
# linux
# 调试启动
./captcha-bot
# nohup 常驻启动

# windows
captcha-bot.exe
```

## 配置:
请将项目目录下`.env.example`文件重命名为`.env`, 然后对`.env`文件进行编辑即可!
里面的配置项有详细的注释。

## 预览
![禁言.png](https://i.loli.net/2021/09/27/dZQSFKmI23nbXhN.png)
![验证.png](https://i.loli.net/2021/09/27/rEUYVmgt2ve87TL.png)
25 changes: 25 additions & 0 deletions bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package bootstrap

import (
"github.com/assimon/captcha-bot/telegram"
"github.com/assimon/captcha-bot/util/config"
"github.com/assimon/captcha-bot/util/log"
"github.com/assimon/captcha-bot/util/orm"
"os"
"os/signal"
"syscall"
)

// Start 服务启动
func Start() {
config.InitConfig()
log.InitLog()
orm.InitDb()
// 机器人启动
go func() {
telegram.BotStart()
}()
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
<-signalChan
}
Loading

0 comments on commit 632a657

Please sign in to comment.