How Features Work
Technical details on how BeefyGuard features operate.
Portal Verification System
Verification Flow
- Admin runs
/portalcommand in their group - Bot DMs admin with "Create Portal" button
- Admin selects which private group(s) to protect
- Admin selects a public channel (bot must be admin)
- Admin chooses CAPTCHA type and customizes message
- Bot posts verification message to channel with "Tap to Verify" button
- User clicks button → opens deep link to bot
- Bot sends WebApp button → user opens verification page
- User completes CAPTCHA (button/math/emoji)
- On success, bot generates one-time invite link
- User receives link to join private group
CAPTCHA Types
- Button: Simple "I'm not a robot" click
- Math: Solve simple arithmetic (e.g., 5 + 3 = ?)
- Emoji: Select matching emoji from choices
Security
- Each invite link works once only
- Links expire after use or timeout
- Tokens are cryptographically random
Detection Algorithm
Similarity Matching
The bot uses fuzzy string matching to compare user names to admin names. The similarity threshold determines how similar names must be to trigger detection.
Profile Picture Matching
Uses perceptual hashing (pHash) to compare profile pictures. Generates a hash of each admin's profile picture and compares incoming users' pictures. Hamming distance below threshold triggers detection.
Detection Process
- User joins or changes name/picture
- Bot compares name to admin list
- Bot compares profile picture to admin pictures
- Calculates similarity scores
- If any score exceeds threshold, takes action
Background Scanning
Scan Process
- Bot periodically scans all group members
- Compares each member's name to admin list
- Takes action on matches
- Logs results to log channel (if set)
Scan Intervals
Configurable from 0 (disabled) to 1440 minutes (24 hours). Default is 30 minutes.
Spam Detection System
Cross-Chat Quote Detection
- Bot monitors all messages for
external_replyattribute - Extracts channel ID from the quoted message
- Checks if channel is on internal spam list
- Tracks channel usage count across all groups
- Takes action based on settings
Linked Channel Spam Detection
- Bot detects replies to linked channel posts
- Extracts ALL URLs from message (text + entities)
- Checks URLs against domain whitelist
- If spam link found, takes action
URL Extraction
The bot extracts URLs from:
- Plain text (regex matching)
text_linkentities (hidden hyperlinks)urlentities (marked URLs)
Reply-to-User Detection
- Bot monitors replies from low-activity users
- Checks if target user is admin (allowed) or not (suspicious)
- Tracks attempts per user
- Auto-bans after configurable threshold
First Message Link Detection
- Bot checks if this is user's first message
- Checks user's join date against grace period
- If first message AND within grace period AND contains link → ban
- Established users (messages > 0 OR joined > X hours) are exempt
Action System
Action Types
- Delete: Remove message only
- Warn: Send warning message
- Restrict: Temporarily mute user (configurable duration)
- Kick: Remove user (can rejoin)
- Ban: Permanently ban user
- Alert: Notify admins only (no action)
Action Priority
Actions are configurable per feature. Each spam type can have its own action.
Forum Topic Logging
How It Works
- Admin enables Forum Mode in their log channel (Telegram setting)
- Admin clicks "Auto-Create Topic" in dashboard
- Bot creates a topic named after the group
- All logs for that group go to that topic
- Multiple groups can use one log channel with separate topics
Log Channel Requirements
- Must be a group (not channel)
- Must have Forum Mode enabled
- Bot needs "Manage Topics" permission
One-Tap Mod Actions
Button Types
- Whitelist: Add user to whitelist (skip future detection)
- Ban: Permanently ban user
- Unban: Remove ban
- Mute: Temporarily restrict user (1 hour default)
- Unmute: Remove restrictions
How It Works
- Each log message includes action buttons
- Button callbacks contain user ID and group ID
- When admin clicks, bot verifies admin permissions
- Bot executes action immediately
- Button updates to show action taken
Moderation System
Flood Detection
Tracks message count per user in a time window. When limit exceeded, takes configured action.
Raid Detection
Tracks join count in a time window. When limit exceeded, takes configured action (lock group, ban new joins, etc.).
Filter System
Word Filtering
Scans message text for blacklisted words. Case sensitivity and action are configurable.
Link Filtering
Extracts links from messages and checks against filter rules. Supports allow/deny/whitelist modes.
See Also
- All Features - Complete feature list
- Feature Descriptions - Feature overview