2 using System.Collections;
5 using System.Threading;
6 using TechBot.IRCLibrary;
8 namespace TechBot.Library
10 public class TechBotService
12 private IServiceOutput serviceOutput;
13 private string chmPath;
14 private string mainChm;
15 private string ntstatusXml;
16 private string winerrorXml;
17 private string hresultXml;
19 private string svnCommand;
20 private string bugUrl, WineBugUrl, SambaBugUrl;
21 private ArrayList commands = new ArrayList();
23 public TechBotService(IServiceOutput serviceOutput,
35 this.serviceOutput = serviceOutput;
36 this.chmPath = chmPath;
37 this.mainChm = mainChm;
38 this.ntstatusXml = ntstatusXml;
39 this.winerrorXml = winerrorXml;
40 this.hresultXml = hresultXml;
42 this.svnCommand = svnCommand;
44 this.WineBugUrl = WineBugUrl;
45 this.SambaBugUrl = SambaBugUrl;
50 commands.Add(new HelpCommand(serviceOutput,
52 /*commands.Add(new ApiCommand(serviceOutput,
55 commands.Add(new NtStatusCommand(serviceOutput,
57 commands.Add(new WinerrorCommand(serviceOutput,
59 commands.Add(new HresultCommand(serviceOutput,
61 commands.Add(new ErrorCommand(serviceOutput,
65 commands.Add(new WmCommand(serviceOutput,
67 commands.Add(new SvnCommand(serviceOutput,
69 commands.Add(new BugCommand(serviceOutput,
75 public void InjectMessage(MessageContext context,
78 if (message.StartsWith("!"))
79 ParseCommandMessage(context,
83 private bool IsCommandMessage(string message)
85 return message.StartsWith("!");
88 public void ParseCommandMessage(MessageContext context,
91 if (!IsCommandMessage(message))
94 message = message.Substring(1).Trim();
95 int index = message.IndexOf(' ');
97 string parameters = "";
100 commandName = message.Substring(0, index).Trim();
101 parameters = message.Substring(index).Trim();
104 commandName = message.Trim();
106 foreach (ICommand command in commands)
108 if (command.CanHandle(commandName))
110 command.Handle(context,
111 commandName, parameters);