From ae9fea4785444ea348050e8bfed689bbc566f269 Mon Sep 17 00:00:00 2001 From: 13xforever Date: Fri, 20 Jul 2018 23:11:09 +0500 Subject: [PATCH] fixed the issue where manual library selection was selected, but no library was checked --- CompatBot/EventHandlers/LogInfoHandler.cs | 39 +++++++++++-------- .../LogParserResultFormatter.cs | 2 + 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/CompatBot/EventHandlers/LogInfoHandler.cs b/CompatBot/EventHandlers/LogInfoHandler.cs index 76c61a53..a252c1b1 100644 --- a/CompatBot/EventHandlers/LogInfoHandler.cs +++ b/CompatBot/EventHandlers/LogInfoHandler.cs @@ -55,26 +55,33 @@ namespace CompatBot.EventHandlers await args.Channel.SendMessageAsync("Log analysis failed, most likely cause is a truncated/invalid log. Please run the game again and reupload the new copy.").ConfigureAwait(false); else { - await args.Channel.SendMessageAsync(embed: await result.AsEmbedAsync(args.Client, args.Message).ConfigureAwait(false)).ConfigureAwait(false); - if (result.Error == LogParseState.ErrorCode.PiracyDetected) + try { - bool needsAttention = false; - try + await args.Channel.SendMessageAsync(embed: await result.AsEmbedAsync(args.Client, args.Message).ConfigureAwait(false)).ConfigureAwait(false); + if (result.Error == LogParseState.ErrorCode.PiracyDetected) { - await message.DeleteAsync("Piracy detected in log").ConfigureAwait(false); + bool needsAttention = false; + try + { + await message.DeleteAsync("Piracy detected in log").ConfigureAwait(false); + } + catch (Exception e) + { + needsAttention = true; + args.Client.DebugLogger.LogMessage(LogLevel.Warning, "", $"Unable to delete message in {args.Channel.Name}: {e.Message}", DateTime.Now); + } + await Task.WhenAll( + args.Client.ReportAsync("Pirated Release", args.Message, result.PiracyTrigger, result.PiracyContext, needsAttention), + Warnings.AddAsync(args.Client, args.Message, args.Message.Author.Id, args.Message.Author.Username, args.Client.CurrentUser, + "Pirated Release", $"{message.Content.Sanitize()} - {result.PiracyTrigger}") + ); } - catch (Exception e) - { - needsAttention = true; - args.Client.DebugLogger.LogMessage(LogLevel.Warning, "", $"Unable to delete message in {args.Channel.Name}: {e.Message}", DateTime.Now); - } - await Task.WhenAll( - args.Client.ReportAsync("Pirated Release", args.Message, result.PiracyTrigger, result.PiracyContext, needsAttention), - Warnings.AddAsync(args.Client, args.Message, args.Message.Author.Id, args.Message.Author.Username, args.Client.CurrentUser, - "Pirated Release", $"{message.Content.Sanitize()} - {result.PiracyTrigger}") - ); } - } + catch (Exception e) + { + args.Client.DebugLogger.LogMessage(LogLevel.Error, "", "Sending log results failed: " + e, DateTime.Now); + } + } return; } diff --git a/CompatBot/Utils/ResultFormatters/LogParserResultFormatter.cs b/CompatBot/Utils/ResultFormatters/LogParserResultFormatter.cs index 01d9c5ae..8291ed5d 100644 --- a/CompatBot/Utils/ResultFormatters/LogParserResultFormatter.cs +++ b/CompatBot/Utils/ResultFormatters/LogParserResultFormatter.cs @@ -121,6 +121,8 @@ namespace CompatBot.Utils.ResultFormatters var libList = libs.Split('\n').Select(l => l.Trim(' ', '\t', '-', '\r', '[', ']')).Where(s => !string.IsNullOrEmpty(s)).ToList(); items["library_list"] = libList.Count > 0 ? string.Join(", ", libList) : "None"; } + else + items["library_list"] = "None"; foreach (var key in items.AllKeys) {