Skip to content

Commit a1a75ed

Browse files
ChestnutLUOclaude
andcommitted
feat: Ingress reCAPTCHA bot - initial public release
Telegram group verification bot with image recognition challenge. New members must identify Ingress game items from composed images before gaining chat permissions. Features: - Image-based CAPTCHA with configurable challenge parameters - Multi-language support (zh/en) with per-user language preference - Inline keyboard verification with bilingual labels - Cross-session failure tracking (kick on 1st fail, ban on 2nd) - Anti-spam rejoin cooldown - Admin management via bot commands - Docker deployment with SQLite persistence Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
0 parents  commit a1a75ed

46 files changed

Lines changed: 5872 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Telegram Bot Token (required)
2+
# 从 @BotFather 获取
3+
TELEGRAM_BOT_TOKEN=your_bot_token_here
4+
5+
# Bot 管理员 User ID 列表 (逗号分隔)
6+
# 使用 /myid 命令获取你的 User ID
7+
# 示例: BOT_ADMIN_IDS=123456789,987654321
8+
BOT_ADMIN_IDS=
9+
10+
# Database path
11+
DATABASE_PATH=/data/bot.db
12+
13+
# Image cache path
14+
IMAGE_CACHE_PATH=/images
15+
16+
# Verification parameters
17+
VERIFY_IMAGE_COUNT=3 # 验证时显示的图片数量
18+
VERIFY_REQUIRED_CORRECT=2 # 需要答对的数量
19+
VERIFY_TIMEOUT_SECONDS=120 # 验证超时时间(秒)
20+
VERIFY_MAX_RETRY=1 # 最大重试次数
21+
VERIFY_DISTRACTOR_COUNT=3 # 干扰选项数量(总选项 = 图片数量 + 干扰数量)
22+
23+
# Anti-spam: cooldown in seconds for users who rejoin
24+
REJOIN_COOLDOWN_SECONDS=300 # 重新加入冷却时间(秒)

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Data files
2+
/data/
3+
/images/
4+
5+
# Environment files
6+
.env
7+
8+
# IDE
9+
.idea/
10+
.vscode/
11+
*.swp
12+
*.swo
13+
14+
# OS
15+
.DS_Store
16+
Thumbs.db
17+
18+
# Go
19+
*.exe
20+
*.exe~
21+
*.dll
22+
*.so
23+
*.dylib
24+
*.test
25+
*.out
26+
go.work
27+
28+
# Build
29+
/bot
30+
31+
# Claude Code local settings
32+
.claude/

Dockerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Build stage
2+
FROM golang:1.21-alpine AS builder
3+
4+
# Install build dependencies
5+
RUN apk add --no-cache gcc musl-dev sqlite-dev
6+
7+
WORKDIR /app
8+
9+
# Copy go mod files
10+
COPY go.mod go.sum ./
11+
RUN go mod download
12+
13+
# Copy source code
14+
COPY . .
15+
16+
# Build with CGO enabled for SQLite
17+
RUN CGO_ENABLED=1 GOOS=linux go build -a -ldflags '-linkmode external -extldflags "-static"' -o bot ./cmd/bot
18+
19+
# Runtime stage
20+
FROM alpine:3.19
21+
22+
# Install runtime dependencies
23+
RUN apk add --no-cache \
24+
ca-certificates \
25+
tzdata \
26+
sqlite-libs \
27+
ttf-dejavu
28+
29+
# Set timezone
30+
ENV TZ=Asia/Shanghai
31+
32+
WORKDIR /app
33+
34+
# Copy binary from builder
35+
COPY --from=builder /app/bot .
36+
37+
# Create directories for volumes
38+
RUN mkdir -p /data /images
39+
40+
# Run as non-root user
41+
RUN adduser -D -u 1000 botuser
42+
RUN chown -R botuser:botuser /app /data /images
43+
USER botuser
44+
45+
CMD ["./bot"]

0 commit comments

Comments
 (0)