From 5f1b807541736f99c27a3fdfd6cc0e57a9569ecb Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sat, 24 Nov 2018 14:57:39 -0500 Subject: [PATCH] Fix issues with chat send commands --- src/Tgstation.Server.Host/Components/Chat/Channel.cs | 4 ++-- src/Tgstation.Server.Host/Components/Chat/Chat.cs | 8 ++++---- .../Components/Chat/Commands/ICommand.cs | 2 +- .../Components/Chat/Providers/DiscordProvider.cs | 6 +++--- .../Components/Chat/Providers/IrcProvider.cs | 6 +++--- .../Components/Interop/CommCommand.cs | 2 +- .../Components/Interop/CommContext.cs | 2 +- .../Components/Watchdog/SessionController.cs | 4 ++-- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Channel.cs b/src/Tgstation.Server.Host/Components/Chat/Channel.cs index 131ce67962..fe5d6acb15 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Channel.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Channel.cs @@ -38,12 +38,12 @@ namespace Tgstation.Server.Host.Components.Chat /// /// If this is considered a channel for admin commands /// - public bool IsAdmin { get; set; } + public bool IsAdminChannel { get; set; } /// /// If this is a 1-to-1 chat channel /// - public bool IsPrivate { get; set; } + public bool IsPrivateChannel { get; set; } /// /// For user use diff --git a/src/Tgstation.Server.Host/Components/Chat/Chat.cs b/src/Tgstation.Server.Host/Components/Chat/Chat.cs index b4d68b1139..fc7321af84 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Chat.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Chat.cs @@ -195,7 +195,7 @@ namespace Tgstation.Server.Host.Components.Chat { var providerId = providers.Where(x => x.Value == provider).Select(x => x.Key).First(); var enumerable = mappedChannels.Where(x => x.Value.ProviderId == providerId && x.Value.ProviderChannelId == message.User.Channel.RealId); - if (message.User.Channel.IsPrivate) + if (message.User.Channel.IsPrivateChannel) lock (mappedChannels) { if (!provider.Connected) @@ -223,7 +223,7 @@ namespace Tgstation.Server.Host.Components.Chat var mapping = enumerable.First().Value; message.User.Channel.Id = mapping.Channel.Id; message.User.Channel.Tag = mapping.Channel.Tag; - message.User.Channel.IsAdmin = mapping.Channel.IsAdmin; + message.User.Channel.IsAdminChannel = mapping.Channel.IsAdminChannel; } } @@ -236,7 +236,7 @@ namespace Tgstation.Server.Host.Components.Chat var addressed = address == CommonMention.ToUpperInvariant() || address == provider.BotMention.ToUpperInvariant(); - if (!addressed && !message.User.Channel.IsPrivate) + if (!addressed && !message.User.Channel.IsPrivateChannel) //no mention return; @@ -302,7 +302,7 @@ namespace Tgstation.Server.Host.Components.Chat return; } - if (commandHandler.AdminOnly && !message.User.Channel.IsAdmin) + if (commandHandler.AdminOnly && !message.User.Channel.IsAdminChannel) { await SendMessage("Use this command in an admin channel!", new List { message.User.Channel.RealId }, cancellationToken).ConfigureAwait(false); return; diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/ICommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/ICommand.cs index 8694606731..4ff8799ce7 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/ICommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/ICommand.cs @@ -19,7 +19,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands string HelpText { get; } /// - /// If the command should only be available to s who's has set + /// If the command should only be available to s who's has set /// bool AdminOnly { get; } diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs index 711454887c..50996ed74a 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs @@ -97,7 +97,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers Channel = new Channel { RealId = e.Channel.Id, - IsPrivate = pm, + IsPrivateChannel = pm, ConnectionName = pm ? e.Author.Username : (e.Channel as ITextChannel)?.Guild.Name ?? "UNKNOWN", FriendlyName = e.Channel.Name //isAdmin and Tag populated by manager @@ -188,10 +188,10 @@ namespace Tgstation.Server.Host.Components.Chat.Providers return new Channel { RealId = discordChannel.Id, - IsAdmin = channel.IsAdminChannel == true, + IsAdminChannel = channel.IsAdminChannel == true, ConnectionName = discordChannel.Guild.Name, FriendlyName = discordChannel.Name, - IsPrivate = false, + IsPrivateChannel = false, Tag = channel.Tag }; }; diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs index cd08c1760e..01fa89697e 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs @@ -204,7 +204,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers ConnectionName = address, FriendlyName = isPrivate ? String.Format(CultureInfo.InvariantCulture, "PM: {0}", channelName) : channelName, RealId = channelId, - IsPrivate = isPrivate + IsPrivateChannel = isPrivate //isAdmin and Tag populated by manager }, FriendlyName = username, @@ -393,10 +393,10 @@ namespace Tgstation.Server.Host.Components.Chat.Providers return new Channel { RealId = id.Value, - IsAdmin = x.IsAdminChannel == true, + IsAdminChannel = x.IsAdminChannel == true, ConnectionName = address, FriendlyName = channelIdMap[id.Value], - IsPrivate = false, + IsPrivateChannel = false, Tag = x.Tag }; }).ToList(); diff --git a/src/Tgstation.Server.Host/Components/Interop/CommCommand.cs b/src/Tgstation.Server.Host/Components/Interop/CommCommand.cs index 7145d35aae..31b4715897 100644 --- a/src/Tgstation.Server.Host/Components/Interop/CommCommand.cs +++ b/src/Tgstation.Server.Host/Components/Interop/CommCommand.cs @@ -10,7 +10,7 @@ namespace Tgstation.Server.Host.Components.Interop /// /// The dictionary of the /// - public IReadOnlyDictionary Parameters { get; set; } + public IReadOnlyDictionary Parameters { get; set; } /// /// The raw JSON of the diff --git a/src/Tgstation.Server.Host/Components/Interop/CommContext.cs b/src/Tgstation.Server.Host/Components/Interop/CommContext.cs index f9c5208d88..e910ad7ffa 100644 --- a/src/Tgstation.Server.Host/Components/Interop/CommContext.cs +++ b/src/Tgstation.Server.Host/Components/Interop/CommContext.cs @@ -109,7 +109,7 @@ namespace Tgstation.Server.Host.Components.Interop { command = new CommCommand { - Parameters = JsonConvert.DeserializeObject>(file), + Parameters = JsonConvert.DeserializeObject>(file), RawJson = file }; } diff --git a/src/Tgstation.Server.Host/Components/Watchdog/SessionController.cs b/src/Tgstation.Server.Host/Components/Watchdog/SessionController.cs index 8cd90b5b72..e36ecedd0e 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/SessionController.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/SessionController.cs @@ -316,7 +316,7 @@ namespace Tgstation.Server.Host.Components.Watchdog case Constants.DMCommandNewPort: lock (this) { - if (!query.TryGetValue(Constants.DMParameterData, out var stringPort) || !UInt16.TryParse(stringPort, out var currentPort)) + if (!query.TryGetValue(Constants.DMParameterData, out var stringPortObject) || !UInt16.TryParse(stringPortObject as string, out var currentPort)) { /////UHHHH logger.LogWarning("DreamDaemon sent new port command without providing it's own!"); @@ -354,7 +354,7 @@ namespace Tgstation.Server.Host.Components.Watchdog content = new ErrorMessage { Message = "Invalid API validation request!" }; break; } - if (!query.TryGetValue(Constants.DMParameterData, out var stringMinimumSecurityLevel) || !Enum.TryParse(stringMinimumSecurityLevel, out var minimumSecurityLevel)) + if (!query.TryGetValue(Constants.DMParameterData, out var stringMinimumSecurityLevelObject) || !Enum.TryParse(stringMinimumSecurityLevelObject as string, out var minimumSecurityLevel)) apiValidationStatus = ApiValidationStatus.BadValidationRequest; else switch (minimumSecurityLevel)