2021-12-05 17:54:36 +00:00
|
|
|
#pragma once
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "dCommonVars.h"
|
|
|
|
|
|
|
|
namespace dChatFilterDCF {
|
|
|
|
static const uint32_t header = ('D' + ('C' << 8) + ('F' << 16) + ('B' << 24));
|
2021-12-07 20:03:55 +00:00
|
|
|
static const uint32_t formatVersion = 2;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
struct fileHeader {
|
|
|
|
uint32_t header;
|
|
|
|
uint32_t formatVersion;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
class dChatFilter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
dChatFilter(const std::string& filepath, bool dontGenerateDCF);
|
|
|
|
~dChatFilter();
|
|
|
|
|
2022-07-17 08:40:34 +00:00
|
|
|
void ReadWordlistPlaintext(const std::string& filepath, bool whiteList);
|
2022-07-17 06:54:36 +00:00
|
|
|
bool ReadWordlistDCF(const std::string& filepath, bool whiteList);
|
2022-07-17 08:40:34 +00:00
|
|
|
void ExportWordlistToDCF(const std::string& filepath, bool whiteList);
|
2022-07-18 09:01:43 +00:00
|
|
|
std::vector<std::pair<uint8_t, uint8_t>> IsSentenceOkay(const std::string& message, int gmLevel, bool whiteList = true);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_DontGenerateDCF;
|
2022-07-18 09:01:43 +00:00
|
|
|
std::vector<size_t> m_DeniedWords;
|
|
|
|
std::vector<size_t> m_ApprovedWords;
|
2021-12-05 17:54:36 +00:00
|
|
|
std::vector<size_t> m_UserUnapprovedWordCache;
|
|
|
|
|
|
|
|
//Private functions:
|
|
|
|
size_t CalculateHash(const std::string& word);
|
2022-07-18 09:01:43 +00:00
|
|
|
};
|