Adding by default a music bot to each newly created server

This commit is contained in:
WolverinDEV 2020-02-15 15:37:19 +01:00
parent 035f23ef23
commit 64b4a7118b
6 changed files with 18 additions and 7 deletions

View File

@ -45,6 +45,7 @@ bool config::server::enable_teamspeak_weblist;
bool config::server::strict_ut8_mode; bool config::server::strict_ut8_mode;
bool config::server::show_invisible_clients_as_online; bool config::server::show_invisible_clients_as_online;
bool config::server::disable_ip_saving; bool config::server::disable_ip_saving;
bool config::server::default_music_bot;
ssize_t config::server::max_virtual_server; ssize_t config::server::max_virtual_server;
bool config::server::badges::allow_badges; bool config::server::badges::allow_badges;
bool config::server::badges::allow_overwolf; bool config::server::badges::allow_overwolf;
@ -1233,7 +1234,12 @@ std::deque<std::shared_ptr<EntryBinding>> config::create_bindings() {
{ {
CREATE_BINDING("disable_ip_saving", 0); CREATE_BINDING("disable_ip_saving", 0);
BIND_BOOL(config::server::disable_ip_saving, false); BIND_BOOL(config::server::disable_ip_saving, false);
ADD_DESCRIPTION("Disable the saving of IP addresses within the database"); ADD_DESCRIPTION("Disable the saving of IP addresses within the database.");
}
{
CREATE_BINDING("default_music_bot", 0);
BIND_BOOL(config::server::default_music_bot, true);
ADD_DESCRIPTION("Add by default a new music bot to each created virtual server.");
} }
{ {
CREATE_BINDING("max_virtual_servers", FLAG_RELOADABLE); CREATE_BINDING("max_virtual_servers", FLAG_RELOADABLE);

View File

@ -73,6 +73,7 @@ namespace ts::config {
extern bool enable_teamspeak_weblist; extern bool enable_teamspeak_weblist;
extern bool show_invisible_clients_as_online; extern bool show_invisible_clients_as_online;
extern bool disable_ip_saving; extern bool disable_ip_saving;
extern bool default_music_bot;
namespace badges { namespace badges {
extern bool allow_overwolf; extern bool allow_overwolf;

View File

@ -388,7 +388,8 @@ FwIDAQAB
if (voiceServerManager->serverInstances().empty()) { if (voiceServerManager->serverInstances().empty()) {
logMessage(LOG_INSTANCE, "§aCreating new TeaSpeak server..."); logMessage(LOG_INSTANCE, "§aCreating new TeaSpeak server...");
auto server = voiceServerManager->createServer(config::binding::DefaultVoiceHost, config::voice::default_voice_port); auto server = voiceServerManager->create_server(config::binding::DefaultVoiceHost,
config::voice::default_voice_port);
if (!server) if (!server)
logCritical(LOG_INSTANCE, "§cCould not create a new server!"); logCritical(LOG_INSTANCE, "§cCould not create a new server!");
else { else {

View File

@ -308,7 +308,7 @@ size_t VirtualServerManager::usedSlots() {
return res; return res;
} }
shared_ptr<VirtualServer> VirtualServerManager::createServer(std::string hosts, uint16_t port) { shared_ptr<VirtualServer> VirtualServerManager::create_server(std::string hosts, uint16_t port) {
bool sid_success = false; bool sid_success = false;
ServerId serverId = this->next_available_server_id(sid_success); ServerId serverId = this->next_available_server_id(sid_success);
@ -330,7 +330,10 @@ shared_ptr<VirtualServer> VirtualServerManager::createServer(std::string hosts,
} }
server->properties()[property::VIRTUALSERVER_HOST] = hosts; server->properties()[property::VIRTUALSERVER_HOST] = hosts;
server->properties()[property::VIRTUALSERVER_PORT] = port; server->properties()[property::VIRTUALSERVER_PORT] = port;
auto bot = server->musicManager->createBot(0);
if(!bot) {
logCritical(server->getServerId(), "Failed to create default music bot!");
}
{ {
threads::MutexLock l(this->instanceLock); threads::MutexLock l(this->instanceLock);
this->instances.push_back(server); this->instances.push_back(server);

View File

@ -32,7 +32,7 @@ namespace ts {
bool initialize(bool execute_autostart = true); bool initialize(bool execute_autostart = true);
std::shared_ptr<VirtualServer> createServer(std::string, uint16_t); std::shared_ptr<VirtualServer> create_server(std::string hosts, uint16_t port);
bool deleteServer(std::shared_ptr<VirtualServer>); bool deleteServer(std::shared_ptr<VirtualServer>);
std::shared_ptr<VirtualServer> findServerById(ServerId); std::shared_ptr<VirtualServer> findServerById(ServerId);

View File

@ -603,7 +603,7 @@ command_result QueryClient::handleCommandServerCreate(Command& cmd) {
uint16_t port = cmd[0].has("virtualserver_port") ? cmd["virtualserver_port"].as<uint16_t>() : freePort; uint16_t port = cmd[0].has("virtualserver_port") ? cmd["virtualserver_port"].as<uint16_t>() : freePort;
{ {
auto _start = system_clock::now(); auto _start = system_clock::now();
server = serverInstance->getVoiceServerManager()->createServer(host, port); server = serverInstance->getVoiceServerManager()->create_server(host, port);
auto _end = system_clock::now(); auto _end = system_clock::now();
time_create = duration_cast<milliseconds>(_end - _start); time_create = duration_cast<milliseconds>(_end - _start);
} }