forked from Comon-tech/TACT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbad_words.py
54 lines (43 loc) · 1.69 KB
/
bad_words.py
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
import requests
import json
# Define the API endpoint
url = "https://vector.profanity.dev"
# List of offensive words
offensive_words = ["fuck","motherfucker","fucker","motherfucker","shit", "Shit","whore","asshole","bitch","ass","nigga", "Israel", "israel","nazi","jew","coon","dild","dildo","rape","dick","porn","penis","killyourself","whore","slut","twat","x-rated","xrated","18+","gore","cock","cum","cancer", "idiot", "vagina" ]
def check_for_bad_words(message):
loop_index = 0
split_messages = []
temp_words = ""
loop_index_max = len(message.split(" "))
for index, wrd in enumerate(message.split(" ")):
temp_words += wrd + " "
if loop_index == 9:
split_messages.append(temp_words)
loop_index = 0
temp_words = ""
elif loop_index_max == index + 1:
split_messages.append(temp_words)
else:
loop_index += 1
return split_messages
def split_msg_into_array(words):
# for words in split_messages:
data = {"message": words}
# Set the headers
headers = {"Content-Type": "application/json"}
# Make the POST request
response = requests.post(url, headers=headers, data=json.dumps(data))
# Handle the response
if response.status_code == 200:
# print("Response:", response.json())
response = response.json()
if response["isProfanity"] == True:
return True, response["flaggedFor"]
return False, "safe"
# words = check_for_bad_words(message)
# for word in words:
# true_or_false, flagge_word = split_msg_into_array(word)
# if true_or_false:
# print(f"Bad word found: {flagge_word}")
# else:
# print("No bad words found")