Skip to main content

Anti-Ban Protection

Starting with UDMODZ Edition v6.1.3, every socket created via makeWASocket is automatically wrapped with baileys-antiban — a full-featured anti-ban middleware layer.

No extra code needed. It just works.


How It Works

When you call makeWASocket(config), the returned socket is transparently proxied through the anti-ban middleware unless you opt out. Every sendMessage call is:

  • Rate-limited with Gaussian jitter (human-like timing, not a fixed interval)
  • Warmed up gradually on a fresh session (no sudden burst from cold start)
  • Health-monitored for bad MAC counts, disconnection patterns, and ban risk signals

No config needed. Antiban is on by default:

import makeWASocket, { useMultiFileAuthState } from 'amiudmodz'
import P from 'pino'

const { state, saveCreds } = await useMultiFileAuthState('auth_info')

const socket = makeWASocket({
logger: P({ level: 'silent' }),
printQRInTerminal: false,
auth: state,
version,
// antiban is enabled automatically — no config required!
})

socket.ev.on('creds.update', saveCreds)

The socket returned has the full Baileys API plus an .antiban property for stats and control.


Checking Anti-Ban Stats

const stats = socket.antiban.getStats()
console.log(stats)
// {
// sendCount: 42,
// rateLimiterStats: { queued: 0, sent: 42 },
// healthStatus: { banRisk: 'low', badMacCount: 0 },
// warmUpState: { isWarmedUp: true, sentSinceStart: 42 }
// }

Disabling Anti-Ban

If you want to manage rate limiting yourself, pass antiban: false:

const socket = makeWASocket({
auth: state,
antiban: false, // opt out — raw socket, no middleware
})
warning

Disabling anti-ban may expose your number to WhatsApp's automated ban systems, especially if you send messages in bulk or on a fresh session.


Custom Anti-Ban Configuration

You can pass any AntiBanConfig options directly:

const socket = makeWASocket({
auth: state,

antiban: {
// Use a named preset as the baseline
preset: 'moderate', // 'conservative' | 'moderate' | 'aggressive' | 'high-volume'

// Fine-tune rate limits
maxPerMinute: 12,

// Warmup options — gradually increase send rate on cold sessions
warmUp: {
enabled: true,
durationMs: 10 * 60 * 1000, // 10-minute warmup
},
}
})

Available Presets

PresetMax/MinBest For
conservative~5/minNew numbers, high-risk environments
moderate (default)~15/minMost personal/small bots
aggressive~30/minEstablished numbers, higher volume
high-volume~60/minApproved business API replacements

Anti-Ban Features Included

FeatureDescription
Gaussian Jitter Rate LimiterHuman-like message timing with randomised delays
Warmup SchedulerGradually ramps send rate on fresh/reconnected sessions
Session Health MonitorTracks bad MACs, disconnects, and ban risk level
Deaf Session DetectorDetects dead WebSocket connections that still ping-pong
Legitimacy Signal InjectionOptional: simulated read gaps, typing pauses
Group Operation GuardRate-limits group add/remove/create to prevent spam flags
JID Circuit BreakerBlocks sends to problematic recipients after threshold failures
Post-Reconnect ThrottleSlows down messages after a reconnect to avoid burst detection
Reply Ratio GuardTracks incoming vs outgoing ratio and warns on spam-like patterns

Note: Poll vote helper and channel auto-follow features from baileys-antiban are not enabled in this integration (as per UDMODZ policy).


Advanced: Accessing the AntiBan Controller Directly

// Get the full AntiBan controller
const antiban = socket.antiban

// Pause sending (e.g., before a risky operation)
antiban.pause()

// Resume
antiban.resume()

// Get current health status
const health = antiban.health.getStatus()
console.log(health.banRisk) // 'low' | 'medium' | 'high' | 'critical'

// Get rate limiter stats
const rl = antiban.rateLimiter.getStats()
console.log(rl.queued) // messages queued waiting to send