From b6911c09c41aa36deacefdd795554d3d7e9512ec Mon Sep 17 00:00:00 2001 From: Michael Flaherty Date: Fri, 7 Sep 2018 05:31:25 -0700 Subject: [PATCH] Unify logging to Discord.NET --- IRC-Relay/Discord.cs | 8 +++----- IRC-Relay/IRC.cs | 4 ++-- IRC-Relay/Program.cs | 3 ++- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/IRC-Relay/Discord.cs b/IRC-Relay/Discord.cs index 4f6ad93..089c458 100644 --- a/IRC-Relay/Discord.cs +++ b/IRC-Relay/Discord.cs @@ -76,7 +76,7 @@ public async Task SpawnBot() public async Task OnDiscordConnected() { - await session.Discord.Log(new LogMessage(LogSeverity.Critical, "DiscSpawn", "Discord bot initalized.")); + await Discord.Log(new LogMessage(LogSeverity.Critical, "DiscSpawn", "Discord bot initalized.")); } /* When we disconnect from discord (we got booted off), we'll remake */ @@ -197,7 +197,7 @@ await messageParam.Author.SendMessageAsync("To prevent you from having to re-typ } } - public Task Log(LogMessage msg) + public static Task Log(LogMessage msg) { return Task.Run(() => Console.WriteLine(msg.ToString())); } @@ -224,9 +224,7 @@ public static string UploadMarkDown(string input) } string key = (string)obj["key"]; - string hasteUrl = "https://hastebin.com/" + key + ".cs"; - - return hasteUrl; + return "https://hastebin.com/" + key + ".cs"; } } public static string MentionToUsername(string input, SocketUserMessage message) diff --git a/IRC-Relay/IRC.cs b/IRC-Relay/IRC.cs index 77cd08b..4a6b68f 100644 --- a/IRC-Relay/IRC.cs +++ b/IRC-Relay/IRC.cs @@ -87,7 +87,7 @@ await Task.Run(() => private void OnConnected(object sender, EventArgs e) { - session.Discord.Log(new LogMessage(LogSeverity.Critical, "IRCSpawn", "IRC bot initalized.")); + Discord.Log(new LogMessage(LogSeverity.Critical, "IRCSpawn", "IRC bot initalized.")); } private void OnError(object sender, ErrorEventArgs e) @@ -96,7 +96,7 @@ private void OnError(object sender, ErrorEventArgs e) * this Disconnect call */ new System.Threading.Thread(() => { session.Kill(); }).Start(); - session.Discord.Log(new LogMessage(LogSeverity.Critical, "IRCOnError", e.ErrorMessage)); + Discord.Log(new LogMessage(LogSeverity.Critical, "IRCOnError", e.ErrorMessage)); } private void OnChannelMessage(object sender, IrcEventArgs e) diff --git a/IRC-Relay/Program.cs b/IRC-Relay/Program.cs index 06787eb..f673e19 100644 --- a/IRC-Relay/Program.cs +++ b/IRC-Relay/Program.cs @@ -19,6 +19,7 @@ using System.IO; using System.Threading.Tasks; +using Discord; using JsonConfig; namespace IRCRelay @@ -39,7 +40,7 @@ private static async Task StartSessions(dynamic config) do { await session.StartSession(); - Console.WriteLine("Session failure... New session starting."); + await Discord.Log(new LogMessage(LogSeverity.Critical, "Main", "Session officially over. Starting new...")); } while (!session.IsAlive); } }