maint: remove links from server names (#87)

This commit is contained in:
Diamante 2024-05-04 19:05:02 +02:00 committed by GitHub
parent d48736c12a
commit 479f6fcbf3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,10 +1,21 @@
#include <std_include.hpp>
#include "elimination_handler.hpp"
#include <utils/string.hpp>
namespace
{
constexpr auto T7_PROTOCOL = 7;
constexpr size_t MAX_SERVERS_PER_GAME = 10;
std::array bad_names =
{
"http",
"discord.gg",
};
}
void elimination_handler::run_frame()
{
std::unordered_map<game_type, std::unordered_map<std::string, size_t>> server_count;
@ -40,6 +51,16 @@ void elimination_handler::run_frame()
console::log("Removing server '%s' because it exceeds MAX_SERVERS_PER_GAME", context.get_address().to_string().data());
context.remove();
}
const auto name = utils::string::to_lower(server.name);
for (const auto& entry : bad_names)
{
if (const auto pos = name.find(entry); pos != std::string::npos)
{
console::log("Removing server '%s' (%s) because it contains a bad name", server.name.data(), context.get_address().to_string().data());
context.remove();
}
}
});
now = std::chrono::high_resolution_clock::now();