add option to change chat command character
This commit is contained in:
+3
-3
@@ -3183,9 +3183,9 @@ struct SplitCommand {
|
||||
asio::awaitable<void> on_chat_command(std::shared_ptr<Client> c, const std::string& text, bool check_permissions) {
|
||||
SplitCommand cmd(text);
|
||||
|
||||
// This function is only called by on_06 if it looks like a chat command (starts with $, or @ on 11/2000), so we just
|
||||
// normalize all commands to $ here
|
||||
if (!cmd.name.empty() && cmd.name[0] == '@') {
|
||||
// This function is only called by on_06 if it looks like a chat command (starts with $, or @ on 11/2000, or
|
||||
// s->chat_command_sentinel if overridden), so we just normalize all commands to $ here
|
||||
if (!cmd.name.empty()) {
|
||||
cmd.name[0] = '$';
|
||||
}
|
||||
|
||||
|
||||
@@ -1972,7 +1972,10 @@ static asio::awaitable<HandlerResult> C_06(shared_ptr<Client> c, Channel::Messag
|
||||
co_return HandlerResult::FORWARD;
|
||||
}
|
||||
|
||||
char command_sentinel = (c->version() == Version::DC_11_2000) ? '@' : '$';
|
||||
auto s = c->require_server_state();
|
||||
char command_sentinel = s->chat_command_sentinel
|
||||
? s->chat_command_sentinel
|
||||
: ((c->version() == Version::DC_11_2000) ? '@' : '$');
|
||||
bool is_command = (text[0] == command_sentinel) ||
|
||||
(text[0] == '\t' && text[1] != 'C' && text[2] == command_sentinel);
|
||||
if (is_command && c->check_flag(Client::Flag::PROXY_CHAT_COMMANDS_ENABLED)) {
|
||||
|
||||
@@ -3628,7 +3628,10 @@ static asio::awaitable<void> on_06(shared_ptr<Client> c, Channel::Message& msg)
|
||||
co_return;
|
||||
}
|
||||
|
||||
char command_sentinel = (c->version() == Version::DC_11_2000) ? '@' : '$';
|
||||
auto s = c->require_server_state();
|
||||
char command_sentinel = s->chat_command_sentinel
|
||||
? s->chat_command_sentinel
|
||||
: ((c->version() == Version::DC_11_2000) ? '@' : '$');
|
||||
if ((text[0] == command_sentinel) && c->can_use_chat_commands()) {
|
||||
if (text[1] == command_sentinel) {
|
||||
text = text.substr(1);
|
||||
|
||||
@@ -1114,6 +1114,14 @@ void ServerState::load_config_early() {
|
||||
}
|
||||
|
||||
this->enable_chat_commands = this->config_json->get_bool("EnableChatCommands", true);
|
||||
try {
|
||||
const auto& s = this->config_json->get_string("ChatCommandSentinel");
|
||||
if (s.size() != 1) {
|
||||
throw std::runtime_error("ChatCommandSentinel must be a string of length 1");
|
||||
}
|
||||
this->chat_command_sentinel = s[0];
|
||||
} catch (const std::out_of_range&) {
|
||||
}
|
||||
this->num_backup_character_slots = this->config_json->get_int("BackupCharacterSlots", 16);
|
||||
|
||||
this->version_name_colors.reset();
|
||||
|
||||
@@ -115,6 +115,7 @@ struct ServerState : public std::enable_shared_from_this<ServerState> {
|
||||
bool use_temp_accounts_for_prototypes = true;
|
||||
std::array<uint16_t, NUM_VERSIONS> compatibility_groups = {};
|
||||
bool enable_chat_commands = true;
|
||||
char chat_command_sentinel = '\0'; // 0 = default (@ on 11/2000; $ on all other versions)
|
||||
size_t num_backup_character_slots = 16;
|
||||
std::unique_ptr<std::array<uint32_t, NUM_NON_PATCH_VERSIONS>> version_name_colors;
|
||||
uint32_t client_customization_name_color = 0x00000000;
|
||||
|
||||
@@ -279,6 +279,10 @@
|
||||
// use chat commands.
|
||||
"EnableChatCommands": true,
|
||||
|
||||
// Sentinel to use for chat commands. If this is specified, chat commands are
|
||||
// prefixed by this character instead of $.
|
||||
// "ChatCommandSentinel": "/",
|
||||
|
||||
// Number of backup character slots for each account, accessible with the
|
||||
// $savechar, $loadchar, and $checkchar commands. This can be any value, but
|
||||
// it's recommended to use a small number such as 16.
|
||||
|
||||
Reference in New Issue
Block a user