This repository was archived by the owner on Jul 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPluginAPI.php
More file actions
149 lines (138 loc) · 3.45 KB
/
PluginAPI.php
File metadata and controls
149 lines (138 loc) · 3.45 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
/*
* _
* | |
* __ ____ ___ _| |___ _____ _ __
* \ \/ / _` \ \ /\ / / __\ \/ / _ \| '_ \
* > < (_| |\ V V /| |_ > < (_) | | | |
* /_/\_\__, | \_/\_/ \__/_/\_\___/|_| |_|
* | |
* |_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author xqwtxon
* @link https://github.com/xqwtxon/
*
*/
declare(strict_types=1);
namespace xqwtxon\ProfanityFilter;
use function preg_match;
use function str_replace;
use function str_word_count;
use function str_repeat;
use function sizeof;
final class PluginAPI {
/*
* Whether to detect message on provided words.
* @param string $message
* @param array $words
* @return bool
*/
public static function detectProfanity(string $message, array $words) : bool {
$filterCount = sizeof($words);
for ($i = 0; $i < $filterCount; $i++) {
$condition = preg_match('/' . $words[$i] . '/iu', $message) > 0;
if ($condition) {
return true;
}
}
return false;
}
/*
* It is being used to remove profanities on message.
* Returns string convert to **** characters.
* @param string $message
* @param array $words
* @return string
*/
public static function removeProfanity(string $message, $words) : string {
foreach($words as $profanity){
$message = str_replace($profanity, str_repeat("*", str_word_count($profanity)), $words);
}
return $message;
}
/*
* Returns array batch in english default profanity.
* @return array
*/
public static function defaultProfanity() : array {
return $words = [
"anal",
"anus",
"arse",
"ass",
"ballsack",
"balls",
"bastard",
"bitch",
"biatch",
"bloody",
"blowjob",
"blow job",
"bollock",
"bollok",
"boner",
"boob",
"bugger",
"bum",
"butt",
"buttplug",
"clitoris",
"cock",
"coon",
"crap",
"cunt",
"damn",
"dick",
"dildo",
"dyke",
"fag",
"feck",
"fellate",
"fellatio",
"felching",
"fuck",
"f u c k",
"fudgepacker",
"fudge packer",
"flange",
"Goddamn",
"God damn",
"hell",
"homo",
"jerk",
"jizz",
"knobend",
"knob end",
"labia",
"muff",
"nigger",
"nigga",
"penis",
"piss",
"prick",
"pube",
"pussy",
"queer",
"scrotum",
"shit",
"s hit",
"sh1t",
"slut",
"smegma",
"spunk",
"tit",
"tosser",
"turd",
"twat",
"vagina",
"wank",
"whore",
"wtf",
];
}
}