2005-01-15 19:27:25 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
2007-12-10 19:08:13 +00:00
|
|
|
using System.Collections.Generic;
|
2005-01-15 19:27:25 +00:00
|
|
|
using System.IO;
|
|
|
|
using System.Data;
|
|
|
|
using System.Threading;
|
|
|
|
using TechBot.IRCLibrary;
|
|
|
|
|
|
|
|
namespace TechBot.Library
|
|
|
|
{
|
|
|
|
public class TechBotService
|
|
|
|
{
|
|
|
|
private IServiceOutput serviceOutput;
|
|
|
|
private string chmPath;
|
|
|
|
private string mainChm;
|
|
|
|
private string ntstatusXml;
|
|
|
|
private string winerrorXml;
|
|
|
|
private string hresultXml;
|
2005-12-14 17:34:00 +00:00
|
|
|
private string wmXml;
|
2005-01-15 19:27:25 +00:00
|
|
|
private string svnCommand;
|
2006-01-05 21:46:24 +00:00
|
|
|
private string bugUrl, WineBugUrl, SambaBugUrl;
|
2007-12-10 19:08:13 +00:00
|
|
|
private List<Command> commands = new List<Command>();
|
2005-01-15 19:27:25 +00:00
|
|
|
|
|
|
|
public TechBotService(IServiceOutput serviceOutput,
|
|
|
|
string chmPath,
|
2007-12-10 19:08:13 +00:00
|
|
|
string mainChm)
|
|
|
|
//string ntstatusXml,
|
|
|
|
//string winerrorXml,
|
|
|
|
//string hresultXml,
|
|
|
|
//string wmXml,
|
|
|
|
//string svnCommand,
|
|
|
|
//string bugUrl,
|
|
|
|
//string WineBugUrl,
|
|
|
|
//string SambaBugUrl)
|
2005-01-15 19:27:25 +00:00
|
|
|
{
|
|
|
|
this.serviceOutput = serviceOutput;
|
|
|
|
this.chmPath = chmPath;
|
|
|
|
this.mainChm = mainChm;
|
|
|
|
this.ntstatusXml = ntstatusXml;
|
|
|
|
this.winerrorXml = winerrorXml;
|
|
|
|
this.hresultXml = hresultXml;
|
2005-12-14 17:34:00 +00:00
|
|
|
this.wmXml = wmXml;
|
2005-01-15 19:27:25 +00:00
|
|
|
this.svnCommand = svnCommand;
|
2005-12-14 18:13:05 +00:00
|
|
|
this.bugUrl = bugUrl;
|
2006-01-05 21:46:24 +00:00
|
|
|
this.WineBugUrl = WineBugUrl;
|
|
|
|
this.SambaBugUrl = SambaBugUrl;
|
2005-01-15 19:27:25 +00:00
|
|
|
}
|
2007-12-10 19:08:13 +00:00
|
|
|
|
|
|
|
public void Run()
|
|
|
|
{
|
|
|
|
commands.Add(new HelpCommand(this));
|
|
|
|
/*commands.Add(new ApiCommand(serviceOutput,
|
|
|
|
chmPath,
|
|
|
|
mainChm));*/
|
|
|
|
commands.Add(new NtStatusCommand(this));
|
|
|
|
commands.Add(new WinerrorCommand(this));
|
|
|
|
commands.Add(new HResultCommand(this));
|
|
|
|
commands.Add(new ErrorCommand(this));
|
|
|
|
commands.Add(new WMCommand(this));
|
|
|
|
commands.Add(new SvnCommand(this));
|
|
|
|
commands.Add(new ReactOSBugUrl(this));
|
|
|
|
commands.Add(new SambaBugUrl(this));
|
|
|
|
commands.Add(new WineBugUrl(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
public IServiceOutput ServiceOutput
|
|
|
|
{
|
|
|
|
get { return serviceOutput; }
|
|
|
|
}
|
|
|
|
|
|
|
|
public IList<Command> Commands
|
|
|
|
{
|
|
|
|
get { return commands; }
|
|
|
|
}
|
2005-01-15 19:27:25 +00:00
|
|
|
|
2005-02-16 21:07:55 +00:00
|
|
|
public void InjectMessage(MessageContext context,
|
|
|
|
string message)
|
2005-01-15 19:27:25 +00:00
|
|
|
{
|
|
|
|
if (message.StartsWith("!"))
|
2005-02-16 21:07:55 +00:00
|
|
|
ParseCommandMessage(context,
|
|
|
|
message);
|
2005-01-15 19:27:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private bool IsCommandMessage(string message)
|
|
|
|
{
|
|
|
|
return message.StartsWith("!");
|
|
|
|
}
|
|
|
|
|
2005-02-16 21:07:55 +00:00
|
|
|
public void ParseCommandMessage(MessageContext context,
|
|
|
|
string message)
|
2005-01-15 19:27:25 +00:00
|
|
|
{
|
|
|
|
if (!IsCommandMessage(message))
|
|
|
|
return;
|
|
|
|
|
|
|
|
message = message.Substring(1).Trim();
|
|
|
|
int index = message.IndexOf(' ');
|
|
|
|
string commandName;
|
2007-12-10 19:08:13 +00:00
|
|
|
string commandParams = "";
|
2005-01-15 19:27:25 +00:00
|
|
|
if (index != -1)
|
|
|
|
{
|
|
|
|
commandName = message.Substring(0, index).Trim();
|
2007-12-10 19:08:13 +00:00
|
|
|
commandParams = message.Substring(index).Trim();
|
2005-01-15 19:27:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
commandName = message.Trim();
|
|
|
|
|
2007-12-10 19:08:13 +00:00
|
|
|
foreach (Command command in commands)
|
2005-01-15 19:27:25 +00:00
|
|
|
{
|
2007-12-10 19:08:13 +00:00
|
|
|
foreach (string cmd in command.AvailableCommands)
|
|
|
|
{
|
|
|
|
if (cmd == commandName)
|
|
|
|
{
|
|
|
|
command.Handle(context,
|
|
|
|
commandName,
|
|
|
|
commandParams);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2005-01-15 19:27:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|