diff --git a/CHEF/CHEF.cs b/CHEF/CHEF.cs index 5cff6ab..dec8946 100644 --- a/CHEF/CHEF.cs +++ b/CHEF/CHEF.cs @@ -25,7 +25,6 @@ private async Task MainAsync() private async Task InitOnClientReady() { - Logger.Init(); await Task.CompletedTask; } diff --git a/CHEF/Components/Commands/Cooking/Cook.cs b/CHEF/Components/Commands/Cooking/Cook.cs index 25b1e51..56269c3 100644 --- a/CHEF/Components/Commands/Cooking/Cook.cs +++ b/CHEF/Components/Commands/Cooking/Cook.cs @@ -18,7 +18,6 @@ public override async Task SetupAsync() using (var context = new RecipeContext()) { await context.Database.MigrateAsync(); - Logger.Log("Done migrating recipe table."); } Client.MessageReceived += RecipeShortcutAsync; @@ -48,6 +47,7 @@ private Task RecipeShortcutAsync(SocketMessage msg) var guild = (msg.Channel as SocketGuildChannel)?.Guild; await msg.Channel.SendMessageAsync( $"**Recipe: {recipe.Name} (Owner: {recipe.RealOwnerName(guild)})**{Environment.NewLine}{recipe.Text}"); + Logger.Log($"[{DateTime.UtcNow}] Recipe {recipe.Name} was executed by {msg.Author}."); } } diff --git a/CHEF/Components/Commands/Cooking/CookModule.cs b/CHEF/Components/Commands/Cooking/CookModule.cs index 7ca7b9e..46375a0 100644 --- a/CHEF/Components/Commands/Cooking/CookModule.cs +++ b/CHEF/Components/Commands/Cooking/CookModule.cs @@ -340,7 +340,6 @@ public async Task DeleteDuplicateRecipes() foreach (var duplicate in duplicates) { - Logger.Log("duplicate recipe : " + duplicate.Name); nameOfRecipesToRemove.Add(duplicate.Name); } @@ -370,7 +369,6 @@ public async Task DeleteDuplicateRecipes() foreach (var forbidden in forbiddens) { - Logger.Log("forbidden recipe : " + forbidden.Name); recipesToRemove.Add(forbidden); } diff --git a/CHEF/Components/ComponentHandler.cs b/CHEF/Components/ComponentHandler.cs index 62cf9bb..e635b98 100644 --- a/CHEF/Components/ComponentHandler.cs +++ b/CHEF/Components/ComponentHandler.cs @@ -13,16 +13,17 @@ internal static class ComponentHandler internal static async Task Init(DiscordSocketClient client) { + LoadedComponents.Clear(); + var componentTypes = Assembly.GetExecutingAssembly().GetTypes().Where(ComponentFilter).ToList(); foreach (var componentType in componentTypes) { try { - Logger.Log($"Enabling Component: {componentType.Name}"); - var compInstance = (Component)Activator.CreateInstance(componentType, client); await compInstance.SetupAsync(); + LoadedComponents.Add(compInstance); } catch (Exception e) { diff --git a/CHEF/Components/Watcher/AutoPastebin.cs b/CHEF/Components/Watcher/AutoPastebin.cs index eb9c4c3..4a20e74 100644 --- a/CHEF/Components/Watcher/AutoPastebin.cs +++ b/CHEF/Components/Watcher/AutoPastebin.cs @@ -58,11 +58,6 @@ msg.Channel is SocketTextChannel && $"Automatic pastebin for {msg.Author.Username} {attachment.Filename} file: {pasteResult.FullUrl}"); return botAnswer.ToString(); } - else - { - Logger.Log( - $"Failed to make pastebin for {msg.Author.Username} {attachment.Filename}, size: {attachment.Size}. HTTP Error code {pasteResult.StatusCode}"); - } } } } diff --git a/CHEF/Components/Watcher/CommonIssues.cs b/CHEF/Components/Watcher/CommonIssues.cs index c8297f1..c5c2a59 100644 --- a/CHEF/Components/Watcher/CommonIssues.cs +++ b/CHEF/Components/Watcher/CommonIssues.cs @@ -98,10 +98,8 @@ public static async Task CheckModsVersion(string text, StringBuilder answe { var modName = match.Groups[1].ToString(); var verFromText = match.Groups[2].ToString().Replace(" ", ""); - //Logger.Log("modName : " + modName); - //Logger.Log("verFromText : " + verFromText); - // todo : re-enable me when we have consistency + // todo : re-enable me for all plugins when we have consistency // across manifest version and the version from the plugin / log var (latestVer, isDeprecated) = await IsThisLatestModVersion(modName, verFromText); diff --git a/CHEF/Components/Watcher/ImageParser.cs b/CHEF/Components/Watcher/ImageParser.cs index 1ff2aed..8f10f4d 100644 --- a/CHEF/Components/Watcher/ImageParser.cs +++ b/CHEF/Components/Watcher/ImageParser.cs @@ -46,15 +46,11 @@ msg.Channel is SocketTextChannel && var fileType = System.IO.Path.GetExtension(attachment.Url); if (fileType == ".png") { - Logger.Log("Preparing a query for Yandex."); - var botAnswer = new StringBuilder(); var queryResult = await QueryYandex(attachment.Url); - Logger.Log("Checking for common log errors."); CommonIssues.CheckCommonLogError(queryResult.ImageText, botAnswer, msg.Author); - Logger.Log("Checking for outdated mods."); var hasOutdatedMods = await CommonIssues.CheckModsVersion(queryResult.ImageText, botAnswer, msg.Author); if (hasOutdatedMods) { @@ -63,7 +59,6 @@ msg.Channel is SocketTextChannel && queryResult.HasModLoadingText = true; } - Logger.Log("Checking if its a version mismatch problem"); if (queryResult.ImageText.Contains("version mismatch", StringComparison.InvariantCultureIgnoreCase) || queryResult.ImageText.Contains("Yours=MOD", StringComparison.InvariantCultureIgnoreCase)) { @@ -74,7 +69,6 @@ msg.Channel is SocketTextChannel && return botAnswer.ToString(); } - Logger.Log("Checking if its a console image"); if (queryResult.IsAConsole()) { botAnswer.AppendLine($"{msg.Author.Mention}, looks like you just uploaded a screenshot of a BepinEx console / log file." + @@ -95,7 +89,6 @@ msg.Channel is SocketTextChannel && return botAnswer.ToString(); } - Logger.Log("Checking if its a window explorer image"); if (queryResult.IsWindowExplorer() && (queryResult.ImageText.Contains("bepin", StringComparison.InvariantCultureIgnoreCase) || queryResult.ImageText.Contains("risk of rain", StringComparison.InvariantCultureIgnoreCase))) @@ -130,7 +123,6 @@ private async Task QueryYandex(string imageUrl) var document = (await web.LoadFromWebAsync($"{_postUrl}{imageUrl}&rpt=imageview")).DocumentNode; var tags = document.SelectNodes("//*[@class=\"CbirItem CbirTags\"]//*[@class=\"Button2-Text\"]"); res.AddTags(tags); - Logger.Log("Got the image tags."); // Catch any error in case the Cloud Vision Service is // not correctly setup : An exception will be thrown @@ -138,8 +130,7 @@ private async Task QueryYandex(string imageUrl) try { var img = Image.FromUri(imageUrl); - res.AddText(CloudVisionOcr.AnnotatorClient.DetectText(img)); - Logger.Log("Got the image text : " + res.ImageText); + res.AddText(await CloudVisionOcr.AnnotatorClient.DetectTextAsync(img)); } catch (Exception e) { @@ -149,7 +140,7 @@ private async Task QueryYandex(string imageUrl) return res; } - public class YandexImageQuery + private class YandexImageQuery { private readonly List _imageTags; public string ImageText { get; private set; } diff --git a/CHEF/Logger.cs b/CHEF/Logger.cs index beb1df8..7ad2455 100644 --- a/CHEF/Logger.cs +++ b/CHEF/Logger.cs @@ -9,11 +9,6 @@ internal static class Logger { private const string LogPrefix = "[CHEF]"; - internal static void Init() - { - Log("Logger Init"); - } - internal static void Log(string msg) { var log = $"{LogPrefix} {msg}";