mirror of
https://github.com/Dingo-Shenanigans/ReSkate.git
synced 2026-10-23 05:45:53 +02:00
Server window: word filter toggle and a roles editor
Settings tab: a Chat Word Filter card with "Use Global Word Filter" (use_global_word_filter), buttons that open data/words_filtered.txt and data/words_blocked.txt, and one that has a running server read them again. Moderation tab: - ROLES: create, edit and delete roles (tag, tag colour, rank, default role, inheriting from it, permissions, commands). Saving checks the roles, writes data/roles.json and has a running server reload it. A role's name is fixed once made, since players are given roles by name, and a save keeps who has which role as the server has it then. - PLAYER ROLES (was SERVER ADMINISTRATORS): giving a role picks any of the server's roles, not only admin. The two word files are now made empty when they are missing, without the explanation that was written into them. Also: the README's Chat words section sat inside the Roles section, and the server parks test did not link without server_words.cpp.
This commit is contained in:
1 parent
0b28dbd7c9
commit
f7beec83c5
6 files changed
+274
-35
No files matched your search
+5
-16
@@ -11,24 +11,13 @@ namespace {
|
||||
// As many words of as many bytes as one of the team's lists holds.
|
||||
constexpr std::size_t most_words = 5000, longest_word = 64;
|
||||
|
||||
constexpr std::string_view filtered_help =
|
||||
"# Words this server filters in chat, beside the ReSkate team's list.\n"
|
||||
"# One word to a line. Messages with them are still passed on: players who have their chat filter on\n"
|
||||
"# see the word as stars. The first 256 words of up to 32 letters are sent to players' games.\n"
|
||||
"# Read when the server starts and by the console command: words reload\n";
|
||||
constexpr std::string_view blocked_help =
|
||||
"# Words that are not allowed in this server's chat at all, beside the ReSkate team's list.\n"
|
||||
"# One word to a line. A message with one is not passed on and its player is warned\n"
|
||||
"# (see word_warnings in the README).\n"
|
||||
"# Read when the server starts and by the console command: words reload\n";
|
||||
|
||||
std::vector<std::string> read(const std::filesystem::path &file, std::string_view help, std::string &problem) {
|
||||
// The words in `file`, which is made empty when it is not there, so an owner finds it to fill in.
|
||||
std::vector<std::string> read(const std::filesystem::path &file, std::string &problem) {
|
||||
std::vector<std::string> words;
|
||||
std::error_code error;
|
||||
if (!std::filesystem::exists(file, error)) {
|
||||
std::filesystem::create_directories(file.parent_path(), error);
|
||||
std::ofstream out(file, std::ios::binary);
|
||||
if (!(out << help)) problem = "could not write " + file.filename().string();
|
||||
if (!std::ofstream(file, std::ios::binary)) problem = "could not write " + file.filename().string();
|
||||
return words;
|
||||
}
|
||||
std::ifstream in(file, std::ios::binary);
|
||||
@@ -52,8 +41,8 @@ std::filesystem::path blocked_words_file(const ServerConfig &c) { return c.file.
|
||||
|
||||
OwnWords use_own_words(const ServerConfig &config) {
|
||||
OwnWords result;
|
||||
const auto filtered = read(filtered_words_file(config), filtered_help, result.problem);
|
||||
const auto blocked = read(blocked_words_file(config), blocked_help, result.problem);
|
||||
const auto filtered = read(filtered_words_file(config), result.problem);
|
||||
const auto blocked = read(blocked_words_file(config), result.problem);
|
||||
result.filtered = filtered.size();
|
||||
result.blocked = blocked.size();
|
||||
for (const auto &word : filtered)
|
||||
|
||||
Reference in new issue
Block a user