This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
YimMenu/src/util/spam.hpp

55 lines
1.1 KiB
C++
Raw Normal View History

2022-11-21 15:42:12 +00:00
#pragma once
#include "services/players/player_service.hpp"
#include "file_manager/file.hpp"
namespace
{
static const char* spam_texts[] =
{
"QQ",
"WWW.",
"www.",
".cn",
".CN",
".TOP",
".COM",
2022-12-06 16:12:02 +00:00
".top",
2022-11-21 15:42:12 +00:00
"\xE3\x80\x90",
"/Menu",
"Money/",
"Money\\\\",
"Money\\",
".gg",
"--->",
"shopgta5",
"doit#",
"krutka#",
"<b>"
2022-11-21 15:42:12 +00:00
};
}
namespace big::spam
{
inline bool is_text_spam(const char* text)
{
for (auto e : spam_texts)
if (strstr(text, e) != 0)
return true;
return false;
}
inline void log_chat(char* msg, player_ptr player, bool is_spam)
{
std::ofstream spam_log(g_file_manager->get_project_file(is_spam ? "./spam.log" : "./chat.log").get_path(), std::ios::app);
auto& plData = *player->get_net_data();
spam_log << player->get_name() << " (" << plData.m_gamer_handle_2.m_rockstar_id << ") <"
<< (int)plData.m_external_ip.m_field1 << "." << (int)plData.m_external_ip.m_field2 << "." << (int)plData.m_external_ip.m_field3 << "." << (int)plData.m_external_ip.m_field4 <<
">: " << msg <<
std::endl;
spam_log.close();
}
}