ralkage/flarum-ext-civility-filter
Composer 安装命令:
composer require ralkage/flarum-ext-civility-filter
包简介
AI-powered civility filter that analyzes posts for incivility using Anthropic Claude, OpenAI GPT, or OpenRouter
README 文档
README
AI-powered content moderation extension for Flarum that automatically analyzes posts for civility using Anthropic Claude, OpenAI GPT, or OpenRouter.
Features
AI Analysis
- Analyzes posts in real-time before they're published
- Supports Anthropic Claude (Haiku, Sonnet, Opus), OpenAI GPT (5.4 Nano, 5.4 mini, 5.4 generic), and OpenRouter (200+ models)
- Customizable AI prompt for tailored moderation rules
- Fail-open design — posts go through if the API is unavailable
4-Tier Action System
| Action | Default Threshold | Behavior |
|---|---|---|
| Allowed | 0–59 | Post published normally |
| Warned | 60–79 | Post published, logged, user notified |
| Moderated | 80–94 | Post held in moderation queue for review |
| Blocked | 95–100 | Post rejected, user sees error message |
All thresholds are configurable in 5-point increments.
Content Filtering
- Word Blocklist — Instant block on matching keywords without calling the AI (saves API costs)
- Tag-Based Monitoring — Only analyze posts in specific tags, or monitor all
- Quoted Content Exclusion — Strips quoted text before analysis so users aren't penalized for quoting others
Moderation Tools
- Civility Log — Paginated, filterable log of all analysis results
- Statistics Dashboard — Action breakdown, top categories, top offenders, and daily trend charts
- Test Analyzer — Test messages against the AI before deploying settings
- CSV Export — Download the full civility log for offline review
- Quick Actions — Approve, delete, or suspend directly from the log table
Automated Enforcement
- Auto-Suspend — Automatically suspend users after X violations within a configurable time window
- API Rate Limiting — Cap AI API calls per hour to control costs during traffic spikes
Notifications
- In-App Alerts — Users are notified when their posts are warned or moderated
- Discord/Webhook Alerts — Send rich embeds to Discord or JSON payloads to any webhook URL when posts are flagged
Forum Integration
- Post Badges — Visual notices on warned/moderated posts (visible to author and staff only)
- User Profile History — Per-user civility stats and recent violations (admin only)
- Bypass Permission — Exempt trusted users/groups from civility checks
Installation
composer require ralkage/flarum-ext-civility-filter php flarum migrate php flarum cache:clear
Enable the extension in the admin panel under Extensions > Civility Filter.
Configuration
Navigate to the extension settings page in the admin panel. The settings are organized into sections:
General
- Enable Civility Filter — Master on/off switch
AI Provider
- AI Provider — Choose between Anthropic (Claude), OpenAI (GPT), or OpenRouter
- Anthropic API Key — Your Anthropic API key
- OpenAI API Key — Your OpenAI API key
- OpenRouter API Key — Your OpenRouter API key (access 200+ models from one API)
- AI Model — Select the model for your chosen provider
Thresholds
- Warn Threshold — Score to trigger a warning (default: 60)
- Hold/Moderate Threshold — Score to hold for moderation (default: 80)
- Block Threshold — Score to block the post (default: 95)
Filtering
- Monitored Tags — Multi-select tag picker to limit which tags are monitored
- Word Blocklist — One word/phrase per line, instantly blocks without AI
Custom Prompt
- Custom AI Prompt — Override the default analysis prompt with your own instructions
Auto-Suspend
- Threshold — Number of violations before auto-suspend (0 = disabled)
- Duration — Suspension length in days
- Window — Count violations within this many days
Webhooks
- Webhook URL — Discord webhook or generic endpoint
- Minimum Action — Only alert for this severity or higher
Logging & Limits
- Log All Checks — Include passing posts in the log
- Rate Limit — Maximum API calls per hour (0 = unlimited)
Permissions
| Permission | Description |
|---|---|
| Bypass Civility Filter | Users with this permission skip all civility analysis |
Configure under the Permissions section of the extension settings page.
API Endpoints
All endpoints require admin authentication unless noted.
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/civility-logs |
List logs (paginated, filterable) |
DELETE |
/api/civility-logs |
Clear all logs |
GET |
/api/civility-logs/export |
Download CSV export |
GET |
/api/civility-logs/stats |
Statistics and trends |
POST |
/api/civility-logs/test |
Test analyzer |
POST |
/api/civility-logs/moderate |
Quick actions (approve/delete/suspend) |
GET |
/api/civility-logs/user?userId=X |
Per-user civility history |
Scoring Guide
The AI evaluates posts on a 0–100 scale:
| Score Range | Meaning |
|---|---|
| 0–20 | Civil, constructive, or neutral |
| 21–40 | Mildly rude or snarky but not harmful |
| 41–60 | Hostile tone, dismissive, or antagonistic |
| 61–80 | Personal attacks, inflammatory language, bad-faith arguing |
| 81–95 | Hate speech, severe harassment, threats |
| 96–100 | Extreme abuse or dangerous content |
Political disagreement alone is not considered uncivil. The AI focuses on how something is said, not what position is taken.
Categories
The AI categorizes issues found in posts:
personal_attack · inflammatory · hate_speech · bad_faith · trolling · harassment · threat · profanity · discrimination
Requirements
- Flarum
^1.8 - PHP 8.0+
- An API key from Anthropic, OpenAI, or OpenRouter
Links
License
MIT License. See LICENSE for details.
ralkage/flarum-ext-civility-filter 适用场景与选型建议
ralkage/flarum-ext-civility-filter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「moderation」 「ai」 「openai」 「gpt」 「claude」 「OpenRouter」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ralkage/flarum-ext-civility-filter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ralkage/flarum-ext-civility-filter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ralkage/flarum-ext-civility-filter 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP 8.0+ OpenAI API client with fully typed/documented requests+responses models, guzzle and symfony/http-client support and async/parallel requests.
A CakePHP plugin for adding threaded comments with moderation support
Laravel Profanity Filter - Powerful PHP package for detecting, filtering, and masking profanity in multiple languages. Supports leet speak, custom word lists, case sensitivity, and seamless Laravel integration.
AI-powered helper for PHP errors, warnings and exceptions: practical, context-aware explanations and suggestions via local or API LLMs.
Magento MCP AI Assistant - A powerful AI assistant for Magento 2 that helps with store data queries and management
Estimate AI API costs before making expensive calls
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-22