From 81adbb454abe95a3c78735536823e601a19d69c3 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Fri, 20 Oct 2017 14:10:07 -0400 Subject: [PATCH] ChatMessageType => MessageType --- TGServerService/ChatProviders/ChatProvider.cs | 2 +- .../ChatProviders/DiscordChatProvider.cs | 10 +++---- .../ChatProviders/IRCChatProvider.cs | 10 +++---- .../{ChatMessageType.cs => MessageType.cs} | 2 +- TGServerService/ServerInstance/Byond.cs | 10 +++---- TGServerService/ServerInstance/Chat.cs | 2 +- TGServerService/ServerInstance/Compiler.cs | 18 ++++++------ TGServerService/ServerInstance/DreamDaemon.cs | 16 +++++------ TGServerService/ServerInstance/Interop.cs | 4 +-- TGServerService/ServerInstance/Repository.cs | 28 +++++++++---------- .../ServerInstance/ServerInstance.cs | 2 +- TGServerService/TGServerService.csproj | 2 +- 12 files changed, 53 insertions(+), 53 deletions(-) rename TGServerService/{ChatMessageType.cs => MessageType.cs} (95%) diff --git a/TGServerService/ChatProviders/ChatProvider.cs b/TGServerService/ChatProviders/ChatProvider.cs index e343f2b79b..c99f138a07 100644 --- a/TGServerService/ChatProviders/ChatProvider.cs +++ b/TGServerService/ChatProviders/ChatProvider.cs @@ -72,6 +72,6 @@ namespace TGServerService.ChatProviders /// /// The message to send /// The message type - void SendMessage(string msg, ChatMessageType mt); + void SendMessage(string msg, MessageType mt); } } diff --git a/TGServerService/ChatProviders/DiscordChatProvider.cs b/TGServerService/ChatProviders/DiscordChatProvider.cs index 573ef7517e..313e5096ef 100644 --- a/TGServerService/ChatProviders/DiscordChatProvider.cs +++ b/TGServerService/ChatProviders/DiscordChatProvider.cs @@ -132,7 +132,7 @@ namespace TGServerService.ChatProviders return Connect(); } - public void SendMessage(string msg, ChatMessageType mt) + public void SendMessage(string msg, MessageType mt) { if (!Connected()) return; @@ -145,10 +145,10 @@ namespace TGServerService.ChatProviders { var cid = J.Id.ToString(); var wdc = DiscordConfig.WatchdogChannels; - bool SendToThisChannel = (mt.HasFlag(ChatMessageType.AdminInfo) && DiscordConfig.AdminChannels.Contains(cid)) - || (mt.HasFlag(ChatMessageType.DeveloperInfo) && DiscordConfig.DevChannels.Contains(cid)) - || (mt.HasFlag(ChatMessageType.GameInfo) && DiscordConfig.GameChannels.Contains(cid)) - || (mt.HasFlag(ChatMessageType.WatchdogInfo) && DiscordConfig.WatchdogChannels.Contains(cid)); + bool SendToThisChannel = (mt.HasFlag(MessageType.AdminInfo) && DiscordConfig.AdminChannels.Contains(cid)) + || (mt.HasFlag(MessageType.DeveloperInfo) && DiscordConfig.DevChannels.Contains(cid)) + || (mt.HasFlag(MessageType.GameInfo) && DiscordConfig.GameChannels.Contains(cid)) + || (mt.HasFlag(MessageType.WatchdogInfo) && DiscordConfig.WatchdogChannels.Contains(cid)); if (SendToThisChannel) tasks.Add(J.SendMessageAsync(msg)); diff --git a/TGServerService/ChatProviders/IRCChatProvider.cs b/TGServerService/ChatProviders/IRCChatProvider.cs index 279aee4323..d79d236835 100644 --- a/TGServerService/ChatProviders/IRCChatProvider.cs +++ b/TGServerService/ChatProviders/IRCChatProvider.cs @@ -259,7 +259,7 @@ namespace TGServerService.ChatProviders } } //public api - public void SendMessage(string message, ChatMessageType mt) + public void SendMessage(string message, MessageType mt) { if (!Connected()) return; @@ -267,10 +267,10 @@ namespace TGServerService.ChatProviders { foreach (var cid in irc.JoinedChannels) { - bool SendToThisChannel = (mt.HasFlag(ChatMessageType.AdminInfo) && IRCConfig.AdminChannels.Contains(cid)) - || (mt.HasFlag(ChatMessageType.DeveloperInfo) && IRCConfig.DevChannels.Contains(cid)) - || (mt.HasFlag(ChatMessageType.GameInfo) && IRCConfig.GameChannels.Contains(cid)) - || (mt.HasFlag(ChatMessageType.WatchdogInfo) && IRCConfig.WatchdogChannels.Contains(cid)); + bool SendToThisChannel = (mt.HasFlag(MessageType.AdminInfo) && IRCConfig.AdminChannels.Contains(cid)) + || (mt.HasFlag(MessageType.DeveloperInfo) && IRCConfig.DevChannels.Contains(cid)) + || (mt.HasFlag(MessageType.GameInfo) && IRCConfig.GameChannels.Contains(cid)) + || (mt.HasFlag(MessageType.WatchdogInfo) && IRCConfig.WatchdogChannels.Contains(cid)); if (SendToThisChannel) irc.SendMessage(SendType.Message, cid, message); } diff --git a/TGServerService/ChatMessageType.cs b/TGServerService/MessageType.cs similarity index 95% rename from TGServerService/ChatMessageType.cs rename to TGServerService/MessageType.cs index a727a28488..8db0cf2298 100644 --- a/TGServerService/ChatMessageType.cs +++ b/TGServerService/MessageType.cs @@ -6,7 +6,7 @@ namespace TGServerService /// Type of chat message, these may be OR'd together /// [Flags] - enum ChatMessageType + enum MessageType { /// /// Send message to the admin channels diff --git a/TGServerService/ServerInstance/Byond.cs b/TGServerService/ServerInstance/Byond.cs index e3e415649e..3c2ede7354 100644 --- a/TGServerService/ServerInstance/Byond.cs +++ b/TGServerService/ServerInstance/Byond.cs @@ -163,7 +163,7 @@ namespace TGServerService var vi = (VersionInfo)param; using (var client = new WebClient()) { - SendMessage(String.Format("BYOND: Updating to version {0}.{1}...", vi.major, vi.minor), ChatMessageType.DeveloperInfo); + SendMessage(String.Format("BYOND: Updating to version {0}.{1}...", vi.major, vi.minor), MessageType.DeveloperInfo); //DOWNLOADING @@ -173,7 +173,7 @@ namespace TGServerService } catch { - SendMessage("BYOND: Update download failed. Does the specified version exist?", ChatMessageType.DeveloperInfo); + SendMessage("BYOND: Update download failed. Does the specified version exist?", MessageType.DeveloperInfo); lastError = String.Format("Download of BYOND version {0}.{1} failed! Does it exist?", vi.major, vi.minor); Service.WriteWarning(String.Format("Failed to update BYOND to version {0}.{1}!", vi.major, vi.minor), EventID.BYONDUpdateFail); lock (ByondLock) @@ -216,7 +216,7 @@ namespace TGServerService default: RequestRestart(); lastError = "Update staged. Awaiting server restart..."; - SendMessage(String.Format("BYOND: Staging complete. Awaiting server restart...", vi.major, vi.minor), ChatMessageType.DeveloperInfo); + SendMessage(String.Format("BYOND: Staging complete. Awaiting server restart...", vi.major, vi.minor), MessageType.DeveloperInfo); Service.WriteInfo(String.Format("BYOND update {0}.{1} staged", vi.major, vi.minor), EventID.BYONDUpdateStaged); break; } @@ -273,14 +273,14 @@ namespace TGServerService Directory.Move(StagingDirectoryInner, ByondDirectory); Program.DeleteDirectory(StagingDirectory); lastError = null; - SendMessage("BYOND: Update completed!", ChatMessageType.DeveloperInfo); + SendMessage("BYOND: Update completed!", MessageType.DeveloperInfo); Service.WriteInfo(String.Format("BYOND update {0} completed!", GetVersion(ByondVersion.Installed)), EventID.BYONDUpdateComplete); return true; } catch (Exception e) { lastError = e.ToString(); - SendMessage("BYOND: Update failed!", ChatMessageType.DeveloperInfo); + SendMessage("BYOND: Update failed!", MessageType.DeveloperInfo); Service.WriteError("BYOND update failed!", EventID.BYONDUpdateFail); return false; } diff --git a/TGServerService/ServerInstance/Chat.cs b/TGServerService/ServerInstance/Chat.cs index d017dab391..64cd4f8b0b 100644 --- a/TGServerService/ServerInstance/Chat.cs +++ b/TGServerService/ServerInstance/Chat.cs @@ -197,7 +197,7 @@ namespace TGServerService /// /// The message to send /// The message type - public void SendMessage(string msg, ChatMessageType mt) + public void SendMessage(string msg, MessageType mt) { lock (ChatLock) { diff --git a/TGServerService/ServerInstance/Compiler.cs b/TGServerService/ServerInstance/Compiler.cs index e3247b3424..25f839bf3a 100644 --- a/TGServerService/ServerInstance/Compiler.cs +++ b/TGServerService/ServerInstance/Compiler.cs @@ -185,7 +185,7 @@ namespace TGServerService } try { - SendMessage("DM: Setting up symlinks...", ChatMessageType.DeveloperInfo); + SendMessage("DM: Setting up symlinks...", MessageType.DeveloperInfo); CleanGameFolder(); Program.DeleteDirectory(GameDir); @@ -220,7 +220,7 @@ namespace TGServerService { lock (CompilerLock) { - SendMessage("DM: Setup failed!", ChatMessageType.DeveloperInfo); + SendMessage("DM: Setup failed!", MessageType.DeveloperInfo); lastCompilerError = e.ToString(); compilerCurrentStatus = CompilerStatus.Uninitialized; return; @@ -330,7 +330,7 @@ namespace TGServerService if (repobusy_check) { - SendMessage("DM: Copy aborted, repo locked!", ChatMessageType.DeveloperInfo); + SendMessage("DM: Copy aborted, repo locked!", MessageType.DeveloperInfo); lock (CompilerLock) { lastCompilerError = "The repo could not be locked for copying"; @@ -349,7 +349,7 @@ namespace TGServerService } if (!silent) - SendMessage("DM: Compiling...", ChatMessageType.DeveloperInfo); + SendMessage("DM: Compiling...", MessageType.DeveloperInfo); resurrectee = GetStagingDir(); @@ -412,7 +412,7 @@ namespace TGServerService if (!File.Exists(dmePath)) { var errorMsg = String.Format("Could not find {0}!", dmeName); - SendMessage("DM: " + errorMsg, ChatMessageType.DeveloperInfo); + SendMessage("DM: " + errorMsg, MessageType.DeveloperInfo); Service.WriteError(errorMsg, EventID.DMCompileCrash); lock (CompilerLock) { @@ -529,7 +529,7 @@ namespace TGServerService } UpdateLiveSha(CurrentSha); var msg = String.Format("Compile complete!{0}", !staged ? "" : " Server will update next round."); - SendMessage("DM: " + msg, ChatMessageType.DeveloperInfo); + SendMessage("DM: " + msg, MessageType.DeveloperInfo); Service.WriteInfo(msg, EventID.DMCompileSuccess); lock (CompilerLock) { @@ -541,7 +541,7 @@ namespace TGServerService } else { - SendMessage("DM: Compile failed!", ChatMessageType.DeveloperInfo); //Also happens for warnings + SendMessage("DM: Compile failed!", MessageType.DeveloperInfo); //Also happens for warnings Service.WriteWarning("Compile error: " + OutputList.ToString(), EventID.DMCompileError); lock (CompilerLock) { @@ -558,7 +558,7 @@ namespace TGServerService } catch (Exception e) { - SendMessage("DM: Compiler thread crashed!", ChatMessageType.DeveloperInfo); + SendMessage("DM: Compiler thread crashed!", MessageType.DeveloperInfo); Service.WriteError("Compile manager errror: " + e.ToString(), EventID.DMCompileCrash); lock (CompilerLock) { @@ -575,7 +575,7 @@ namespace TGServerService { compilerCurrentStatus = CompilerStatus.Initialized; compilationCancellationRequestation = false; - SendMessage("DM: Compile cancelled!", ChatMessageType.DeveloperInfo); + SendMessage("DM: Compile cancelled!", MessageType.DeveloperInfo); Service.WriteInfo("Compilation cancelled", EventID.DMCompileCancel); } } diff --git a/TGServerService/ServerInstance/DreamDaemon.cs b/TGServerService/ServerInstance/DreamDaemon.cs index a65c5f162c..b924ec6dea 100644 --- a/TGServerService/ServerInstance/DreamDaemon.cs +++ b/TGServerService/ServerInstance/DreamDaemon.cs @@ -57,7 +57,7 @@ namespace TGServerService ThreadPool.QueueUserWorkItem(_ => { Thread.Sleep(5000); - SendMessage("DD: Update complete. Watch dog reactivated...", ChatMessageType.WatchdogInfo); + SendMessage("DD: Update complete. Watch dog reactivated...", MessageType.WatchdogInfo); }); //start wd @@ -113,7 +113,7 @@ namespace TGServerService else { RenameLog = CurrentDDLog != null; - SendMessage("DD: Detaching watch dog for update!", ChatMessageType.WatchdogInfo); + SendMessage("DD: Detaching watch dog for update!", MessageType.WatchdogInfo); WriteCurrentDDLog("Service updating! Splitting diagnostics..."); } } @@ -214,7 +214,7 @@ namespace TGServerService return "Restart already in progress"; RestartInProgress = true; } - SendMessage("DD: Hard restart triggered", ChatMessageType.WatchdogInfo); + SendMessage("DD: Hard restart triggered", MessageType.WatchdogInfo); Stop(); var res = Start(); if(res != null) @@ -244,7 +244,7 @@ namespace TGServerService { if (!RestartInProgress) { - SendMessage("DD: Server started, watchdog active...", ChatMessageType.WatchdogInfo); + SendMessage("DD: Server started, watchdog active...", MessageType.WatchdogInfo); Service.WriteInfo("Watchdog started", EventID.DDWatchdogStarted); } else @@ -302,14 +302,14 @@ namespace TGServerService { ++retries; var sleep_time = (int)Math.Min(Math.Pow(2, retries), 3600); //max of one hour - SendMessage(String.Format("DD: Watchdog server startup failed! Retrying in {0} seconds...", sleep_time), ChatMessageType.WatchdogInfo); + SendMessage(String.Format("DD: Watchdog server startup failed! Retrying in {0} seconds...", sleep_time), MessageType.WatchdogInfo); Thread.Sleep(sleep_time * 1000); } else { retries = 0; var msg = "DD: DreamDaemon crashed! Watchdog rebooting DD..."; - SendMessage(msg, ChatMessageType.WatchdogInfo); + SendMessage(msg, MessageType.WatchdogInfo); Service.WriteWarning(msg, EventID.DDWatchdogRebootingServer); } } @@ -343,7 +343,7 @@ namespace TGServerService } catch (Exception e) { - SendMessage("DD: Watchdog thread crashed!", ChatMessageType.WatchdogInfo); + SendMessage("DD: Watchdog thread crashed!", MessageType.WatchdogInfo); Service.WriteError("Watch dog thread crashed: " + e.ToString(), EventID.DDWatchdogCrash); } finally @@ -356,7 +356,7 @@ namespace TGServerService if (!RestartInProgress) { if(!Properties.Settings.Default.ReattachToDD) - SendMessage("DD: Server stopped, watchdog exiting...", ChatMessageType.WatchdogInfo); + SendMessage("DD: Server stopped, watchdog exiting...", MessageType.WatchdogInfo); Service.WriteInfo("Watch dog exited", EventID.DDWatchdogExit); } else diff --git a/TGServerService/ServerInstance/Interop.cs b/TGServerService/ServerInstance/Interop.cs index a72c7a2ca4..430e46f285 100644 --- a/TGServerService/ServerInstance/Interop.cs +++ b/TGServerService/ServerInstance/Interop.cs @@ -81,13 +81,13 @@ namespace TGServerService switch (cmd) { case SRIRCBroadcast: - SendMessage("GAME: " + String.Join(" ", splits), ChatMessageType.GameInfo); + SendMessage("GAME: " + String.Join(" ", splits), MessageType.GameInfo); break; case SRKillProcess: KillMe(); break; case SRIRCAdminChannelMessage: - SendMessage("RELAY: " + String.Join(" ", splits), ChatMessageType.AdminInfo); + SendMessage("RELAY: " + String.Join(" ", splits), MessageType.AdminInfo); break; case SRWorldReboot: Service.WriteInfo("World Rebooted", EventID.WorldReboot); diff --git a/TGServerService/ServerInstance/Repository.cs b/TGServerService/ServerInstance/Repository.cs index 93829c13e2..47f87e6d2b 100644 --- a/TGServerService/ServerInstance/Repository.cs +++ b/TGServerService/ServerInstance/Repository.cs @@ -255,7 +255,7 @@ namespace TGServerService var BranchName = ts.b; try { - SendMessage(String.Format("REPO: {2} started: Cloning {0} branch of {1} ...", BranchName, RepoURL, Repository.IsValid(RepoPath) ? "Full reset" : "Setup"), ChatMessageType.DeveloperInfo); + SendMessage(String.Format("REPO: {2} started: Cloning {0} branch of {1} ...", BranchName, RepoURL, Repository.IsValid(RepoPath) ? "Full reset" : "Setup"), MessageType.DeveloperInfo); try { DisposeRepo(); @@ -286,7 +286,7 @@ namespace TGServerService InitialConfigureRepository(); - SendMessage("REPO: Clone complete!", ChatMessageType.DeveloperInfo); + SendMessage("REPO: Clone complete!", MessageType.DeveloperInfo); Service.WriteInfo("Repository {0}:{1} successfully cloned", EventID.RepoClone); } finally @@ -297,7 +297,7 @@ namespace TGServerService catch (Exception e) { - SendMessage("REPO: Setup failed!", ChatMessageType.DeveloperInfo); + SendMessage("REPO: Setup failed!", MessageType.DeveloperInfo); Service.WriteWarning(String.Format("Failed to clone {2}:{0}: {1}", BranchName, e.ToString(), RepoURL), EventID.RepoCloneFail); } finally @@ -509,7 +509,7 @@ namespace TGServerService var result = LoadRepo(); if (result != null) return result; - SendMessage("REPO: Checking out object: " + sha, ChatMessageType.DeveloperInfo); + SendMessage("REPO: Checking out object: " + sha, MessageType.DeveloperInfo); try { if (Repo.Branches[sha] == null) @@ -534,13 +534,13 @@ namespace TGServerService Commands.Checkout(Repo, sha, Opts); var res = ResetNoLock(null); UpdateSubmodules(); - SendMessage("REPO: Checkout complete!", ChatMessageType.DeveloperInfo); + SendMessage("REPO: Checkout complete!", MessageType.DeveloperInfo); Service.WriteInfo("Repo checked out " + sha, EventID.RepoCheckout); return res; } catch (Exception e) { - SendMessage("REPO: Checkout failed!", ChatMessageType.DeveloperInfo); + SendMessage("REPO: Checkout failed!", MessageType.DeveloperInfo); Service.WriteWarning(String.Format("Repo checkout of {0} failed: {1}", sha, e.ToString()), EventID.RepoCheckoutFail); return e.ToString(); } @@ -560,7 +560,7 @@ namespace TGServerService { case MergeStatus.Conflicts: ResetNoLock(null); - SendMessage("REPO: Merge conflicted, aborted.", ChatMessageType.DeveloperInfo); + SendMessage("REPO: Merge conflicted, aborted.", MessageType.DeveloperInfo); return "Merge conflict occurred."; case MergeStatus.UpToDate: return RepoErrorUpToDate; @@ -594,7 +594,7 @@ namespace TGServerService if (!successOnUpToDate && Repo.Head.Tip.Sha == originBranch.Tip.Sha) return RepoErrorUpToDate; - SendMessage(String.Format("REPO: Updating origin branch...({0})", reset ? "Hard Reset" : "Merge"), ChatMessageType.DeveloperInfo); + SendMessage(String.Format("REPO: Updating origin branch...({0})", reset ? "Hard Reset" : "Merge"), MessageType.DeveloperInfo); if (reset) { @@ -615,7 +615,7 @@ namespace TGServerService } catch (Exception E) { - SendMessage("REPO: Update failed!", ChatMessageType.DeveloperInfo); + SendMessage("REPO: Update failed!", MessageType.DeveloperInfo); Service.WriteWarning(String.Format("Repo{0} update failed", reset ? " hard" : ""), reset ? EventID.RepoHardUpdateFail : EventID.RepoMergeUpdateFail); return E.ToString(); } @@ -647,7 +647,7 @@ namespace TGServerService } Repo.Submodules.Update(I.Name, suo); var msg = String.Format("I had to reclone submodule {0}. If this is happening a lot find a better hack or fix https://github.com/libgit2/libgit2/issues/3820!", I.Name); - SendMessage(String.Format("REPO: {0}", msg), ChatMessageType.DeveloperInfo); + SendMessage(String.Format("REPO: {0}", msg), MessageType.DeveloperInfo); Service.WriteWarning(msg, EventID.SubmoduleReclone); } } @@ -718,7 +718,7 @@ namespace TGServerService var res = LoadRepo() ?? ResetNoLock(trackedBranch ? (Repo.Head.TrackedBranch ?? Repo.Head) : Repo.Head); if (res == null) { - SendMessage(String.Format("REPO: Hard reset to {0}branch", trackedBranch ? "tracked " : ""), ChatMessageType.DeveloperInfo); + SendMessage(String.Format("REPO: Hard reset to {0}branch", trackedBranch ? "tracked " : ""), MessageType.DeveloperInfo); if (trackedBranch) DeletePRList(); Service.WriteInfo(String.Format("Repo branch reset{0}", trackedBranch ? " to tracked branch" : ""), trackedBranch ? EventID.RepoResetTracked : EventID.RepoReset); @@ -780,7 +780,7 @@ namespace TGServerService var result = LoadRepo(); if (result != null) return result; - SendMessage(String.Format("REPO: {1}erging PR #{0}...", PRNumber, impliedUpdate ? "Test m" : "M"), ChatMessageType.DeveloperInfo); + SendMessage(String.Format("REPO: {1}erging PR #{0}...", PRNumber, impliedUpdate ? "Test m" : "M"), MessageType.DeveloperInfo); result = ResetNoLock(null); if (result != null) return result; @@ -813,7 +813,7 @@ namespace TGServerService branch = Repo.Branches[LocalBranchName]; if (branch == null) { - SendMessage("REPO: PR could not be fetched. Does it exist?", ChatMessageType.DeveloperInfo); + SendMessage("REPO: PR could not be fetched. Does it exist?", MessageType.DeveloperInfo); return String.Format("PR #{0} could not be fetched. Does it exist?", PRNumber); } @@ -873,7 +873,7 @@ namespace TGServerService } catch (Exception E) { - SendMessage("REPO: PR merge failed!", ChatMessageType.DeveloperInfo); + SendMessage("REPO: PR merge failed!", MessageType.DeveloperInfo); Service.WriteWarning(String.Format("Failed to merge pull request #{0}: {1}", PRNumber, E.ToString()), EventID.RepoPRMergeFail); return E.ToString(); } diff --git a/TGServerService/ServerInstance/ServerInstance.cs b/TGServerService/ServerInstance/ServerInstance.cs index ef21c8ca1a..df1703d18c 100644 --- a/TGServerService/ServerInstance/ServerInstance.cs +++ b/TGServerService/ServerInstance/ServerInstance.cs @@ -47,7 +47,7 @@ namespace TGServerService public void PrepareForUpdate() { Properties.Settings.Default.ReattachToDD = true; - SendMessage("SERVICE: Update started...", ChatMessageType.DeveloperInfo); + SendMessage("SERVICE: Update started...", MessageType.DeveloperInfo); } //mostly generated code with a call to RunDisposals() diff --git a/TGServerService/TGServerService.csproj b/TGServerService/TGServerService.csproj index d5ece5b6f4..e35856b188 100644 --- a/TGServerService/TGServerService.csproj +++ b/TGServerService/TGServerService.csproj @@ -82,7 +82,7 @@ - +