mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-09 01:38:20 +00:00
Nice Commit! :)
This commit is contained in:
parent
bcb0454916
commit
eede772b53
@ -102,26 +102,14 @@ bool dChatFilter::IsSentenceOkay(const std::string& message, int gmLevel) {
|
||||
if (message.empty()) return true;
|
||||
|
||||
std::stringstream sMessage(message);
|
||||
std::string segment;
|
||||
std::string line;
|
||||
std::regex reg("(!*|\\?*|\\;*|\\.*|\\,*)");
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef _win32
|
||||
while (std::getline(file, line)) {
|
||||
while (std::getline(sMessage, line)) {
|
||||
line.erase(std::remove(line.begin(), line.end(), '\r'), line.end()); //Remove nix line-endings
|
||||
std::transform(line.begin(), line.end(), line.begin(), ::tolower); //Transform to lowercase
|
||||
m_Words.push_back(CalculateHash(line));
|
||||
#else
|
||||
while (std::getline(sMessage, segment, ' ')) {
|
||||
#endif
|
||||
|
||||
|
||||
std::transform(segment.begin(), segment.end(), segment.begin(), ::tolower); //Transform to lowercase
|
||||
segment = std::regex_replace(segment, reg, "");
|
||||
|
||||
size_t hash = CalculateHash(segment);
|
||||
line = std::regex_replace(line, reg, "");
|
||||
size_t hash = CalculateHash(line);
|
||||
|
||||
if (std::find(m_UserUnapprovedWordCache.begin(), m_UserUnapprovedWordCache.end(), hash) != m_UserUnapprovedWordCache.end()) {
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user