-
Notifications
You must be signed in to change notification settings - Fork 24
/
content_filtering.go
81 lines (75 loc) · 1.23 KB
/
content_filtering.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package main
import (
"fmt"
"regexp"
"slices"
"strings"
"github.com/nbd-wtf/go-nostr"
)
func hasProhibitedWordOrTag(event *nostr.Event) bool {
for _, tag := range event.Tags {
if len(tag) >= 2 && tag[0] == "t" && slices.Contains(pornTags, strings.ToLower(tag[1])) {
return true
}
}
return pornWordsRe.MatchString(event.Content)
}
// list copied from https://jsr.io/@gleasonator/policy/0.2.0/data/porntags.json
var pornTags = []string{
"adult",
"ass",
"assworship",
"boobs",
"boobies",
"butt",
"cock",
"dick",
"dickpic",
"explosionloli",
"femboi",
"femboy",
"fetish",
"fuck",
"freeporn",
"girls",
"lewd",
"loli",
"milf",
"naked",
"nude",
"nudes",
"nudeart",
"nudity",
"nsfw",
"pantsu",
"pussy",
"porn",
"porngif",
"porno",
"pornstar",
"porntube",
"pornvideo",
"sex",
"sexpervertsyndicate",
"sexporn",
"sexworker",
"sexy",
"slut",
"teen",
"tits",
"teenporn",
"teens",
"transnsfw",
"xxx",
}
var pornWordsRe = func() *regexp.Regexp {
// list copied from https://jsr.io/@gleasonator/policy/0.2.0/data/pornwords.json
pornWords := []string{
"loli",
"nsfw",
"teen porn",
}
concat := strings.Join(pornWords, "|")
regex := fmt.Sprintf(`\b(%s)\b`, concat)
return regexp.MustCompile(regex)
}()