Openclaw Zalo Mod

Zero-token Zalo group moderation plugin for OpenClaw — slash commands, anti-spam, warn system, and memory integration.

Audits

Warn

Install

openclaw plugins install clawhub:openclaw-zalo-mod

🛡️ openclaw-zalo-mod — Zero-Token Zalo Group Moderation

OpenClaw runtime plugin dành cho quản trị nhóm Zalo. Xử lý kiểm duyệt, slash commands, anti-spam với 0 token LLM. Chỉ có tin nhắn @mention mới được chuyển lên AI agent.

License: MIT OpenClaw Plugin Version

🇺🇸 English


✨ Tính năng

Tính năngTokenMô tả
Slash Commands0/noi-quy, /menu, /huong-dan, /groupid, /ownerid, /report, /rules
Warn System0/warn @name [lý do] — theo dõi vi phạm theo member
Anti-Spam0Tự phát hiện tin nhắn lặp, spam link, emoji flood
Admin Notes0/note [text] — ghi chú admin
Memory Sync0/memory — lưu digest vào skills/memory/
Smart Q&A0Tự trả lời "ai bị warn?", "vi phạm?" từ dữ liệu local
ZCA Admin Sync0Tự động lấy creatorId + adminIds từ Zalo API
Owner DM0Nhận lệnh quản trị qua DM riêng với bot

🏗️ Kiến trúc

Tin nhắn Zalo đến
    │
    ├─ /slash command     → Plugin xử lý local (0 token)
    ├─ Spam phát hiện     → Log + block im lặng (0 token)
    ├─ Sticker/media      → Chuyển thành [Sticker] (0 token)
    ├─ "Ai bị warn?"      → Plugin trả lời từ store (0 token)
    │
    └─ @BotName câu hỏi  → Chuyển lên LLM agent (dùng token)

📦 Cài đặt

1. Docker (khuyến nghị — dùng với openclaw-setup)

# Chạy bên trong container
docker exec openclaw-bot openclaw plugins install clawhub:openclaw-zalo-mod --force
docker restart openclaw-bot

2. Native (không Docker)

openclaw plugins install clawhub:openclaw-zalo-mod
openclaw gateway restart

3. Cài thủ công từ source

# Copy source vào thư mục extensions
xcopy /E /I openclaw-zalo-mod "%OPENCLAW_HOME%\extensions\zalo-mod"

# Hoặc trên Linux
cp -r openclaw-zalo-mod ~/.openclaw/extensions/zalo-mod

# Restart gateway
openclaw gateway restart

4. Patch nhanh khi phát triển (Docker)

# Copy file đã sửa vào container
Copy-Item -Path "D:\openclaw-zalo-mod\index.js" -Destination "E:\final\.openclaw\extensions\zalo-mod\index.js" -Force

# Fix quyền (Windows bind mount tạo quyền 777)
docker exec openclaw-bot chmod 644 /root/project/.openclaw/extensions/zalo-mod/index.js

# Restart
docker restart openclaw-bot

⚠️ Lưu ý quyền file: Windows bind mounts tạo file với quyền 0777. OpenClaw sẽ từ chối load plugin có quyền world-writable. Luôn chạy chmod 644 sau khi copy.


⚙️ Cấu hình ban đầu

Bước 1: Xác nhận bot đã load plugin

Kiểm tra log sau khi restart:

[gateway] http server listening (5 plugins: browser, memory-core, openclaw-n8n-facebook-poster, zalo-mod, zalouser; ...)

Plugin phải xuất hiện trong danh sách. Nếu thiếu, kiểm tra quyền file.

Bước 2: Nhận quyền Owner

Gửi tin nhắn DM riêng cho bot:

i'm admin

Bot sẽ tự động ghi ownerId vào config và xác nhận.

Bước 3: Đăng ký Group

Vào group cần quản lý, gửi lệnh:

/bot-rules groupid

Bot sẽ quét session, lấy creatorId + adminIds từ Zalo API, rồi tự ghi vào config.


📋 Danh sách lệnh đầy đủ

👤 Mọi người (trong group)

LệnhMô tả
/{botname}-noi-quyXem nội quy nhóm
/{botname}-menuDanh sách lệnh
/{botname}-huong-danHướng dẫn sử dụng bot
/{botname}-reportBáo cáo vi phạm

🔧 Admin (trong group)

LệnhMô tả
/{botname}-muteTắt bot hoàn toàn
/{botname}-unmuteBật lại bot
/{botname}-warn @name [lý do]Cảnh cáo member
/{botname}-note [text]Ghi chú admin
/{botname}-memory [note]Lưu memory digest

👑 Owner — trong group

LệnhMô tả
/{botname}-rulesXem panel sub-lệnh
/{botname}-rules statusCấu hình group hiện tại
/{botname}-rules groupidThêm group + lấy adminIds/creatorId từ ZCA
/{botname}-rules silent-onBật silent (chỉ reply khi @tag)
/{botname}-rules silent-offTắt silent mode
/{botname}-rules welcome-onBật chào member mới
/{botname}-rules welcome-offTắt chào member mới
/{botname}-rules tracking-onBật ghi lịch sử chat
/{botname}-rules tracking-offTắt ghi lịch sử chat

🔐 Owner — qua DM

LệnhMô tả
/{botname}-rules mute-listTrạng thái mute tất cả groups
/{botname}-rules mute <groupId> on/offMute/unmute group cụ thể
/{botname}-rules mute all on/offMute/unmute tất cả
/{botname}-rules silent-listTrạng thái silent tất cả groups
/{botname}-rules silent <groupId> on/offSilent group cụ thể
/{botname}-rules silent all on/offSilent tất cả
/{botname}-rules welcome-listTrạng thái welcome tất cả
/{botname}-rules welcome <groupId> on/offWelcome group cụ thể
/{botname}-rules welcome all on/offWelcome tất cả
/{botname}-rules tracking-listTrạng thái tracking tất cả
/{botname}-rules tracking <groupId> on/offTracking group cụ thể
/{botname}-rules tracking all on/offTracking tất cả
/{botname}-rules follow-listTheo dõi memory per-group
/{botname}-rules follow <groupId> on/offFollow group cụ thể
/{botname}-rules follow all on/offFollow tất cả
/{botname}-rules dm-listDM whitelist
/{botname}-rules dm-add <tên>Thêm vào DM whitelist
/{botname}-rules dm-remove <tên>Xóa khỏi DM whitelist
/{botname}-rules groupid-listDanh sách tất cả groups
/{botname}-rules groupid-add <groupId>Thêm group từ xa
/{botname}-owneridXem/đặt owner ID

🔐 Owner — qua DM riêng

LệnhMô tả
/bot-rules mute <groupId> on/offMute/unmute group cụ thể
/bot-rules mute all on/offMute/unmute tất cả
/bot-rules silent <groupId> on/offSilent group cụ thể
/bot-rules welcome <groupId> on/offWelcome group cụ thể
/bot-rules tracking <groupId> on/offTracking group cụ thể
/bot-rules dm-add <userId>Thêm vào DM whitelist
/bot-rules groupid-listDanh sách tất cả groups
/bot-owneridXem owner ID hiện tại

🛑 Anti-Spam

LoạiPhát hiện
Repeat SpamCùng tin nhắn gửi N lần trong khoảng thời gian
Link SpamURL rút gọn hoặc link affiliate đáng ngờ
Emoji Flood5+ emoji liên tiếp

Cấu hình trong openclaw.json:

"spamRepeatN": 3,
"spamWindowSeconds": 300

🔧 Yêu cầu

  • OpenClaw >= 2026.3.24
  • Channel zalouser đã được cấu hình và xác thực
  • Node.js >= 20

📄 License

MIT — see LICENSE