Massive sanity reorganization of project structure

Overall:
- Removed all 'TG' prefixes on classes and enums
Service:
- TGStationServer => ServerInstance
- TGServerService => Service
- Moved all ServerInstance partial classes to a subfolder
- Moved ChatProvider classes, delegate, and interface to a namespace
- Moved EventID and ChatMessageType to their own .cs files
- Moved SanitizeTopicString to Program
- ServerService.cs => Service.cs
- Fixed ProjectInstaller being in it's own namespace instead of
TGServerService
Interface:
- Moved ExitCode enum to Command class
- Moved all components to a namespace
- Moved all component enums to Enumerations.cs
- DDInteropCallHolder => DreamDaemonBridge
- Move PullRequestInfo and DreamDaemonBridge to their own .cs files
- Changes the type of ChannelFactory cache from Dictionary<Type,
ChannelFactory> to IDictionary<Type, ChannelFactory>
This commit is contained in:
Cyberboss
2017-10-20 14:00:09 -04:00
parent 7b8fa03f5d
commit 3137be7abb
58 changed files with 3274 additions and 3212 deletions
+29 -28
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using TGServiceInterface;
using TGServiceInterface.Components;
namespace TGCommandLine
{
@@ -9,7 +10,7 @@ namespace TGCommandLine
public IRCCommand()
{
Keyword = "irc";
Children = new Command[] { new IRCNickCommand(), new IRCAuthCommand(), new IRCDisableAuthCommand(), new IRCServerCommand(), new ChatJoinCommand(TGChatProvider.IRC), new ChatPartCommand(TGChatProvider.IRC), new ChatListAdminsCommand(TGChatProvider.IRC), new ChatReconnectCommand(TGChatProvider.IRC), new ChatAddminCommand(TGChatProvider.IRC), new ChatDeadminCommand(TGChatProvider.IRC), new ChatEnableCommand(TGChatProvider.IRC), new ChatDisableCommand(TGChatProvider.IRC), new ChatStatusCommand(TGChatProvider.IRC), new IRCAuthModeCommand(), new IRCAuthLevelCommand() };
Children = new Command[] { new IRCNickCommand(), new IRCAuthCommand(), new IRCDisableAuthCommand(), new IRCServerCommand(), new ChatJoinCommand(ChatProvider.IRC), new ChatPartCommand(ChatProvider.IRC), new ChatListAdminsCommand(ChatProvider.IRC), new ChatReconnectCommand(ChatProvider.IRC), new ChatAddminCommand(ChatProvider.IRC), new ChatDeadminCommand(ChatProvider.IRC), new ChatEnableCommand(ChatProvider.IRC), new ChatDisableCommand(ChatProvider.IRC), new ChatStatusCommand(ChatProvider.IRC), new IRCAuthModeCommand(), new IRCAuthLevelCommand() };
}
public override string GetHelpText()
{
@@ -21,7 +22,7 @@ namespace TGCommandLine
public DiscordCommand()
{
Keyword = "discord";
Children = new Command[] { new DiscordSetTokenCommand(), new ChatJoinCommand(TGChatProvider.Discord), new ChatPartCommand(TGChatProvider.Discord), new ChatListAdminsCommand(TGChatProvider.Discord), new ChatReconnectCommand(TGChatProvider.Discord), new ChatAddminCommand(TGChatProvider.Discord), new ChatDeadminCommand(TGChatProvider.Discord), new ChatEnableCommand(TGChatProvider.Discord), new ChatDisableCommand(TGChatProvider.Discord), new ChatStatusCommand(TGChatProvider.Discord) , new DiscordAuthModeCommand() };
Children = new Command[] { new DiscordSetTokenCommand(), new ChatJoinCommand(ChatProvider.Discord), new ChatPartCommand(ChatProvider.Discord), new ChatListAdminsCommand(ChatProvider.Discord), new ChatReconnectCommand(ChatProvider.Discord), new ChatAddminCommand(ChatProvider.Discord), new ChatDeadminCommand(ChatProvider.Discord), new ChatEnableCommand(ChatProvider.Discord), new ChatDisableCommand(ChatProvider.Discord), new ChatStatusCommand(ChatProvider.Discord) , new DiscordAuthModeCommand() };
}
public override string GetHelpText()
{
@@ -48,7 +49,7 @@ namespace TGCommandLine
protected override ExitCode Run(IList<string> parameters)
{
var Chat = Server.GetComponent<ITGChat>();
Chat.SetProviderInfo(new TGIRCSetupInfo(Chat.ProviderInfos()[(int)TGChatProvider.IRC])
Chat.SetProviderInfo(new IRCSetupInfo(Chat.ProviderInfos()[(int)ChatProvider.IRC])
{
Nickname = parameters[0],
});
@@ -59,7 +60,7 @@ namespace TGCommandLine
class ChatJoinCommand : Command
{
readonly int providerIndex;
public ChatJoinCommand(TGChatProvider pI)
public ChatJoinCommand(ChatProvider pI)
{
Keyword = "join";
RequiredParameters = 2;
@@ -138,7 +139,7 @@ namespace TGCommandLine
class ChatPartCommand : Command
{
readonly int providerIndex;
public ChatPartCommand(TGChatProvider pI)
public ChatPartCommand(ChatProvider pI)
{
Keyword = "part";
RequiredParameters = 2;
@@ -178,7 +179,7 @@ namespace TGCommandLine
return ExitCode.BadCommand;
}
var lowerParam = parameters[0].ToLower();
if ((TGChatProvider)providerIndex == TGChatProvider.IRC && lowerParam[0] != '#')
if ((ChatProvider)providerIndex == ChatProvider.IRC && lowerParam[0] != '#')
lowerParam = "#" + lowerParam;
channels.Remove(lowerParam);
switch (parameters[1].ToLower())
@@ -208,7 +209,7 @@ namespace TGCommandLine
class ChatListAdminsCommand : Command
{
readonly int providerIndex;
public ChatListAdminsCommand(TGChatProvider pI)
public ChatListAdminsCommand(ChatProvider pI)
{
Keyword = "list-admins";
providerIndex = (int)pI;
@@ -223,15 +224,15 @@ namespace TGCommandLine
{
var info = Server.GetComponent<ITGChat>().ProviderInfos()[providerIndex];
string authType;
switch ((TGChatProvider)providerIndex)
switch ((ChatProvider)providerIndex)
{
case TGChatProvider.IRC:
case ChatProvider.IRC:
if (info.AdminsAreSpecial)
authType = "Mode:";
else
authType = "Nicknames:";
break;
case TGChatProvider.Discord:
case ChatProvider.Discord:
if (info.AdminsAreSpecial)
authType = "Role IDs:";
else
@@ -242,8 +243,8 @@ namespace TGCommandLine
return ExitCode.ServerError;
}
OutputProc("Authorized " + authType);
if (info.AdminsAreSpecial && (TGChatProvider)providerIndex == TGChatProvider.IRC)
switch(new TGIRCSetupInfo(info).AuthLevel)
if (info.AdminsAreSpecial && (ChatProvider)providerIndex == ChatProvider.IRC)
switch(new IRCSetupInfo(info).AuthLevel)
{
case IRCMode.Voice:
OutputProc("+");
@@ -266,8 +267,8 @@ namespace TGCommandLine
}
class ChatReconnectCommand : Command
{
readonly TGChatProvider providerIndex;
public ChatReconnectCommand(TGChatProvider pI)
readonly ChatProvider providerIndex;
public ChatReconnectCommand(ChatProvider pI)
{
Keyword = "reconnect";
providerIndex = pI;
@@ -292,7 +293,7 @@ namespace TGCommandLine
class ChatAddminCommand : Command
{
readonly int providerIndex;
public ChatAddminCommand(TGChatProvider pI)
public ChatAddminCommand(ChatProvider pI)
{
Keyword = "addmin";
RequiredParameters = 1;
@@ -313,7 +314,7 @@ namespace TGCommandLine
var info = IRC.ProviderInfos()[providerIndex];
var newmin = parameters[0].ToLower();
if (info.AdminsAreSpecial && (TGChatProvider)providerIndex == TGChatProvider.IRC)
if (info.AdminsAreSpecial && (ChatProvider)providerIndex == ChatProvider.IRC)
{
OutputProc("Invalid auth mode for this command!");
return ExitCode.BadCommand;
@@ -355,7 +356,7 @@ namespace TGCommandLine
protected override ExitCode Run(IList<string> parameters)
{
var IRC = Server.GetComponent<ITGChat>();
var info = IRC.ProviderInfos()[(int)TGChatProvider.IRC];
var info = IRC.ProviderInfos()[(int)ChatProvider.IRC];
var lowerparam = parameters[0].ToLower();
if (lowerparam == "channel-mode")
info.AdminsAreSpecial = true;
@@ -394,7 +395,7 @@ namespace TGCommandLine
protected override ExitCode Run(IList<string> parameters)
{
var IRC = Server.GetComponent<ITGChat>();
var info = IRC.ProviderInfos()[(int)TGChatProvider.Discord];
var info = IRC.ProviderInfos()[(int)ChatProvider.Discord];
var lowerparam = parameters[0].ToLower();
if (lowerparam == "role-id")
info.AdminsAreSpecial = true;
@@ -433,7 +434,7 @@ namespace TGCommandLine
protected override ExitCode Run(IList<string> parameters)
{
var IRC = Server.GetComponent<ITGChat>();
var info = new TGIRCSetupInfo(IRC.ProviderInfos()[(int)TGChatProvider.IRC]);
var info = new IRCSetupInfo(IRC.ProviderInfos()[(int)ChatProvider.IRC]);
switch (parameters[0])
{
case "+":
@@ -465,7 +466,7 @@ namespace TGCommandLine
class ChatDeadminCommand : Command
{
readonly int providerIndex;
public ChatDeadminCommand(TGChatProvider pI)
public ChatDeadminCommand(ChatProvider pI)
{
Keyword = "deadmin";
RequiredParameters = 1;
@@ -485,7 +486,7 @@ namespace TGCommandLine
var info = IRC.ProviderInfos()[providerIndex];
var newmin = parameters[0].ToLower();
if (info.AdminsAreSpecial && (TGChatProvider)providerIndex == TGChatProvider.IRC)
if (info.AdminsAreSpecial && (ChatProvider)providerIndex == ChatProvider.IRC)
{
OutputProc("Invalid auth mode for this command!");
return ExitCode.BadCommand;
@@ -529,7 +530,7 @@ namespace TGCommandLine
protected override ExitCode Run(IList<string> parameters)
{
var IRC = Server.GetComponent<ITGChat>();
IRC.SetProviderInfo(new TGIRCSetupInfo(IRC.ProviderInfos()[(int)TGChatProvider.IRC])
IRC.SetProviderInfo(new IRCSetupInfo(IRC.ProviderInfos()[(int)ChatProvider.IRC])
{
AuthTarget = parameters[0],
AuthMessage = parameters[1]
@@ -551,7 +552,7 @@ namespace TGCommandLine
protected override ExitCode Run(IList<string> parameters)
{
var IRC = Server.GetComponent<ITGChat>();
IRC.SetProviderInfo(new TGIRCSetupInfo(IRC.ProviderInfos()[(int)TGChatProvider.IRC])
IRC.SetProviderInfo(new IRCSetupInfo(IRC.ProviderInfos()[(int)ChatProvider.IRC])
{
AuthTarget = null,
AuthMessage = null,
@@ -563,7 +564,7 @@ namespace TGCommandLine
class ChatStatusCommand : Command
{
readonly int providerIndex;
public ChatStatusCommand(TGChatProvider pI)
public ChatStatusCommand(ChatProvider pI)
{
Keyword = "status";
providerIndex = (int)pI;
@@ -596,7 +597,7 @@ namespace TGCommandLine
class ChatEnableCommand : Command
{
readonly int providerIndex;
public ChatEnableCommand(TGChatProvider pI)
public ChatEnableCommand(ChatProvider pI)
{
Keyword = "enable";
providerIndex = (int)pI;
@@ -624,7 +625,7 @@ namespace TGCommandLine
class ChatDisableCommand : Command
{
readonly int providerIndex;
public ChatDisableCommand(TGChatProvider pI)
public ChatDisableCommand(ChatProvider pI)
{
Keyword = "disable";
providerIndex = (int)pI;
@@ -675,7 +676,7 @@ namespace TGCommandLine
return ExitCode.BadCommand;
}
var Chat = Server.GetComponent<ITGChat>();
var PI = new TGIRCSetupInfo(Chat.ProviderInfos()[(int)TGChatProvider.IRC])
var PI = new IRCSetupInfo(Chat.ProviderInfos()[(int)ChatProvider.IRC])
{
URL = splits[0]
};
@@ -713,7 +714,7 @@ namespace TGCommandLine
protected override ExitCode Run(IList<string> parameters)
{
var Chat = Server.GetComponent<ITGChat>();
var res = Chat.SetProviderInfo(new TGDiscordSetupInfo(Chat.ProviderInfos()[(int)TGChatProvider.Discord]) { BotToken = parameters[0] });
var res = Chat.SetProviderInfo(new DiscordSetupInfo(Chat.ProviderInfos()[(int)ChatProvider.Discord]) { BotToken = parameters[0] });
OutputProc(res ?? "Success");
return res == null ? ExitCode.Normal : ExitCode.ServerError;
}