How cnsunyour/tg-guard-bot works
Telegram Guard Bot is a group-moderation bot: Telegram updates enter the application, where join verification and message screening lead to access decisions, moderation actions, or administrator review. Its documented capabilities also include group-management commands, reporting and voting, activity and curfew controls, localization, and large-group cleanup. The graph separates those product stages from detection, persistence, and integrations. Several links reflect README-level capability descriptions; unsampled implementations are represented only at paths supported by the tree, and their internal call relationships are not inferred.
Main entry points: main.py Update runtime · antispam.py Message screening · spam_detector.py Spam detection · verification.py Join verification
Components 27
Bot entry
- Update runtime
src/main.py
Verification and safety
- Join verification
src/bot/handlers/verification.py - Challenge rendering
src/bot/handlers/verification_render.py - CAPTCHA WebApp
captcha-webapp/functions/api/verify.js - ALTCHA service
altcha-backend/verify.php - CAS screening
src/services/cas_service.py - Account status
src/services/user_status_service.py
Detection and moderation
- Message screening
src/bot/handlers/antispam.py - Spam detection
src/services/spam_detector.py - Rule engine
src/ml/rule_engine.py - ML classifier
src/ml/classifier.py - Semantic embeddings
src/ml/embedder.py - AI detection
src/ml/ai_detector.py - Conversation context
src/services/context_service.py - Spam review
src/services/spam_review.py - Enforcement actions
src/services/moderation.py - Reports and votes
src/bot/handlers/moderation.py
Group operations
- Group commands
src/bot/handlers/admin.py - Member cleanup
src/bot/handlers/cleanup.py - Curfew controls
src/bot/handlers/curfew.py - Activity scoring
src/services/activity.py
Runtime services
- Localization
src/core/i18n/translator.py - Group settings
src/repositories/group_repo.py - PostgreSQL
src/core/database.py - Redis state
src/core/redis.py - Telethon client
src/core/telethon_client.py
Other components
- Telegram users
Connections 31
- Telegram users → Update runtime: sends updates
README.md - Update runtime → Join verification: routes joins
src/main.py - Update runtime → Message screening: routes messages
src/main.py - Update runtime → Group commands: routes commands
src/main.py - Join verification → Challenge rendering: renders challenges
src/bot/handlers/verification.py - Join verification → CAPTCHA WebApp: uses CAPTCHA
README.md - CAPTCHA WebApp → ALTCHA service: verifies ALTCHA
README.md - Join verification → CAS screening: checks entrants
src/bot/handlers/verification.py - Join verification → Account status: checks accounts
src/bot/handlers/verification.py - Message screening → Spam detection: screens messages
src/bot/handlers/antispam.py - Message screening → Enforcement actions: enforces outcomes
src/bot/handlers/antispam.py - Message screening → Spam review: opens review
src/bot/handlers/antispam.py - Spam detection → Rule engine: uses rules
- Spam detection → ML classifier: uses classifier
- Spam detection → Semantic embeddings: uses embeddings
- Spam detection → AI detection: uses AI
- Spam detection → Conversation context: uses context
- Reports and votes → Enforcement actions: applies penalties
src/bot/handlers/moderation.py - Group commands → Group settings: updates settings
src/bot/handlers/admin.py - Member cleanup → Telethon client: queries members
src/bot/handlers/cleanup.py - Member cleanup → Telethon client: uses client
src/bot/handlers/cleanup.py - Curfew controls → Group settings: updates curfew
src/bot/handlers/curfew.py - Message screening → Group settings: reads settings
src/bot/handlers/antispam.py - Group settings → PostgreSQL: queries groups
src/repositories/group_repo.py - CAS screening → Redis state: caches results
src/services/cas_service.py - Account status → Redis state: caches results
src/services/user_status_service.py - Update runtime → Localization: initializes languages
src/main.py - Update runtime → PostgreSQL: initializes database
src/main.py - Update runtime → Telethon client: starts client
src/main.py - Message screening → Activity scoring: records activity
src/bot/handlers/antispam.py - Curfew controls → Activity scoring: uses activity