Documentație: Ghid complet configurare Badwords / Word Filtering
CERINȚĂ UTILIZATOR: - Filtrare cuvinte (badwords) precum 'www.' sau alte pattern-uri - Blocarea spam-ului și conținutului nedorit SOLUȚIE: UnderChat IRCd NU are badwords built-in, DAR există soluții: 1. ⭐ ANOPE IRC SERVICES (RECOMANDAT): - Modul os_badwords integrat - Filtrare regex și wildcard - Acțiuni: kick, ban, quiet - Configurare simplă 2. Custom Bot (Python/Node.js): - Exemplu complet de bot Python - Monitorizare mesaje real-time - Kick/ban automat 3. Modificare cod sursă IRCd (avansat): - Editare m_privmsg.c - Necesită recompilare 4. Channel modes (limitat): - +m (moderated) - +R (registered only) DOCUMENTAȚIE INCLUDE: ✅ Instalare pas-cu-pas Anope Services ✅ Configurare services.conf ✅ Modificări necesare în ircd.conf ✅ Comenzi IRC pentru administrare badwords ✅ Exemplu bot Python complet ✅ Comparație soluții cu pro/contra ✅ Troubleshooting EXEMPLU REZULTAT: /msg OperServ BADWORD ADD *www.* Spam links blocked → Orice mesaj cu 'www.' este blocat automat! Fișier: BADWORDS_FILTERING.md
This commit is contained in:
parent
afbf6251d1
commit
3b0f9e3e21
|
|
@ -0,0 +1,374 @@
|
||||||
|
# Ghid: Configurare Badwords / Word Filtering în UnderChat IRCd
|
||||||
|
|
||||||
|
## 📋 IMPORTANT: UnderChat IRCd NU are badwords built-in!
|
||||||
|
|
||||||
|
**UnderChat IRCd** (bazat pe Nefarious/ircu) **NU include** un sistem nativ de filtrare cuvinte (badwords).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✅ SOLUȚII DISPONIBILE
|
||||||
|
|
||||||
|
### **Opțiunea 1: Servicii IRC (RECOMANDAT) ⭐**
|
||||||
|
|
||||||
|
Instalează servicii IRC precum **Anope** sau **Atheme** care au module dedicate de badwords.
|
||||||
|
|
||||||
|
#### **A. Anope IRC Services**
|
||||||
|
|
||||||
|
**Link:** https://www.anope.org/
|
||||||
|
|
||||||
|
**Caracteristici:**
|
||||||
|
- ✅ Modul `os_badwords` - Filtrare cuvinte globală
|
||||||
|
- ✅ Modul `cs_badwords` - Filtrare pe canal
|
||||||
|
- ✅ Suport regex și wildcard patterns
|
||||||
|
- ✅ Acțiuni: kick, ban, quiet
|
||||||
|
- ✅ Exceptii pentru operatori
|
||||||
|
|
||||||
|
**Exemplu configurare:**
|
||||||
|
|
||||||
|
```conf
|
||||||
|
# Încarcă modulul
|
||||||
|
module
|
||||||
|
{
|
||||||
|
name = "os_badwords"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Configurare badwords
|
||||||
|
service
|
||||||
|
{
|
||||||
|
nick = "OperServ"
|
||||||
|
user = "services"
|
||||||
|
host = "services.underchat.org"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Lista de badwords
|
||||||
|
badword
|
||||||
|
{
|
||||||
|
word = "*www.*"
|
||||||
|
type = "start" # start, end, single
|
||||||
|
reason = "Spam link detected"
|
||||||
|
}
|
||||||
|
|
||||||
|
badword
|
||||||
|
{
|
||||||
|
word = "*http*"
|
||||||
|
type = "any"
|
||||||
|
reason = "URL not allowed"
|
||||||
|
}
|
||||||
|
|
||||||
|
badword
|
||||||
|
{
|
||||||
|
word = "badword123"
|
||||||
|
type = "single"
|
||||||
|
reason = "Offensive language"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Comenzi IRC:**
|
||||||
|
```irc
|
||||||
|
/msg OperServ BADWORD ADD *www.* Spam links not allowed
|
||||||
|
/msg OperServ BADWORD ADD *http* URLs not allowed
|
||||||
|
/msg OperServ BADWORD DEL *www.*
|
||||||
|
/msg OperServ BADWORD LIST
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
#### **B. Atheme IRC Services**
|
||||||
|
|
||||||
|
**Link:** https://atheme.github.io/
|
||||||
|
|
||||||
|
**Modul:** `operserv/akill` + custom filtering
|
||||||
|
|
||||||
|
**Exemplu:**
|
||||||
|
```conf
|
||||||
|
loadmodule "modules/operserv/akill";
|
||||||
|
|
||||||
|
# Apoi folosești AKILL pentru pattern matching
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **Opțiunea 2: BotServ / Custom Bot**
|
||||||
|
|
||||||
|
Creează un bot IRC (Python, Node.js) care monitorizează mesajele și kickează/banează utilizatorii care folosesc cuvinte interzise.
|
||||||
|
|
||||||
|
#### **Exemplu Bot Python (irc library):**
|
||||||
|
|
||||||
|
```python
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import irc.bot
|
||||||
|
import re
|
||||||
|
|
||||||
|
class BadwordBot(irc.bot.SingleServerIRCBot):
|
||||||
|
def __init__(self, channel, nickname, server, port=6667):
|
||||||
|
irc.bot.SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname)
|
||||||
|
self.channel = channel
|
||||||
|
|
||||||
|
# Lista de badwords (regex patterns)
|
||||||
|
self.badwords = [
|
||||||
|
r'www\.', # Blochează www.
|
||||||
|
r'http[s]?://', # Blochează link-uri
|
||||||
|
r'badword', # Cuvânt specific
|
||||||
|
]
|
||||||
|
|
||||||
|
def on_welcome(self, c, e):
|
||||||
|
c.join(self.channel)
|
||||||
|
c.privmsg("OperServ", "OPER botuser password") # Login ca oper
|
||||||
|
|
||||||
|
def on_pubmsg(self, c, e):
|
||||||
|
message = e.arguments[0]
|
||||||
|
nick = e.source.nick
|
||||||
|
|
||||||
|
# Verifică fiecare badword
|
||||||
|
for pattern in self.badwords:
|
||||||
|
if re.search(pattern, message, re.IGNORECASE):
|
||||||
|
c.kick(self.channel, nick, f"Badword detected: {pattern}")
|
||||||
|
c.mode(self.channel, f"+b *!*@{nick}")
|
||||||
|
return
|
||||||
|
|
||||||
|
def main():
|
||||||
|
server = "madrid.es.eu.underchat.org"
|
||||||
|
channel = "#underchat"
|
||||||
|
nickname = "BadwordBot"
|
||||||
|
|
||||||
|
bot = BadwordBot(channel, nickname, server, 6667)
|
||||||
|
bot.start()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
```
|
||||||
|
|
||||||
|
**Instalare:**
|
||||||
|
```bash
|
||||||
|
pip3 install irc
|
||||||
|
python3 badword_bot.py
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **Opțiunea 3: Modificare Cod Sursă IRCd (AVANSAT)**
|
||||||
|
|
||||||
|
Poți modifica codul sursă al IRCd-ului pentru a adăuga filtrare de cuvinte.
|
||||||
|
|
||||||
|
**Fișiere de modificat:**
|
||||||
|
- `ircd/m_privmsg.c` - Handler pentru PRIVMSG
|
||||||
|
- `ircd/m_notice.c` - Handler pentru NOTICE
|
||||||
|
|
||||||
|
**Exemplu simplu (pseudo-cod):**
|
||||||
|
|
||||||
|
```c
|
||||||
|
// În ircd/m_privmsg.c, funcția m_privmsg()
|
||||||
|
|
||||||
|
// Adaugă înainte de trimiterea mesajului:
|
||||||
|
const char *badwords[] = {"www.", "http", "badword", NULL};
|
||||||
|
const char *msg = parv[parc - 1];
|
||||||
|
|
||||||
|
for (int i = 0; badwords[i] != NULL; i++) {
|
||||||
|
if (strstr(msg, badwords[i]) != NULL) {
|
||||||
|
// Blochează mesajul
|
||||||
|
sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :Message blocked: contains forbidden word '%s'",
|
||||||
|
sptr, badwords[i]);
|
||||||
|
return 0; // Nu trimite mesajul
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ... cod existent pentru trimitere mesaj
|
||||||
|
```
|
||||||
|
|
||||||
|
**⚠️ ATENȚIE:** Necesită recompilare și poate introduce bug-uri!
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### **Opțiunea 4: Channel Modes (Limitat)**
|
||||||
|
|
||||||
|
IRCd-ul suportă mode-uri de canal care pot limita cine poate vorbi:
|
||||||
|
|
||||||
|
```irc
|
||||||
|
# Doar voice/halfop/op pot vorbi
|
||||||
|
/MODE #canal +m
|
||||||
|
|
||||||
|
# Apoi dai voice doar utilizatorilor de încredere
|
||||||
|
/MODE #canal +v nickname
|
||||||
|
|
||||||
|
# Blochează utilizatori non-autentificați
|
||||||
|
/MODE #canal +R
|
||||||
|
```
|
||||||
|
|
||||||
|
**Configurare în ircd.conf:**
|
||||||
|
```conf
|
||||||
|
features {
|
||||||
|
# Restricționează canalele
|
||||||
|
"CHMODE_r_NONICKCHANGE" = "TRUE";
|
||||||
|
"CHMODE_m_NONICKCHANGE" = "TRUE";
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🎯 RECOMANDARE FINALĂ
|
||||||
|
|
||||||
|
### **Pentru filtrare eficientă de "www." și alte pattern-uri:**
|
||||||
|
|
||||||
|
**Instalează Anope IRC Services:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. Descarcă Anope
|
||||||
|
cd /opt
|
||||||
|
wget https://github.com/anope/anope/releases/download/2.0.14/anope-2.0.14-source.tar.gz
|
||||||
|
tar xzf anope-2.0.14-source.tar.gz
|
||||||
|
cd anope-2.0.14-source
|
||||||
|
|
||||||
|
# 2. Compilează
|
||||||
|
cd build
|
||||||
|
cmake -DCMAKE_INSTALL_PREFIX=/opt/anope ..
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
|
||||||
|
# 3. Configurează
|
||||||
|
cd /opt/anope/conf
|
||||||
|
cp example.conf services.conf
|
||||||
|
nano services.conf
|
||||||
|
|
||||||
|
# Editează:
|
||||||
|
# - uplink { ... } - IP și port către IRCd
|
||||||
|
# - serverinfo { ... } - Nume services
|
||||||
|
# - Încarcă modulul os_badwords
|
||||||
|
|
||||||
|
# 4. Pornește serviciile
|
||||||
|
cd /opt/anope/bin
|
||||||
|
./services
|
||||||
|
|
||||||
|
# 5. Conectează-te la IRC și configurează
|
||||||
|
/msg OperServ IDENTIFY password
|
||||||
|
/msg OperServ BADWORD ADD *www.* Spam links blocked
|
||||||
|
/msg OperServ BADWORD ADD *http* URLs not allowed
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📊 COMPARAȚIE SOLUȚII
|
||||||
|
|
||||||
|
| Soluție | Dificultate | Eficiență | Mențineță | Recomandare |
|
||||||
|
|---------|------------|-----------|-----------|-------------|
|
||||||
|
| **Anope Services** | ⚡ Medie | ⭐⭐⭐⭐⭐ | ⚡⚡⚡ Bună | ✅ **RECOMANDAT** |
|
||||||
|
| **Custom Bot** | ⚡⚡ Medie-Ușoară | ⭐⭐⭐⭐ | ⚡⚡ Ok | ✅ OK pentru teste |
|
||||||
|
| **Modificare IRCd** | ⚡⚡⚡⚡ Dificilă | ⭐⭐⭐⭐⭐ | ⚡ Dificilă | ❌ Nu recomandat |
|
||||||
|
| **Channel Modes** | ⚡ Foarte ușoară | ⭐⭐ | ⚡⚡⚡ Bună | ✅ Limitat |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🔧 CONFIGURARE RAPIDĂ ANOPE
|
||||||
|
|
||||||
|
### **services.conf (simplificat):**
|
||||||
|
|
||||||
|
```conf
|
||||||
|
###############
|
||||||
|
# UPLINK
|
||||||
|
###############
|
||||||
|
uplink
|
||||||
|
{
|
||||||
|
host = "127.0.0.1"
|
||||||
|
port = 6667
|
||||||
|
password = "link-password" # Trebuie să corespundă cu Connect {} din ircd.conf
|
||||||
|
}
|
||||||
|
|
||||||
|
###############
|
||||||
|
# SERVER INFO
|
||||||
|
###############
|
||||||
|
serverinfo
|
||||||
|
{
|
||||||
|
name = "services.underchat.org"
|
||||||
|
description = "UnderChat IRC Services"
|
||||||
|
pid = "data/services.pid"
|
||||||
|
motd = "conf/services.motd"
|
||||||
|
}
|
||||||
|
|
||||||
|
###############
|
||||||
|
# MODULE - BADWORDS
|
||||||
|
###############
|
||||||
|
module
|
||||||
|
{
|
||||||
|
name = "os_badwords"
|
||||||
|
}
|
||||||
|
|
||||||
|
###############
|
||||||
|
# OPERSERV
|
||||||
|
###############
|
||||||
|
service
|
||||||
|
{
|
||||||
|
nick = "OperServ"
|
||||||
|
user = "services"
|
||||||
|
host = "services.underchat.org"
|
||||||
|
gecos = "Operator Service"
|
||||||
|
}
|
||||||
|
|
||||||
|
###############
|
||||||
|
# ADMIN
|
||||||
|
###############
|
||||||
|
oper
|
||||||
|
{
|
||||||
|
name = "admin"
|
||||||
|
type = "Services Root"
|
||||||
|
password = "admin_password_aici"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### **ircd.conf - Adaugă blocul pentru Services:**
|
||||||
|
|
||||||
|
```conf
|
||||||
|
# Conectare pentru Services
|
||||||
|
Connect {
|
||||||
|
name = "services.underchat.org";
|
||||||
|
host = "127.0.0.1";
|
||||||
|
password = "link-password"; # Aceeași cu cea din services.conf
|
||||||
|
port = 6667;
|
||||||
|
class = "Server";
|
||||||
|
autoconnect = yes;
|
||||||
|
};
|
||||||
|
|
||||||
|
# UWorld pentru Services (permisiuni speciale)
|
||||||
|
UWorld {
|
||||||
|
name = "services.underchat.org";
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✅ PAȘI FINALI
|
||||||
|
|
||||||
|
1. ✅ **Instalează Anope Services**
|
||||||
|
2. ✅ **Configurează uplink în services.conf**
|
||||||
|
3. ✅ **Adaugă Connect {} pentru services în ircd.conf**
|
||||||
|
4. ✅ **Pornește services: `/opt/anope/bin/services`**
|
||||||
|
5. ✅ **Identifică-te ca admin: `/msg OperServ IDENTIFY password`**
|
||||||
|
6. ✅ **Adaugă badwords: `/msg OperServ BADWORD ADD *www.* Spam`**
|
||||||
|
7. ✅ **Testează: Scrie "www.test.com" în canal → Ar trebui să fie blocat**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📚 RESURSE
|
||||||
|
|
||||||
|
- **Anope Documentation:** https://wiki.anope.org/
|
||||||
|
- **Anope Modules:** https://wiki.anope.org/index.php/2.0/Modules
|
||||||
|
- **P10 Protocol (pentru linking):** `doc/p10.txt` în repository
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🎉 REZULTAT FINAL
|
||||||
|
|
||||||
|
După configurarea Anope cu modulul `os_badwords`:
|
||||||
|
|
||||||
|
```
|
||||||
|
[15:30] <User> Check out www.spam-site.com
|
||||||
|
[15:30] * User was kicked by OperServ (Badword detected: *www.*)
|
||||||
|
[15:30] * OperServ sets mode: +b *!*@user.host
|
||||||
|
```
|
||||||
|
|
||||||
|
**Spam-ul cu "www." este BLOCAT automat!** ✅
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Autor:** UnderChat IRCd Team
|
||||||
|
**Data:** 14 Februarie 2026
|
||||||
|
**Versiune:** 1.0
|
||||||
|
|
||||||
Loading…
Reference in New Issue