.BANCHO. .FIX. Fix chat filters

This commit is contained in:
Nyo
2016-08-10 12:00:33 +02:00
parent 9ea11c9e0e
commit a5fd8b0431
8 changed files with 62 additions and 62 deletions

35
objects/chatFilters.py Normal file
View File

@@ -0,0 +1,35 @@
import os
class chatFilters:
def __init__(self, fileName="filters.txt"):
self.filters = {}
self.loadFilters(fileName)
def loadFilters(self, fileName="filters.txt"):
# Reset chat filters
self.filters = {}
# Open filters.txt
#with open(os.path.dirname(os.path.realpath(__file__)) + "/../"+fileName+".txt", "r") as f:
with open("filters.txt", "r") as f:
# Read all lines
data = f.readlines()
# Process each line
for line in data:
# Get old/new word and save it in dictionary
lineSplit = line.split("=")
self.filters[lineSplit[0]] = lineSplit[1].replace("\n", "")
def filterMessage(self, message):
# Split words by spaces
messageTemp = message.split(" ")
# Check each word
for word in messageTemp:
# If the word is filtered, replace it
if word in self.filters:
message = message.replace(word, self.filters[word])
# Return filtered message
return message

View File

@@ -24,6 +24,7 @@ pool = None
fLocks = fileLocks.fileLocks()
verifiedCache = {}
cloudflare = False
chatFilters = None
debug = False
outputRequestTime = False