From 06551d3c8e9aa7791d8764259549e9a201798056 Mon Sep 17 00:00:00 2001 From: Brett Hewitson Date: Fri, 17 Dec 2021 14:09:47 +1000 Subject: [PATCH] Added a checkbox to allow all bots. --- src/ARKServerManager/App.config | 3 ++ src/ARKServerManager/App.xaml.cs | 2 +- src/ARKServerManager/Config.Designer.cs | 12 +++++ src/ARKServerManager/Config.settings | 3 ++ .../Globalization/en-US/en-US.xaml | 2 + .../UserControls/GlobalSettingsControl.xaml | 18 +++++--- .../Utils/DiscordBotHelper.cs | 16 +++++-- src/ARKServerManager/VersionFeed.xml | 5 ++- src/ARKServerManager/VersionFeedBeta.xml | 3 +- src/ConanServerManager/App.config | 3 ++ src/ConanServerManager/App.xaml.cs | 2 +- src/ConanServerManager/Config.Designer.cs | 12 +++++ src/ConanServerManager/Config.settings | 3 ++ .../Globalization/en-US/en-US.xaml | 2 + .../UserControls/GlobalSettingsControl.xaml | 18 +++++--- .../Utils/DiscordBotHelper.cs | 16 +++++-- src/ConanServerManager/VersionFeed.xml | 5 ++- src/ConanServerManager/VersionFeedBeta.xml | 3 +- .../Interfaces/IServerManagerBot.cs | 2 +- ...WhitelistConfig.cs => DiscordBotConfig.cs} | 4 +- src/ServerManager.Discord/ServerManagerBot.cs | 9 ++-- .../Services/CommandHandlerService.cs | 44 ++++++++++++------- 22 files changed, 137 insertions(+), 50 deletions(-) rename src/ServerManager.Discord/Models/{DiscordBotWhitelistConfig.cs => DiscordBotConfig.cs} (69%) diff --git a/src/ARKServerManager/App.config b/src/ARKServerManager/App.config index a136ee00..f74ceca5 100644 --- a/src/ARKServerManager/App.config +++ b/src/ARKServerManager/App.config @@ -863,6 +863,9 @@ Info + + False + diff --git a/src/ARKServerManager/App.xaml.cs b/src/ARKServerManager/App.xaml.cs index 74642a34..aded5630 100644 --- a/src/ARKServerManager/App.xaml.cs +++ b/src/ARKServerManager/App.xaml.cs @@ -612,7 +612,7 @@ namespace ServerManagerTool discordWhiteList.AddRange(Config.Default.DiscordBotWhitelist.Cast()); } - await ServerManagerBotFactory.GetServerManagerBot()?.StartAsync(Config.Default.DiscordBotLogLevel, Config.Default.DiscordBotToken, Config.Default.DiscordBotPrefix, Config.Default.DataDir, discordWhiteList, DiscordBotHelper.HandleDiscordCommand, DiscordBotHelper.HandleTranslation, _tokenSourceDiscordBot.Token); + await ServerManagerBotFactory.GetServerManagerBot()?.StartAsync(Config.Default.DiscordBotLogLevel, Config.Default.DiscordBotToken, Config.Default.DiscordBotPrefix, Config.Default.DataDir, Config.Default.DiscordBotAllowAllBots, discordWhiteList, DiscordBotHelper.HandleDiscordCommand, DiscordBotHelper.HandleTranslation, _tokenSourceDiscordBot.Token); if (_tokenSourceDiscordBot != null) { diff --git a/src/ARKServerManager/Config.Designer.cs b/src/ARKServerManager/Config.Designer.cs index 60833055..ae20bf76 100644 --- a/src/ARKServerManager/Config.Designer.cs +++ b/src/ARKServerManager/Config.Designer.cs @@ -3032,5 +3032,17 @@ namespace ServerManagerTool { return ((int)(this["DiscordBotStatusCheckTime"])); } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool DiscordBotAllowAllBots { + get { + return ((bool)(this["DiscordBotAllowAllBots"])); + } + set { + this["DiscordBotAllowAllBots"] = value; + } + } } } diff --git a/src/ARKServerManager/Config.settings b/src/ARKServerManager/Config.settings index 19c0a3ec..6f6869f6 100644 --- a/src/ARKServerManager/Config.settings +++ b/src/ARKServerManager/Config.settings @@ -837,5 +837,8 @@ 10 + + False + \ No newline at end of file diff --git a/src/ARKServerManager/Globalization/en-US/en-US.xaml b/src/ARKServerManager/Globalization/en-US/en-US.xaml index 5d540166..d905aa52 100644 --- a/src/ARKServerManager/Globalization/en-US/en-US.xaml +++ b/src/ARKServerManager/Globalization/en-US/en-US.xaml @@ -634,6 +634,8 @@ Log Level: Get Token... Help... + Allow All Bots + If enabled, the server manager bot will respond to all other bots, otherwise they will be ignored unless they are in the whitelist. Bot Whitelist Bot ID The id of the bot to whitelist. diff --git a/src/ARKServerManager/UserControls/GlobalSettingsControl.xaml b/src/ARKServerManager/UserControls/GlobalSettingsControl.xaml index bee4de9a..b82088fc 100644 --- a/src/ARKServerManager/UserControls/GlobalSettingsControl.xaml +++ b/src/ARKServerManager/UserControls/GlobalSettingsControl.xaml @@ -586,12 +586,14 @@ - - - - - - + + + + + + + + @@ -629,7 +631,7 @@ - + + + diff --git a/src/ARKServerManager/Utils/DiscordBotHelper.cs b/src/ARKServerManager/Utils/DiscordBotHelper.cs index dace86c7..3ee4e57b 100644 --- a/src/ARKServerManager/Utils/DiscordBotHelper.cs +++ b/src/ARKServerManager/Utils/DiscordBotHelper.cs @@ -165,7 +165,9 @@ namespace ServerManagerTool.Utils else { var mapName = _globalizer.GetResourceString($"Map_{info.Map}") ?? info.Map; - response.Add($"```{info.Name}\n{_globalizer.GetResourceString("DiscordBot_MapLabel")} {mapName}\n{_globalizer.GetResourceString("ServerSettings_PlayersLabel")} {info.Players} / {info.MaxPlayers}```"); + response.Add($"```{info.Name}\n" + + $"{_globalizer.GetResourceString("DiscordBot_MapLabel")} {mapName}\n" + + $"{_globalizer.GetResourceString("ServerSettings_PlayersLabel")} {info.Players} / {info.MaxPlayers}```"); } } } @@ -193,7 +195,10 @@ namespace ServerManagerTool.Utils response.Add($"**{_globalizer.GetResourceString("DiscordBot_CountLabel")}** {serverList.Count()}"); foreach (var server in serverList) { - response.Add($"```{_globalizer.GetResourceString("ServerSettings_ProfileIdLabel")} {server.Profile.ProfileID}\n{_globalizer.GetResourceString("ServerSettings_DiscordAliasLabel")} {server.Profile.DiscordAlias}\n{_globalizer.GetResourceString("ServerSettings_ProfileLabel")} {server.Profile.ProfileName}\n{_globalizer.GetResourceString("ServerSettings_ServerNameLabel")} {server.Profile.ServerName}```"); + response.Add($"```{_globalizer.GetResourceString("ServerSettings_ProfileLabel")} {server.Profile.ProfileName}\n" + + $"{_globalizer.GetResourceString("ServerSettings_ProfileIdLabel")} {server.Profile.ProfileID}\n" + + (string.IsNullOrWhiteSpace(server.Profile.DiscordAlias) ? "" : $"{_globalizer.GetResourceString("ServerSettings_DiscordAliasLabel")} {server.Profile.DiscordAlias}\n") + + $"{_globalizer.GetResourceString("ServerSettings_ServerNameLabel")} {server.Profile.ServerName}```"); } }).Wait(); @@ -212,7 +217,12 @@ namespace ServerManagerTool.Utils response.Add($"**{_globalizer.GetResourceString("DiscordBot_CountLabel")}** {serverList.Count()}"); foreach (var server in serverList) { - response.Add($"```{_globalizer.GetResourceString("ServerSettings_ProfileLabel")} {server.Profile.ProfileName}\n{_globalizer.GetResourceString("ServerSettings_ServerNameLabel")} {server.Profile.ServerName}\n{_globalizer.GetResourceString("ServerSettings_StatusLabel")} {server.Runtime.StatusString}\n{_globalizer.GetResourceString("ServerSettings_AvailabilityLabel")} {_globalizer.GetResourceString($"ServerSettings_Availability_{server.Runtime.Availability}")}```"); + response.Add($"```{_globalizer.GetResourceString("ServerSettings_ProfileLabel")} {server.Profile.ProfileName}\n" + + $"{_globalizer.GetResourceString("ServerSettings_ProfileIdLabel")} {server.Profile.ProfileID}\n" + + (string.IsNullOrWhiteSpace(server.Profile.DiscordAlias) ? "" : $"{_globalizer.GetResourceString("ServerSettings_DiscordAliasLabel")} {server.Profile.DiscordAlias}\n") + + $"{_globalizer.GetResourceString("ServerSettings_ServerNameLabel")} {server.Profile.ServerName}\n" + + $"{_globalizer.GetResourceString("ServerSettings_StatusLabel")} {server.Runtime.StatusString}\n" + + $"{_globalizer.GetResourceString("ServerSettings_AvailabilityLabel")} {_globalizer.GetResourceString($"ServerSettings_Availability_{server.Runtime.Availability}")}```"); } }).Wait(); diff --git a/src/ARKServerManager/VersionFeed.xml b/src/ARKServerManager/VersionFeed.xml index d2349003..4841b4be 100644 --- a/src/ARKServerManager/VersionFeed.xml +++ b/src/ARKServerManager/VersionFeed.xml @@ -19,16 +19,17 @@ NEW
CHANGE