From 1a4a6721a1c189424e677dd3cc07cf54cd6f84bb Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Fri, 20 Mar 2020 17:58:58 +0100 Subject: [PATCH] Added messages --- git-teaspeak | 2 +- server/src/Configuration.cpp | 67 +++++++++++++++++++++++++-- server/src/Configuration.h | 16 +++++++ server/src/client/SpeakingClient.cpp | 21 +++++++++ server/src/client/voice/VoiceClient.h | 1 + 5 files changed, 103 insertions(+), 4 deletions(-) diff --git a/git-teaspeak b/git-teaspeak index d9aa184..46fd235 160000 --- a/git-teaspeak +++ b/git-teaspeak @@ -1 +1 @@ -Subproject commit d9aa18444b8f1322862d8c74123ab6d72b270592 +Subproject commit 46fd2354c3a900b7c8fe2712854bc4b332a0d10e diff --git a/server/src/Configuration.cpp b/server/src/Configuration.cpp index 750aa16..ebed963 100644 --- a/server/src/Configuration.cpp +++ b/server/src/Configuration.cpp @@ -52,8 +52,16 @@ bool config::server::badges::allow_overwolf; bool config::server::authentication::name; bool config::server::clients::teamspeak; +std::string config::server::clients::extra_welcome_message_teamspeak; +config::server::clients::WelcomeMessageType config::server::clients::extra_welcome_message_type_teamspeak; + bool config::server::clients::teaweb; +std::string config::server::clients::extra_welcome_message_teaweb; +config::server::clients::WelcomeMessageType config::server::clients::extra_welcome_message_type_teaweb; + bool config::server::clients::teaspeak; +std::string config::server::clients::extra_welcome_message_teaspeak; +config::server::clients::WelcomeMessageType config::server::clients::extra_welcome_message_type_teaspeak; uint16_t config::voice::default_voice_port; size_t config::voice::DefaultPuzzlePrecomputeSize; @@ -1317,13 +1325,57 @@ std::deque> config::create_bindings() { } } { + using WelcomeMessageType = config::server::clients::WelcomeMessageType; BIND_GROUP(clients); + + /* TeamSpeak */ { CREATE_BINDING("teamspeak", FLAG_RELOADABLE); BIND_BOOL(config::server::clients::teamspeak, true); ADD_DESCRIPTION("Allow/disallow the TeamSpeak 3 client to join the server."); ADD_NOTE_RELOADABLE(); } + { + CREATE_BINDING("teamspeak_message", FLAG_RELOADABLE); + BIND_STRING(config::server::clients::extra_welcome_message_teamspeak, ""); + ADD_DESCRIPTION("Add an extra welcome message for TeamSpeak client users"); + ADD_NOTE_RELOADABLE(); + } + { + CREATE_BINDING("teamspeak_message_type", FLAG_RELOADABLE); + BIND_INTEGRAL(config::server::clients::extra_welcome_message_type_teamspeak, WelcomeMessageType::WELCOME_MESSAGE_TYPE_NONE, WelcomeMessageType::WELCOME_MESSAGE_TYPE_MIN, WelcomeMessageType::WELCOME_MESSAGE_TYPE_MAX); + ADD_DESCRIPTION("The welcome message type modes"); + ADD_DESCRIPTION(std::to_string(WelcomeMessageType::WELCOME_MESSAGE_TYPE_NONE) + " - None, do nothing"); + ADD_DESCRIPTION(std::to_string(WelcomeMessageType::WELCOME_MESSAGE_TYPE_CHAT) + " - Message, sends this message before the server welcome message"); + ADD_DESCRIPTION(std::to_string(WelcomeMessageType::WELCOME_MESSAGE_TYPE_POKE) + " - Message, pokes the client with the message when he enters the server"); + ADD_NOTE_RELOADABLE(); + } + + /* TeaSpeak */ + { + CREATE_BINDING("teaspeak", FLAG_RELOADABLE); + BIND_BOOL(config::server::clients::teaspeak, true); + ADD_DESCRIPTION("Allow/disallow the TeaSpeak - Client to join the server."); + ADD_NOTE_RELOADABLE(); + } + { + CREATE_BINDING("teaspeak_message", FLAG_RELOADABLE); + BIND_STRING(config::server::clients::extra_welcome_message_teaspeak, ""); + ADD_DESCRIPTION("Add an extra welcome message for the TeaSpeak - Client users"); + ADD_NOTE_RELOADABLE(); + } + { + CREATE_BINDING("teaspeak_message_type", FLAG_RELOADABLE); + BIND_INTEGRAL(config::server::clients::extra_welcome_message_type_teaspeak, WelcomeMessageType::WELCOME_MESSAGE_TYPE_NONE, WelcomeMessageType::WELCOME_MESSAGE_TYPE_MIN, WelcomeMessageType::WELCOME_MESSAGE_TYPE_MAX); + ADD_DESCRIPTION("The welcome message type modes"); + ADD_DESCRIPTION(std::to_string(WelcomeMessageType::WELCOME_MESSAGE_TYPE_NONE) + " - None, do nothing"); + ADD_DESCRIPTION(std::to_string(WelcomeMessageType::WELCOME_MESSAGE_TYPE_CHAT) + " - Message, sends this message before the server welcome message"); + ADD_DESCRIPTION(std::to_string(WelcomeMessageType::WELCOME_MESSAGE_TYPE_POKE) + " - Message, pokes the client with the message when he enters the server"); + ADD_NOTE_RELOADABLE(); + } + + + /* TeaWeb */ { CREATE_BINDING("teaweb", FLAG_RELOADABLE); BIND_BOOL(config::server::clients::teaweb, true); @@ -1331,9 +1383,18 @@ std::deque> config::create_bindings() { ADD_NOTE_RELOADABLE(); } { - CREATE_BINDING("teaspeak", FLAG_RELOADABLE); - BIND_BOOL(config::server::clients::teaspeak, true); - ADD_DESCRIPTION("Allow/disallow the TeaSpeak - Client to join the server."); + CREATE_BINDING("teaweb_message", FLAG_RELOADABLE); + BIND_STRING(config::server::clients::extra_welcome_message_teaweb, ""); + ADD_DESCRIPTION("Add an extra welcome message for the TeaSpeak - Web client users"); + ADD_NOTE_RELOADABLE(); + } + { + CREATE_BINDING("teaweb_message_type", FLAG_RELOADABLE); + BIND_INTEGRAL(config::server::clients::extra_welcome_message_type_teaweb, WelcomeMessageType::WELCOME_MESSAGE_TYPE_NONE, WelcomeMessageType::WELCOME_MESSAGE_TYPE_MIN, WelcomeMessageType::WELCOME_MESSAGE_TYPE_MAX); + ADD_DESCRIPTION("The welcome message type modes"); + ADD_DESCRIPTION(std::to_string(WelcomeMessageType::WELCOME_MESSAGE_TYPE_NONE) + " - None, do nothing"); + ADD_DESCRIPTION(std::to_string(WelcomeMessageType::WELCOME_MESSAGE_TYPE_CHAT) + " - Message, sends this message before the server welcome message"); + ADD_DESCRIPTION(std::to_string(WelcomeMessageType::WELCOME_MESSAGE_TYPE_POKE) + " - Message, pokes the client with the message when he enters the server"); ADD_NOTE_RELOADABLE(); } } diff --git a/server/src/Configuration.h b/server/src/Configuration.h index eac2250..2a252ba 100644 --- a/server/src/Configuration.h +++ b/server/src/Configuration.h @@ -86,9 +86,25 @@ namespace ts::config { } namespace clients { + enum WelcomeMessageType { + WELCOME_MESSAGE_TYPE_MIN, + WELCOME_MESSAGE_TYPE_NONE = WELCOME_MESSAGE_TYPE_MIN, + WELCOME_MESSAGE_TYPE_CHAT, + WELCOME_MESSAGE_TYPE_POKE, + WELCOME_MESSAGE_TYPE_MAX + }; + extern bool teamspeak; + extern std::string extra_welcome_message_teamspeak; + extern WelcomeMessageType extra_welcome_message_type_teamspeak; + extern bool teaspeak; + extern std::string extra_welcome_message_teaspeak; + extern WelcomeMessageType extra_welcome_message_type_teaspeak; + extern bool teaweb; + extern std::string extra_welcome_message_teaweb; + extern WelcomeMessageType extra_welcome_message_type_teaweb; } extern ssize_t max_virtual_server; diff --git a/server/src/client/SpeakingClient.cpp b/server/src/client/SpeakingClient.cpp index 9949045..58041a1 100644 --- a/server/src/client/SpeakingClient.cpp +++ b/server/src/client/SpeakingClient.cpp @@ -761,6 +761,27 @@ void SpeakingClient::processJoin() { this->connectTimestamp = chrono::system_clock::now(); this->idleTimestamp = chrono::system_clock::now(); + TIMING_STEP(timings, "welcome msg"); + { + std::string message{}; + config::server::clients::WelcomeMessageType type{config::server::clients::WELCOME_MESSAGE_TYPE_NONE}; + if(this->getType() == ClientType::CLIENT_TEASPEAK) { + message = config::server::clients::extra_welcome_message_teaspeak; + type = config::server::clients::extra_welcome_message_type_teaspeak; + } else if(this->getType() == ClientType::CLIENT_TEAMSPEAK) { + message = config::server::clients::extra_welcome_message_teamspeak; + type = config::server::clients::extra_welcome_message_type_teamspeak; + } else if(this->getType() == ClientType::CLIENT_WEB) { + message = config::server::clients::extra_welcome_message_teaweb; + type = config::server::clients::extra_welcome_message_type_teaweb; + } + + if(type == config::server::clients::WELCOME_MESSAGE_TYPE_POKE) { + this->notifyClientPoke(this->server->serverRoot, message); + } else if(type == config::server::clients::WELCOME_MESSAGE_TYPE_CHAT) { + this->notifyTextMessage(ChatMessageMode::TEXTMODE_SERVER, this->server->serverRoot, 0, 0, std::chrono::system_clock::now(), message); + } + } debugMessage(this->getServerId(), "{} Client join timings: {}", CLIENT_STR_LOG_PREFIX, TIMING_FINISH(timings)); } diff --git a/server/src/client/voice/VoiceClient.h b/server/src/client/voice/VoiceClient.h index f3d9989..073706c 100644 --- a/server/src/client/voice/VoiceClient.h +++ b/server/src/client/voice/VoiceClient.h @@ -120,6 +120,7 @@ namespace ts { bool client_init = false; bool new_protocol = false; bool protocol_encrypted = false; + bool is_teaspeak_client = false; uint32_t client_time = 0; std::string alpha;