using System.IO;\r
using System.Data;\r
using System.Threading;\r
+\r
using TechBot.IRCLibrary;\r
\r
namespace TechBot.Library\r
{\r
- public class TechBotService\r
+ public abstract class TechBotService\r
{\r
- private IServiceOutput serviceOutput;\r
+ protected IServiceOutput serviceOutput;\r
private string chmPath;\r
private string mainChm;\r
- private string ntstatusXml;\r
- private string winerrorXml;\r
- private string hresultXml;\r
- private string wmXml;\r
- private string svnCommand;\r
- private string bugUrl, WineBugUrl, SambaBugUrl;\r
- private List<Command> commands = new List<Command>();\r
\r
public TechBotService(IServiceOutput serviceOutput,\r
string chmPath,\r
string mainChm)\r
- //string ntstatusXml,\r
- //string winerrorXml,\r
- //string hresultXml,\r
- //string wmXml,\r
- //string svnCommand,\r
- //string bugUrl,\r
- //string WineBugUrl,\r
- //string SambaBugUrl)\r
{\r
this.serviceOutput = serviceOutput;\r
this.chmPath = chmPath;\r
this.mainChm = mainChm;\r
- this.ntstatusXml = ntstatusXml;\r
- this.winerrorXml = winerrorXml;\r
- this.hresultXml = hresultXml;\r
- this.wmXml = wmXml;\r
- this.svnCommand = svnCommand;\r
- this.bugUrl = bugUrl;\r
- this.WineBugUrl = WineBugUrl;\r
- this.SambaBugUrl = SambaBugUrl;\r
}\r
\r
- public void Run()\r
+ public virtual void Run()\r
{\r
- commands.Add(new HelpCommand(this));\r
- /*commands.Add(new ApiCommand(serviceOutput,\r
- chmPath,\r
- mainChm));*/\r
- commands.Add(new NtStatusCommand(this));\r
- commands.Add(new WinerrorCommand(this));\r
- commands.Add(new HResultCommand(this));\r
- commands.Add(new ErrorCommand(this));\r
- commands.Add(new WMCommand(this));\r
- commands.Add(new SvnCommand(this));\r
- commands.Add(new ReactOSBugUrl(this));\r
- commands.Add(new SambaBugUrl(this));\r
- commands.Add(new WineBugUrl(this));\r
+ CommandFactory.LoadPlugins();\r
}\r
\r
public IServiceOutput ServiceOutput\r
get { return serviceOutput; }\r
}\r
\r
- public IList<Command> Commands\r
+ public CommandBuilderCollection Commands\r
{\r
- get { return commands; }\r
+ get { return CommandFactory.Commands; }\r
+ }\r
+\r
+ public void InjectMessage(MessageContext context, string message)\r
+ {\r
+ ParseCommandMessage(context,\r
+ message);\r
}\r
- \r
- public void InjectMessage(MessageContext context,\r
- string message)\r
- {\r
- if (message.StartsWith("!"))\r
- ParseCommandMessage(context,\r
- message);\r
- }\r
\r
private bool IsCommandMessage(string message)\r
{\r
else\r
commandName = message.Trim();\r
\r
- foreach (Command command in commands)\r
- {\r
- foreach (string cmd in command.AvailableCommands)\r
+ foreach (CommandBuilder command in Commands)\r
+ {\r
+ if (command.Name == commandName)\r
{\r
- if (cmd == commandName)\r
- {\r
- command.Handle(context,\r
- commandName, \r
- commandParams);\r
- return;\r
- }\r
+ //Create a new instance of the required command type\r
+ Command cmd = command.CreateCommand();\r
+\r
+ cmd.TechBot = this;\r
+ cmd.Context = context;\r
+ cmd.ParseParameters(message);\r
+ cmd.ExecuteCommand();\r
+\r
+ return;\r
}\r
- }\r
+ }\r
}\r
}\r
}\r