WP Manifestindependent plugin directory
manifest / security / lingxiguard

LingxiGuard 灵犀盾

WordPress AI comment spam filter plugin — AI 反垃圾评论插件. Context-aware spam detection via OpenAI-compatible Chat Completions API (DeepSeek by default); spam goes straight to Trash. WordPress 5.8+ / PHP 7.4+

by onbed.cn · github.com/hanhan666666/lingxiguard

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/hanhan666666/lingxiguard/archive/refs/heads/main.zip

Readme

🛡️ LingxiGuard 灵犀盾 — AI Comment Spam Filter for WordPress / AI 反垃圾评论插件

AI-powered WordPress comment spam filter. Automatically detects spam and harmful comments by sending both the comment and the article content to an OpenAI-compatible Chat Completions API (DeepSeek by default), then moves spam straight to the trash. 装上就能用的 AI 反垃圾评论插件:把「评论 + 文章内容」交给 AI 判断,垃圾评论自动丢进回收站。

Keywords: WordPress plugin, AI comment spam filter, anti-spam, comment moderation, DeepSeek, OpenAI-compatible API, 评论过滤, 反垃圾评论, 评论审核


Table of Contents / 目录


✨ Features / 功能特性

English:

  • 🗑️ Trash instead of delete — spam comments go to the WordPress Trash, recoverable anytime
  • 🧠 Context-aware judgment — sends the article title + content together with the comment, so AI judges in context, not just keywords
  • 🔌 Any OpenAI-compatible API — configurable API base URL (default https://api.deepseek.com) and any model name (deepseek-v4-flash, deepseek-v4-pro, gpt-4o-mini, ...)
  • 🧪 One-click test — verify your API key works with a sample spam comment before going live
  • 💾 Smart caching — identical comments are judged only once per hour (saves tokens)
  • 🛡️ Fail-open by default — if the API errors, comments pass through instead of being wrongly deleted (switchable)
  • 👤 Skip logged-in users — admins and registered users are never blocked
  • 📋 Audit log — last 100 decisions with AI reasoning, right on the settings page
  • 🌍 Bilingual UI — Chinese-first interface with English descriptions

中文:

  • 🗑️ 进回收站不直接删:垃圾评论放入回收站,误判可随时恢复
  • 🧠 结合文章上下文判断:把文章标题和内容一起发给 AI,判断更准,不是简单关键词匹配
  • 🔌 兼容任意 OpenAI 格式 API:API 地址可配置(默认 DeepSeek),模型名随意填
  • 🧪 一键测试:上线前用示例垃圾评论验证 API 是否正常工作
  • 💾 智能缓存:相同评论 1 小时内只调用一次 AI,省 token
  • 🛡️ 失败默认放行:API 故障时评论正常通过,不会误删(可切换为严格模式)
  • 👤 跳过已登录用户:管理员和注册用户评论不经过 AI
  • 📋 审核日志:设置页直接查看最近 100 条 AI 判断及理由
  • 🎛️ 极简设置页:装上就能用,高级选项全部折叠

🚀 Installation / 安装

English:

  1. Download the latest release zip, or clone this repo into wp-content/plugins/lingxiguard/
  2. Activate the plugin in Plugins → Installed Plugins
  3. Go to Settings → AI Comment Filter
  4. Paste your API key (create one at platform.deepseek.com), the API base URL and model are pre-filled with DeepSeek defaults
  5. Click 🧪 One-click test — done!

中文:

  1. 下载最新版 zip,或把本仓库克隆到 wp-content/plugins/lingxiguard/
  2. 在后台「插件 → 已安装的插件」中启用
  3. 进入「设置 → AI 评论过滤」
  4. 填入 API Key(在 platform.deepseek.com 创建),API 地址和模型已默认填好 DeepSeek 配置
  5. 点「🧪 一键测试」验证通过即可,完事!

⚙️ Configuration / 配置

English:

Setting Default Description
API Key Secret key from your AI provider
API Base URL https://api.deepseek.com Any OpenAI Chat Completions compatible base URL; /chat/completions is appended automatically
Model deepseek-v4-flash Free-text model name
Thinking mode Max thinking (thinking: enabled + reasoning_effort: high) Recommended for DeepSeek V4; disable for APIs without thinking support
Timeout 30 s Max wait for the AI response
Article length sent to AI 2000 chars Truncate long posts to save tokens
Skip logged-in users On Admins / registered users bypass AI check
On API failure Approve (fail-open) Or switch to "trash" for strict mode
Audit log On Keeps last 100 decisions

中文:

设置项 默认值 说明
API Key AI 服务商密钥
API 地址 https://api.deepseek.com 任意 OpenAI Chat Completions 兼容地址,自动拼接 /chat/completions
模型名称 deepseek-v4-flash 手动输入,想换就换
思考模式 最大思考(thinking: enabled + reasoning_effort: high DeepSeek V4 推荐;其他 API 不支持时可关闭
请求超时 30 秒 AI 响应最长等待时间
发送给 AI 的文章长度 2000 字符 长文截断,省 token
跳过已登录用户 管理员/注册用户评论不审核
API 调用失败时 放行 可切换为「也进回收站」严格模式
审核日志 保留最近 100 条判断记录

🔌 API Compatibility / API 兼容

English:

Uses the standard OpenAI Chat Completions protocol:

POST {api_base}/chat/completions
Authorization: Bearer {api_key}
Content-Type: application/json

{
  "model": "deepseek-v4-flash",
  "messages": [...],
  "response_format": { "type": "json_object" },
  "thinking": { "type": "enabled" },          // when thinking mode is on
  "reasoning_effort": "high"                  // when thinking mode is on
}

Works with DeepSeek, OpenAI, and any self-hosted / relay gateway that implements the same protocol. The AI must reply with a strict JSON object: {"spam": true|false, "category": "spam"|"harmful"|"normal", "reason": "..."}.

中文:

采用标准 OpenAI Chat Completions 协议(见上方示例)。兼容 DeepSeek、OpenAI 以及任何实现该协议的自建/中转服务。AI 必须返回严格 JSON:{"spam": true|false, "category": "spam"|"harmful"|"normal", "reason": "..."}

🧠 How It Works / 工作原理

English:

  1. A visitor submits a comment
  2. WordPress runs its built-in checks first (Disallowed Comment Keys → spam, Moderation Keys → pending)
  3. Only comments WordPress actually approves reach the plugin's pre_comment_approved hook — blocked ones skip the AI entirely, saving tokens
  4. Article title + content (truncated) + comment + author info are sent to the AI
  5. AI returns spam: true/false
  6. Spam → stored directly as trash (recoverable); normal → proceeds through the original moderation flow
  7. Result cached for 1 hour; API errors fail open (configurable)

中文:

  1. 访客提交评论
  2. WordPress 先跑内置检查(评论黑名单关键词 → 垃圾评论,审核关键词 → 待审)
  3. 只有 WordPress 放行的评论才会进入插件的 pre_comment_approved 钩子——已被拦下的评论不再调 AI,省 token
  4. 把「文章标题 + 内容(截断)+ 评论 + 评论者信息」发给 AI
  5. AI 返回 spam: true/false
  6. 垃圾 → 直接以 trash(回收站) 状态入库(可恢复);正常 → 走原有审核流程
  7. 结果缓存 1 小时;API 出错默认放行(可配置)

📊 Screenshots / 界面预览

设置页 审核记录
极简:三个输入框 + 一键测试,高级设置折叠 每条显示 AI 判断结果与理由

📦 Development / Build / 开发与打包

English: The plugin is a single PHP file — no build step required. To package a release zip:

zip -r lingxiguard.zip lingxiguard/

中文: 插件只有一个 PHP 文件,无需构建。打包发布 zip 如上。

📝 Changelog / 更新日志

See CHANGELOG.md for the full history. 完整更新日志见 CHANGELOG.md

📄 License / 许可证

GPL-2.0-or-later — free software. See LICENSE.


Star ⭐ if you find this useful — it helps the project grow! 觉得好用点个 Star 支持一下!

Read the full README on GitHub →