cleanup regex_filter

main
simp 2025-08-16 07:01:08 +00:00
parent e777ef092f
commit bec8486fbc
1 changed files with 4 additions and 7 deletions

View File

@ -1,10 +1,7 @@
"""
Regex Filter Plugin for PyLink
Comprehensive message filtering with Perl regex backend and flood protection
Author: Anon
License: BSD 2-Clause
Comprehensive message filtering with PCRE2 and flood protection
"""
import os
import time
import hashlib
@ -65,7 +62,7 @@ def _ensure_directories():
blacklist_path = Path(config['blacklist_file'])
if not blacklist_path.exists():
with open(blacklist_path, 'w') as f:
f.write("# Regex Blacklist Patterns - One Perl regex per line\n")
f.write("# Regex Blacklist Patterns - One regex per line\n")
f.write("# Test all patterns thoroughly before deploying\n")
f.write("# Examples (commented out by default):\n")
f.write("# \\bhttps?://(?:bit\\.ly|tinyurl\\.com|t\\.co)/\\w+\\b\n")
@ -183,7 +180,7 @@ def _check_flood_protection(source, content):
return False, ""
def _run_regex(content):
"""Call Perl script to filter content"""
"""Filter content using jit compiled pattern"""
for p in Cr.pattern:
try:
matched = p.match(content)
@ -213,7 +210,7 @@ def _should_filter_content(source, target, content, network_name="unknown"):
if is_flood:
return True, flood_reason
# Check content with Perl filter
# Check content with filter
is_blocked, block_reason = _run_regex(content)
if is_blocked:
return True, block_reason