mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
* refactor the code to make it more OOP and extensible
* remove old outdated SD project files * make it use some .NET 2.0 features as generic collections and settings svn path=/trunk/; revision=31130
This commit is contained in:
parent
588f8770cd
commit
82b5e2eb8b
31 changed files with 687 additions and 491 deletions
|
@ -8,11 +8,6 @@
|
|||
<add key="IRCBotPassword" value="MyPassword" />
|
||||
<add key="ChmPath" value="C:\IRC\TechBot\CHM" />
|
||||
<add key="MainChm" value="kmarch.chm" />
|
||||
<add key="NtstatusXml" value="ntstatus.xml" />
|
||||
<add key="WinerrorXml" value="winerror.xml" />
|
||||
<add key="HresultXml" value="hresult.xml" />
|
||||
<add key="WmXml" value="wm.xml" />
|
||||
<add key="SvnCommand" value="svn co svn://svn.reactos.org/trunk/reactos" />
|
||||
<add key="BugUrl" value="http://www.reactos.org/bugzilla/show_bug.cgi?id={0}" />
|
||||
<add key="WineBugUrl" value="http://bugs.winehq.org/show_bug.cgi?id={0}" />
|
||||
<add key="SambaBugUrl" value="https://bugzilla.samba.org/show_bug.cgi?id={0}" />
|
||||
|
|
|
@ -217,11 +217,11 @@ namespace TechBot.Console
|
|||
IRCBotPassword,
|
||||
ChmPath,
|
||||
MainChm,
|
||||
NtstatusXml,
|
||||
WinerrorXml,
|
||||
HresultXml,
|
||||
WmXml,
|
||||
SvnCommand,
|
||||
//NtstatusXml,
|
||||
//WinerrorXml,
|
||||
//HresultXml,
|
||||
//WmXml,
|
||||
//SvnCommand,
|
||||
BugUrl,
|
||||
WineBugUrl,
|
||||
SambaBugUrl);
|
||||
|
@ -239,15 +239,15 @@ namespace TechBot.Console
|
|||
System.Console.WriteLine("TechBot running console service...");
|
||||
TechBotService service = new TechBotService(new ConsoleServiceOutput(),
|
||||
ChmPath,
|
||||
MainChm,
|
||||
NtstatusXml,
|
||||
WinerrorXml,
|
||||
HresultXml,
|
||||
WmXml,
|
||||
SvnCommand,
|
||||
BugUrl,
|
||||
WineBugUrl,
|
||||
SambaBugUrl);
|
||||
MainChm);
|
||||
//NtstatusXml,
|
||||
//WinerrorXml,
|
||||
//HresultXml,
|
||||
//WmXml,
|
||||
//SvnCommand,
|
||||
//BugUrl,
|
||||
//WineBugUrl,
|
||||
//SambaBugUrl);
|
||||
service.Run();
|
||||
while (true)
|
||||
{
|
||||
|
|
|
@ -53,6 +53,9 @@
|
|||
<Name>TechBot.Library</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -7,22 +7,17 @@ using HtmlHelp.ChmDecoding;
|
|||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class ApiCommand : BaseCommand, ICommand
|
||||
public class ApiCommand : Command
|
||||
{
|
||||
private const bool IsVerbose = false;
|
||||
|
||||
private HtmlHelpSystem chm;
|
||||
private IServiceOutput serviceOutput;
|
||||
private string chmPath;
|
||||
private string mainChm;
|
||||
|
||||
public ApiCommand(IServiceOutput serviceOutput,
|
||||
string chmPath,
|
||||
string mainChm)
|
||||
|
||||
public ApiCommand(TechBotService techBot)
|
||||
: base(techBot)
|
||||
{
|
||||
this.serviceOutput = serviceOutput;
|
||||
this.chmPath = chmPath;
|
||||
this.mainChm = mainChm;
|
||||
Run();
|
||||
}
|
||||
|
||||
|
@ -30,7 +25,7 @@ namespace TechBot.Library
|
|||
string message)
|
||||
{
|
||||
if (IsVerbose)
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
message);
|
||||
}
|
||||
|
||||
|
@ -65,14 +60,21 @@ namespace TechBot.Library
|
|||
Console.WriteLine(String.Format("Loaded {0} CHMs",
|
||||
chm.FileList.Length));
|
||||
}
|
||||
|
||||
|
||||
public override string[] AvailableCommands
|
||||
{
|
||||
get { return new string[] { "api" }; }
|
||||
}
|
||||
|
||||
/*
|
||||
public bool CanHandle(string commandName)
|
||||
{
|
||||
return CanHandle(commandName,
|
||||
new string[] { "api" });
|
||||
}
|
||||
*/
|
||||
|
||||
public void Handle(MessageContext context,
|
||||
public override void Handle(MessageContext context,
|
||||
string commandName,
|
||||
string parameters)
|
||||
{
|
||||
|
@ -82,8 +84,8 @@ namespace TechBot.Library
|
|||
Search(context,
|
||||
parameters);
|
||||
}
|
||||
|
||||
public string Help()
|
||||
|
||||
public override string Help()
|
||||
{
|
||||
return "!api <apiname>";
|
||||
}
|
||||
|
@ -177,7 +179,7 @@ namespace TechBot.Library
|
|||
if (prototype == null || prototype.Trim().Equals(String.Empty))
|
||||
return false;
|
||||
string formattedPrototype = FormatPrototype(prototype);
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
formattedPrototype);
|
||||
return true;
|
||||
}
|
||||
|
@ -203,7 +205,7 @@ namespace TechBot.Library
|
|||
if (prototype == null || prototype.Trim().Equals(String.Empty))
|
||||
continue;
|
||||
string formattedPrototype = FormatPrototype(prototype);
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
formattedPrototype);
|
||||
return true;
|
||||
}
|
||||
|
@ -214,14 +216,14 @@ namespace TechBot.Library
|
|||
private void DisplayNoResult(MessageContext context,
|
||||
string keyword)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("I don't know about keyword {0}",
|
||||
keyword));
|
||||
}
|
||||
|
||||
private void DisplayNoKeyword(MessageContext context)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
"Please give me a keyword.");
|
||||
}
|
||||
|
||||
|
|
|
@ -2,70 +2,49 @@ using System;
|
|||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class BugCommand : BaseCommand, ICommand
|
||||
public abstract class BugCommand : Command//, ICommand
|
||||
{
|
||||
private IServiceOutput serviceOutput;
|
||||
private string RosBugUrl;
|
||||
private string WineBugUrl;
|
||||
private string SambaBugUrl;
|
||||
|
||||
public BugCommand(IServiceOutput serviceOutput,
|
||||
string RosBugUrl,
|
||||
string WineBugUrl,
|
||||
string SambaBugUrl)
|
||||
public BugCommand(TechBotService techBot) : base (techBot)
|
||||
{
|
||||
this.serviceOutput = serviceOutput;
|
||||
this.RosBugUrl = RosBugUrl;
|
||||
this.WineBugUrl = WineBugUrl;
|
||||
this.SambaBugUrl = SambaBugUrl;
|
||||
}
|
||||
|
||||
public bool CanHandle(string commandName)
|
||||
{
|
||||
return CanHandle(commandName,
|
||||
new string[] { "bug" });
|
||||
}
|
||||
|
||||
public void Handle(MessageContext context,
|
||||
string commandName,
|
||||
string parameters)
|
||||
{
|
||||
string bugText = parameters;
|
||||
if (bugText.Equals(String.Empty))
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
"Please provide a valid bug number.");
|
||||
return;
|
||||
}
|
||||
public override void Handle(MessageContext context,
|
||||
string commandName,
|
||||
string parameters)
|
||||
{
|
||||
string bugText = parameters;
|
||||
if (bugText.Equals(String.Empty))
|
||||
{
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
"Please provide a valid bug number.");
|
||||
return;
|
||||
}
|
||||
|
||||
NumberParser np = new NumberParser();
|
||||
long bug = np.Parse(bugText);
|
||||
if (np.Error)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
String.Format("{0} is not a valid bug number.",
|
||||
bugText));
|
||||
return;
|
||||
}
|
||||
|
||||
string bugUrl = this.RosBugUrl;
|
||||
NumberParser np = new NumberParser();
|
||||
long bug = np.Parse(bugText);
|
||||
if (np.Error)
|
||||
{
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("{0} is not a valid bug number.",
|
||||
bugText));
|
||||
return;
|
||||
}
|
||||
|
||||
if (context is ChannelMessageContext)
|
||||
{
|
||||
ChannelMessageContext channelContext = context as ChannelMessageContext;
|
||||
if (channelContext.Channel.Name == "winehackers")
|
||||
bugUrl = this.WineBugUrl;
|
||||
else if (channelContext.Channel.Name == "samba-technical")
|
||||
bugUrl = this.SambaBugUrl;
|
||||
}
|
||||
|
||||
serviceOutput.WriteLine(context,
|
||||
String.Format(bugUrl, bug));
|
||||
}
|
||||
|
||||
public string Help()
|
||||
{
|
||||
return "!bug <number>";
|
||||
}
|
||||
/*
|
||||
string bugUrl = this.RosBugUrl;
|
||||
|
||||
if (context is ChannelMessageContext)
|
||||
{
|
||||
ChannelMessageContext channelContext = context as ChannelMessageContext;
|
||||
if (channelContext.Channel.Name == "winehackers")
|
||||
bugUrl = this.WineBugUrl;
|
||||
else if (channelContext.Channel.Name == "samba-technical")
|
||||
bugUrl = this.SambaBugUrl;
|
||||
}*/
|
||||
|
||||
TechBot.ServiceOutput.WriteLine(context, String.Format(BugUrl, bug));
|
||||
}
|
||||
|
||||
protected abstract string BugUrl { get; }
|
||||
}
|
||||
}
|
||||
|
|
53
irc/TechBot/TechBot.Library/Command.cs
Normal file
53
irc/TechBot/TechBot.Library/Command.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
/*
|
||||
public interface ICommand
|
||||
{
|
||||
bool CanHandle(string commandName);
|
||||
void Handle(MessageContext context,
|
||||
string commandName,
|
||||
string parameters);
|
||||
//string Help();
|
||||
}*/
|
||||
|
||||
public abstract class Command
|
||||
{
|
||||
protected TechBotService m_TechBotService = null;
|
||||
|
||||
public Command(TechBotService techbot)
|
||||
{
|
||||
m_TechBotService = techbot;
|
||||
}
|
||||
|
||||
public TechBotService TechBot
|
||||
{
|
||||
get { return m_TechBotService; }
|
||||
}
|
||||
|
||||
public abstract string[] AvailableCommands { get; }
|
||||
|
||||
public abstract void Handle(MessageContext context,
|
||||
string commandName,
|
||||
string parameters);
|
||||
|
||||
/*
|
||||
protected bool CanHandle(string commandName,
|
||||
string[] availableCommands)
|
||||
{
|
||||
foreach (string availableCommand in availableCommands)
|
||||
{
|
||||
if (String.Compare(availableCommand, commandName, true) == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
public virtual string Help()
|
||||
{
|
||||
return "No help is available for this command";
|
||||
}
|
||||
}
|
||||
}
|
26
irc/TechBot/TechBot.Library/Commands/Base/XmlCommand.cs
Normal file
26
irc/TechBot/TechBot.Library/Commands/Base/XmlCommand.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Xml;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public abstract class XmlCommand : Command
|
||||
{
|
||||
protected XmlDocument m_XmlDocument;
|
||||
|
||||
public XmlCommand(TechBotService techBot)
|
||||
: base(techBot)
|
||||
{
|
||||
m_XmlDocument = new XmlDocument();
|
||||
m_XmlDocument.Load(XmlFile);
|
||||
}
|
||||
|
||||
public abstract string XmlFile { get; }
|
||||
|
||||
public XmlDocument XmlDocument
|
||||
{
|
||||
get { return m_XmlDocument; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<project name="TechBot.Library" default="build">
|
||||
|
||||
<property name="output.dir" value="..\bin" />
|
||||
|
||||
<target name="build" description="Build component">
|
||||
<mkdir dir="${output.dir}" />
|
||||
<csc target="library"
|
||||
output="${output.dir}\TechBot.Library.dll"
|
||||
optimize="true"
|
||||
debug="true"
|
||||
doc="${output.dir}\TechBot.Library.xml"
|
||||
warninglevel="0">
|
||||
<sources>
|
||||
<include name="*.cs" />
|
||||
</sources>
|
||||
<references>
|
||||
<include name="${output.dir}\CHMLibrary.dll" />
|
||||
<include name="${output.dir}\TechBot.IRCLibrary.dll" />
|
||||
</references>
|
||||
</csc>
|
||||
</target>
|
||||
|
||||
</project>
|
|
@ -4,30 +4,32 @@ using System.Collections;
|
|||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class ErrorCommand : BaseCommand, ICommand
|
||||
public class ErrorCommand : Command
|
||||
{
|
||||
private IServiceOutput serviceOutput;
|
||||
private NtStatusCommand ntStatus;
|
||||
private WinerrorCommand winerror;
|
||||
private HresultCommand hresult;
|
||||
private HResultCommand hresult;
|
||||
|
||||
public ErrorCommand(IServiceOutput serviceOutput, string ntstatusXml,
|
||||
string winerrorXml, string hresultXml)
|
||||
public ErrorCommand(TechBotService techBot)
|
||||
: base(techBot)
|
||||
{
|
||||
this.serviceOutput = serviceOutput;
|
||||
this.ntStatus = new NtStatusCommand(serviceOutput,
|
||||
ntstatusXml);
|
||||
this.winerror = new WinerrorCommand(serviceOutput,
|
||||
winerrorXml);
|
||||
this.hresult = new HresultCommand(serviceOutput,
|
||||
hresultXml);
|
||||
this.ntStatus = new NtStatusCommand(techBot);
|
||||
this.winerror = new WinerrorCommand(techBot);
|
||||
this.hresult = new HResultCommand(techBot);
|
||||
}
|
||||
|
||||
/*
|
||||
public bool CanHandle(string commandName)
|
||||
{
|
||||
return CanHandle(commandName,
|
||||
new string[] { "error" });
|
||||
}
|
||||
*/
|
||||
|
||||
public override string[] AvailableCommands
|
||||
{
|
||||
get { return new string[] { "error" }; }
|
||||
}
|
||||
|
||||
private static int GetSeverity(long error)
|
||||
{
|
||||
|
@ -79,14 +81,14 @@ namespace TechBot.Library
|
|||
return code.ToString();
|
||||
}
|
||||
|
||||
public void Handle(MessageContext context,
|
||||
public override void Handle(MessageContext context,
|
||||
string commandName,
|
||||
string parameters)
|
||||
{
|
||||
string originalErrorText = parameters.Trim();
|
||||
if (originalErrorText.Equals(String.Empty))
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
"Please provide an Error Code.");
|
||||
return;
|
||||
}
|
||||
|
@ -98,7 +100,7 @@ namespace TechBot.Library
|
|||
long error = np.Parse(errorText);
|
||||
if (np.Error)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("{0} is not a valid Error Code.",
|
||||
originalErrorText));
|
||||
return;
|
||||
|
@ -173,30 +175,30 @@ namespace TechBot.Library
|
|||
goto retry;
|
||||
}
|
||||
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("I don't know about Error Code {0}.",
|
||||
originalErrorText));
|
||||
}
|
||||
else if (descriptions.Count == 1)
|
||||
{
|
||||
string description = (string)descriptions[0];
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("{0} is {1}.",
|
||||
originalErrorText,
|
||||
description));
|
||||
}
|
||||
else
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("{0} could be:",
|
||||
originalErrorText));
|
||||
|
||||
foreach(string description in descriptions)
|
||||
serviceOutput.WriteLine(context, String.Format("\t{0}", description));
|
||||
TechBot.ServiceOutput.WriteLine(context, String.Format("\t{0}", description));
|
||||
}
|
||||
}
|
||||
|
||||
public string Help()
|
||||
|
||||
public override string Help()
|
||||
{
|
||||
return "!error <value>";
|
||||
}
|
||||
|
|
|
@ -3,38 +3,33 @@ using System.Collections;
|
|||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class HelpCommand : BaseCommand, ICommand
|
||||
public class HelpCommand : Command
|
||||
{
|
||||
private IServiceOutput serviceOutput;
|
||||
private ArrayList commands;
|
||||
|
||||
public HelpCommand(IServiceOutput serviceOutput,
|
||||
ArrayList commands)
|
||||
public HelpCommand(TechBotService techBot)
|
||||
: base(techBot)
|
||||
{
|
||||
this.serviceOutput = serviceOutput;
|
||||
this.commands = commands;
|
||||
}
|
||||
|
||||
public bool CanHandle(string commandName)
|
||||
{
|
||||
return CanHandle(commandName,
|
||||
new string[] { "help" });
|
||||
}
|
||||
|
||||
public void Handle(MessageContext context,
|
||||
string commandName,
|
||||
string parameters)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
"I support the following commands:");
|
||||
foreach (ICommand command in commands)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
command.Help());
|
||||
}
|
||||
}
|
||||
|
||||
public string Help()
|
||||
public override string[] AvailableCommands
|
||||
{
|
||||
get { return new string[] { "help" }; }
|
||||
}
|
||||
|
||||
public override void Handle(
|
||||
MessageContext context,
|
||||
string commandName,
|
||||
string parameters)
|
||||
{
|
||||
TechBot.ServiceOutput.WriteLine(context, "I support the following commands:");
|
||||
|
||||
foreach (Command command in TechBot.Commands)
|
||||
{
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
command.Help());
|
||||
}
|
||||
}
|
||||
|
||||
public override string Help()
|
||||
{
|
||||
return "!help";
|
||||
}
|
||||
|
|
|
@ -3,33 +3,39 @@ using System.Xml;
|
|||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class HresultCommand : BaseCommand, ICommand
|
||||
public class HResultCommand : XmlCommand
|
||||
{
|
||||
private IServiceOutput serviceOutput;
|
||||
private XmlDocument hresultXmlDocument;
|
||||
|
||||
public HresultCommand(IServiceOutput serviceOutput,
|
||||
string hresultXml)
|
||||
public HResultCommand(TechBotService techBot)
|
||||
: base(techBot)
|
||||
{
|
||||
this.serviceOutput = serviceOutput;
|
||||
hresultXmlDocument = new XmlDocument();
|
||||
hresultXmlDocument.Load(hresultXml);
|
||||
}
|
||||
|
||||
|
||||
public override string XmlFile
|
||||
{
|
||||
get { return Settings.Default.HResultXml; }
|
||||
}
|
||||
|
||||
public override string[] AvailableCommands
|
||||
{
|
||||
get { return new string[] { "hresult" }; }
|
||||
}
|
||||
|
||||
/*
|
||||
public bool CanHandle(string commandName)
|
||||
{
|
||||
return CanHandle(commandName,
|
||||
new string[] { "hresult" });
|
||||
}
|
||||
*/
|
||||
|
||||
public void Handle(MessageContext context,
|
||||
public override void Handle(MessageContext context,
|
||||
string commandName,
|
||||
string parameters)
|
||||
{
|
||||
string hresultText = parameters;
|
||||
if (hresultText.Equals(String.Empty))
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
"Please provide a valid HRESULT value.");
|
||||
return;
|
||||
}
|
||||
|
@ -38,7 +44,7 @@ namespace TechBot.Library
|
|||
long hresult = np.Parse(hresultText);
|
||||
if (np.Error)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("{0} is not a valid HRESULT value.",
|
||||
hresultText));
|
||||
return;
|
||||
|
@ -47,27 +53,27 @@ namespace TechBot.Library
|
|||
string description = GetHresultDescription(hresult);
|
||||
if (description != null)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("{0} is {1}.",
|
||||
hresultText,
|
||||
description));
|
||||
}
|
||||
else
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("I don't know about HRESULT {0}.",
|
||||
hresultText));
|
||||
}
|
||||
}
|
||||
|
||||
public string Help()
|
||||
public override string Help()
|
||||
{
|
||||
return "!hresult <value>";
|
||||
}
|
||||
|
||||
public string GetHresultDescription(long hresult)
|
||||
{
|
||||
XmlElement root = hresultXmlDocument.DocumentElement;
|
||||
XmlElement root = base.m_XmlDocument.DocumentElement;
|
||||
XmlNode node = root.SelectSingleNode(String.Format("Hresult[@value='{0}']",
|
||||
hresult.ToString("X8")));
|
||||
if (node != null)
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public interface ICommand
|
||||
{
|
||||
bool CanHandle(string commandName);
|
||||
void Handle(MessageContext context,
|
||||
string commandName,
|
||||
string parameters);
|
||||
string Help();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class BaseCommand
|
||||
{
|
||||
protected bool CanHandle(string commandName,
|
||||
string[] availableCommands)
|
||||
{
|
||||
foreach (string availableCommand in availableCommands)
|
||||
{
|
||||
if (String.Compare(availableCommand, commandName, true) == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Threading;
|
||||
|
||||
using TechBot.IRCLibrary;
|
||||
|
||||
namespace TechBot.Library
|
||||
|
@ -20,7 +22,7 @@ namespace TechBot.Library
|
|||
private string wmXml;
|
||||
private string svnCommand;
|
||||
private string bugUrl, WineBugUrl, SambaBugUrl;
|
||||
private IrcClient client;
|
||||
private IrcClient m_IrcClient;
|
||||
private ArrayList channels = new ArrayList(); /* IrcChannel */
|
||||
private TechBotService service;
|
||||
private bool isStopped = false;
|
||||
|
@ -32,11 +34,11 @@ namespace TechBot.Library
|
|||
string password,
|
||||
string chmPath,
|
||||
string mainChm,
|
||||
string ntstatusXml,
|
||||
string winerrorXml,
|
||||
string hresultXml,
|
||||
string wmXml,
|
||||
string svnCommand,
|
||||
//string ntstatusXml,
|
||||
//string winerrorXml,
|
||||
//string hresultXml,
|
||||
//string wmXml,
|
||||
//string svnCommand,
|
||||
string BugUrl,
|
||||
string WineBugUrl,
|
||||
string SambaBugUrl)
|
||||
|
@ -61,42 +63,43 @@ namespace TechBot.Library
|
|||
this.SambaBugUrl = SambaBugUrl;
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
service = new TechBotService(this,
|
||||
chmPath,
|
||||
mainChm,
|
||||
ntstatusXml,
|
||||
winerrorXml,
|
||||
hresultXml,
|
||||
wmXml,
|
||||
svnCommand,
|
||||
bugUrl,
|
||||
WineBugUrl,
|
||||
SambaBugUrl);
|
||||
service.Run();
|
||||
public void Run()
|
||||
{
|
||||
service = new TechBotService(this,
|
||||
chmPath,
|
||||
mainChm);
|
||||
//ntstatusXml,
|
||||
//winerrorXml,
|
||||
//hresultXml,
|
||||
//wmXml,
|
||||
//svnCommand,
|
||||
//bugUrl,
|
||||
//WineBugUrl,
|
||||
//SambaBugUrl);
|
||||
service.Run();
|
||||
|
||||
client = new IrcClient();
|
||||
client.Encoding = System.Text.Encoding.GetEncoding("iso-8859-1");
|
||||
client.MessageReceived += new MessageReceivedHandler(client_MessageReceived);
|
||||
client.ChannelUserDatabaseChanged += new ChannelUserDatabaseChangedHandler(client_ChannelUserDatabaseChanged);
|
||||
System.Console.WriteLine(String.Format("Connecting to {0} port {1}",
|
||||
hostname, port));
|
||||
client.Connect(hostname, port);
|
||||
System.Console.WriteLine("Connected...");
|
||||
client.Register(botname, password, null);
|
||||
System.Console.WriteLine(String.Format("Registered as {0}...", botname));
|
||||
JoinChannels();
|
||||
|
||||
while (!isStopped)
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
m_IrcClient = new IrcClient();
|
||||
m_IrcClient.Encoding = Encoding.GetEncoding("iso-8859-1");
|
||||
m_IrcClient.MessageReceived += new MessageReceivedHandler(client_MessageReceived);
|
||||
m_IrcClient.ChannelUserDatabaseChanged += new ChannelUserDatabaseChangedHandler(client_ChannelUserDatabaseChanged);
|
||||
Console.WriteLine("Connecting to {0} port {1}",
|
||||
hostname,
|
||||
port);
|
||||
m_IrcClient.Connect(hostname, port);
|
||||
Console.WriteLine("Connected...");
|
||||
m_IrcClient.Register(botname, password, null);
|
||||
Console.WriteLine("Registered as {0}...", botname);
|
||||
JoinChannels();
|
||||
|
||||
PartChannels();
|
||||
client.Diconnect();
|
||||
System.Console.WriteLine("Disconnected...");
|
||||
}
|
||||
while (!isStopped)
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
|
||||
PartChannels();
|
||||
m_IrcClient.Diconnect();
|
||||
Console.WriteLine("Disconnected...");
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
|
@ -107,7 +110,7 @@ namespace TechBot.Library
|
|||
{
|
||||
foreach (string channelname in channelnames.Split(new char[] { ';' }))
|
||||
{
|
||||
IrcChannel channel = client.JoinChannel(channelname);
|
||||
IrcChannel channel = m_IrcClient.JoinChannel(channelname);
|
||||
channels.Add(channel);
|
||||
System.Console.WriteLine(String.Format("Joined channel #{0}...",
|
||||
channel.Name));
|
||||
|
@ -118,7 +121,7 @@ namespace TechBot.Library
|
|||
{
|
||||
foreach (IrcChannel channel in channels)
|
||||
{
|
||||
client.PartChannel(channel, "Caught in the bitstream...");
|
||||
m_IrcClient.PartChannel(channel, "Caught in the bitstream...");
|
||||
System.Console.WriteLine(String.Format("Parted channel #{0}...",
|
||||
channel.Name));
|
||||
}
|
||||
|
@ -235,11 +238,11 @@ namespace TechBot.Library
|
|||
else if (GetTargetNickname(message,
|
||||
out nickname))
|
||||
{
|
||||
IrcUser targetUser = new IrcUser(client,
|
||||
IrcUser targetUser = new IrcUser(m_IrcClient,
|
||||
nickname);
|
||||
if (String.Compare(targetUser.Nickname, botname, true) == 0)
|
||||
{
|
||||
IrcUser sourceUser = new IrcUser(client,
|
||||
IrcUser sourceUser = new IrcUser(m_IrcClient,
|
||||
message.PrefixNickname);
|
||||
context = new UserMessageContext(sourceUser);
|
||||
return true;
|
||||
|
|
|
@ -3,35 +3,37 @@ using System.Xml;
|
|||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class NtStatusCommand : BaseCommand, ICommand
|
||||
public class NtStatusCommand : XmlCommand
|
||||
{
|
||||
private IServiceOutput serviceOutput;
|
||||
private string ntstatusXml;
|
||||
private XmlDocument ntstatusXmlDocument;
|
||||
|
||||
public NtStatusCommand(IServiceOutput serviceOutput,
|
||||
string ntstatusXml)
|
||||
public NtStatusCommand(TechBotService techBot)
|
||||
: base(techBot)
|
||||
{
|
||||
this.serviceOutput = serviceOutput;
|
||||
this.ntstatusXml = ntstatusXml;
|
||||
ntstatusXmlDocument = new XmlDocument();
|
||||
ntstatusXmlDocument.Load(ntstatusXml);
|
||||
}
|
||||
|
||||
|
||||
public override string XmlFile
|
||||
{
|
||||
get { return Settings.Default.NtStatusXml; }
|
||||
}
|
||||
|
||||
public override string[] AvailableCommands
|
||||
{
|
||||
get { return new string[] { "ntstatus" }; }
|
||||
}
|
||||
/*
|
||||
public bool CanHandle(string commandName)
|
||||
{
|
||||
return CanHandle(commandName,
|
||||
new string[] { "ntstatus" });
|
||||
}
|
||||
|
||||
public void Handle(MessageContext context,
|
||||
*/
|
||||
public override void Handle(MessageContext context,
|
||||
string commandName,
|
||||
string parameters)
|
||||
{
|
||||
string ntstatusText = parameters;
|
||||
if (ntstatusText.Equals(String.Empty))
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
"Please provide a valid NTSTATUS value.");
|
||||
return;
|
||||
}
|
||||
|
@ -40,7 +42,7 @@ namespace TechBot.Library
|
|||
long ntstatus = np.Parse(ntstatusText);
|
||||
if (np.Error)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("{0} is not a valid NTSTATUS value.",
|
||||
ntstatusText));
|
||||
return;
|
||||
|
@ -49,27 +51,27 @@ namespace TechBot.Library
|
|||
string description = GetNtstatusDescription(ntstatus);
|
||||
if (description != null)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("{0} is {1}.",
|
||||
ntstatusText,
|
||||
description));
|
||||
}
|
||||
else
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("I don't know about NTSTATUS {0}.",
|
||||
ntstatusText));
|
||||
}
|
||||
}
|
||||
|
||||
public string Help()
|
||||
|
||||
public override string Help()
|
||||
{
|
||||
return "!ntstatus <value>";
|
||||
}
|
||||
|
||||
public string GetNtstatusDescription(long ntstatus)
|
||||
{
|
||||
XmlElement root = ntstatusXmlDocument.DocumentElement;
|
||||
XmlElement root = base.m_XmlDocument.DocumentElement;
|
||||
XmlNode node = root.SelectSingleNode(String.Format("Ntstatus[@value='{0}']",
|
||||
ntstatus.ToString("X8")));
|
||||
if (node != null)
|
||||
|
|
|
@ -1,32 +1,32 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Information about this assembly is defined by the following
|
||||
// attributes.
|
||||
//
|
||||
// change them to the information which is associated with the assembly
|
||||
// you compile.
|
||||
|
||||
[assembly: AssemblyTitle("")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// The assembly version has following format :
|
||||
//
|
||||
// Major.Minor.Build.Revision
|
||||
//
|
||||
// You can specify all values by your own or you can build default build and revision
|
||||
// numbers with the '*' character (the default):
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
// The following attributes specify the key for the sign of your assembly. See the
|
||||
// .NET Framework documentation for more information about signing.
|
||||
// This is not required, if you don't want signing let these attributes like they're.
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
[assembly: AssemblyKeyFile("")]
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Information about this assembly is defined by the following
|
||||
// attributes.
|
||||
//
|
||||
// change them to the information which is associated with the assembly
|
||||
// you compile.
|
||||
|
||||
[assembly: AssemblyTitle("")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// The assembly version has following format :
|
||||
//
|
||||
// Major.Minor.Build.Revision
|
||||
//
|
||||
// You can specify all values by your own or you can build default build and revision
|
||||
// numbers with the '*' character (the default):
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
// The following attributes specify the key for the sign of your assembly. See the
|
||||
// .NET Framework documentation for more information about signing.
|
||||
// This is not required, if you don't want signing let these attributes like they're.
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
[assembly: AssemblyKeyFile("")]
|
29
irc/TechBot/TechBot.Library/ReactOSBugUrl.cs
Normal file
29
irc/TechBot/TechBot.Library/ReactOSBugUrl.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
class ReactOSBugUrl : BugCommand
|
||||
{
|
||||
public ReactOSBugUrl(TechBotService techBot)
|
||||
: base(techBot)
|
||||
{
|
||||
}
|
||||
|
||||
public override string[] AvailableCommands
|
||||
{
|
||||
get { return new string[] { "rosbug" }; }
|
||||
}
|
||||
|
||||
protected override string BugUrl
|
||||
{
|
||||
get { return "http://www.reactos.org/bugzilla/show_bug.cgi?id={0}"; }
|
||||
}
|
||||
|
||||
public override string Help()
|
||||
{
|
||||
return "!rosbug <number>";
|
||||
}
|
||||
}
|
||||
}
|
29
irc/TechBot/TechBot.Library/SambaBugUrl.cs
Normal file
29
irc/TechBot/TechBot.Library/SambaBugUrl.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
class SambaBugUrl : BugCommand
|
||||
{
|
||||
public SambaBugUrl(TechBotService techBot)
|
||||
: base(techBot)
|
||||
{
|
||||
}
|
||||
|
||||
public override string[] AvailableCommands
|
||||
{
|
||||
get { return new string[] { "sambabug" }; }
|
||||
}
|
||||
|
||||
protected override string BugUrl
|
||||
{
|
||||
get { return "https://bugzilla.samba.org/show_bug.cgi?id={0}"; }
|
||||
}
|
||||
|
||||
public override string Help()
|
||||
{
|
||||
return "!sambabug <number>";
|
||||
}
|
||||
}
|
||||
}
|
71
irc/TechBot/TechBot.Library/Settings.Designer.cs
generated
Normal file
71
irc/TechBot/TechBot.Library/Settings.Designer.cs
generated
Normal file
|
@ -0,0 +1,71 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.832
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace TechBot.Library {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\ntstatus.xml")]
|
||||
public string NtStatusXml {
|
||||
get {
|
||||
return ((string)(this["NtStatusXml"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\winerror.xml")]
|
||||
public string WinErrorXml {
|
||||
get {
|
||||
return ((string)(this["WinErrorXml"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\hresult.xml")]
|
||||
public string HResultXml {
|
||||
get {
|
||||
return ((string)(this["HResultXml"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\wm.xml")]
|
||||
public string WMXml {
|
||||
get {
|
||||
return ((string)(this["WMXml"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("svn://svn.reactos.org/trunk/reactos")]
|
||||
public string SVNRoot {
|
||||
get {
|
||||
return ((string)(this["SVNRoot"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
28
irc/TechBot/TechBot.Library/Settings.cs
Normal file
28
irc/TechBot/TechBot.Library/Settings.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
namespace TechBot.Library {
|
||||
|
||||
|
||||
// This class allows you to handle specific events on the settings class:
|
||||
// The SettingChanging event is raised before a setting's value is changed.
|
||||
// The PropertyChanged event is raised after a setting's value is changed.
|
||||
// The SettingsLoaded event is raised after the setting values are loaded.
|
||||
// The SettingsSaving event is raised before the setting values are saved.
|
||||
internal sealed partial class Settings {
|
||||
|
||||
public Settings() {
|
||||
// // To add event handlers for saving and changing settings, uncomment the lines below:
|
||||
//
|
||||
// this.SettingChanging += this.SettingChangingEventHandler;
|
||||
//
|
||||
// this.SettingsSaving += this.SettingsSavingEventHandler;
|
||||
//
|
||||
}
|
||||
|
||||
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
|
||||
// Add code to handle the SettingChangingEvent event here.
|
||||
}
|
||||
|
||||
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
|
||||
// Add code to handle the SettingsSaving event here.
|
||||
}
|
||||
}
|
||||
}
|
21
irc/TechBot/TechBot.Library/Settings.settings
Normal file
21
irc/TechBot/TechBot.Library/Settings.settings
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="TechBot.Library" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="NtStatusXml" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">C:\Ros\current\irc\TechBot\Resources\ntstatus.xml</Value>
|
||||
</Setting>
|
||||
<Setting Name="WinErrorXml" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">C:\Ros\current\irc\TechBot\Resources\winerror.xml</Value>
|
||||
</Setting>
|
||||
<Setting Name="HResultXml" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">C:\Ros\current\irc\TechBot\Resources\hresult.xml</Value>
|
||||
</Setting>
|
||||
<Setting Name="WMXml" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">C:\Ros\current\irc\TechBot\Resources\wm.xml</Value>
|
||||
</Setting>
|
||||
<Setting Name="SVNRoot" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">svn://svn.reactos.org/trunk/reactos</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
|
@ -2,33 +2,29 @@ using System;
|
|||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class SvnCommand : BaseCommand, ICommand
|
||||
public class SvnCommand : Command
|
||||
{
|
||||
private IServiceOutput serviceOutput;
|
||||
private string svnCommand;
|
||||
private string m_SvnRoot;
|
||||
|
||||
public SvnCommand(IServiceOutput serviceOutput,
|
||||
string svnCommand)
|
||||
public SvnCommand(TechBotService techBot)
|
||||
: base(techBot)
|
||||
{
|
||||
this.serviceOutput = serviceOutput;
|
||||
this.svnCommand = svnCommand;
|
||||
m_SvnRoot = Settings.Default.SVNRoot;
|
||||
}
|
||||
|
||||
public override string[] AvailableCommands
|
||||
{
|
||||
get { return new string[] { "svn" }; }
|
||||
}
|
||||
|
||||
public bool CanHandle(string commandName)
|
||||
{
|
||||
return CanHandle(commandName,
|
||||
new string[] { "svn" });
|
||||
}
|
||||
|
||||
public void Handle(MessageContext context,
|
||||
public override void Handle(MessageContext context,
|
||||
string commandName,
|
||||
string parameters)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
svnCommand);
|
||||
TechBot.ServiceOutput.WriteLine(context, string.Format("svn co {0}" , m_SvnRoot));
|
||||
}
|
||||
|
||||
public string Help()
|
||||
|
||||
public override string Help()
|
||||
{
|
||||
return "!svn";
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
<Combine fileversion="1.0" name="TechBot.Library" description="">
|
||||
<StartMode startupentry="TechBot.Library" single="True">
|
||||
<Execute entry="TechBot.Library" type="None" />
|
||||
</StartMode>
|
||||
<Entries>
|
||||
<Entry filename=".\.\TechBot.Library.prjx" />
|
||||
</Entries>
|
||||
<Configurations active="Debug">
|
||||
<Configuration name="Release">
|
||||
<Entry name="TechBot.Library" configurationname="Debug" build="False" />
|
||||
</Configuration>
|
||||
<Configuration name="Debug">
|
||||
<Entry name="TechBot.Library" configurationname="Debug" build="False" />
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
</Combine>
|
|
@ -40,8 +40,10 @@
|
|||
-->
|
||||
<ItemGroup>
|
||||
<Compile Include="ApiCommand.cs" />
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
<Compile Include="BugCommand.cs" />
|
||||
<Compile Include="Commands\Base\XmlCommand.cs" />
|
||||
<Compile Include="SambaBugUrl.cs" />
|
||||
<Compile Include="WineBugUrl.cs" />
|
||||
<Compile Include="ErrorCommand.cs" />
|
||||
<Compile Include="HelpCommand.cs" />
|
||||
<Compile Include="HresultCommand.cs" />
|
||||
|
@ -50,7 +52,15 @@
|
|||
<Compile Include="MessageContext.cs" />
|
||||
<Compile Include="NtStatusCommand.cs" />
|
||||
<Compile Include="NumberParser.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ReactOSBugUrl.cs" />
|
||||
<Compile Include="ServiceOutput.cs" />
|
||||
<Compile Include="Settings.cs" />
|
||||
<Compile Include="Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SvnCommand.cs" />
|
||||
<Compile Include="TechBotService.cs" />
|
||||
<Compile Include="WinerrorCommand.cs" />
|
||||
|
@ -72,6 +82,10 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
<None Include="app.config" />
|
||||
<None Include="Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,43 +0,0 @@
|
|||
<Project name="TechBot.Library" standardNamespace="TechBot.Library" description="" newfilesearch="None" enableviewstate="True" version="1.1" projecttype="C#">
|
||||
<Contents>
|
||||
<File name=".\AssemblyInfo.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||
<File name=".\Default.build" subtype="Code" buildaction="Nothing" dependson="" data="" />
|
||||
<File name=".\TechBotService.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||
<File name=".\ServiceOutput.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||
<File name=".\IrcService.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||
<File name=".\ApiCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||
<File name=".\ICommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||
<File name=".\HelpCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||
<File name=".\NtStatusCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||
<File name=".\NumberParser.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||
<File name=".\HresultCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||
<File name=".\WinerrorCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||
<File name=".\ErrorCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||
<File name=".\SvnCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||
<File name=".\BugCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||
<File name=".\WmCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||
<File name=".\MessageContext.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||
</Contents>
|
||||
<References>
|
||||
<Reference type="Project" refto="CHMLibrary" localcopy="True" />
|
||||
<Reference type="Project" refto="TechBot.IRCLibrary" localcopy="True" />
|
||||
</References>
|
||||
<DeploymentInformation target="" script="" strategy="File" />
|
||||
<Configuration runwithwarnings="True" name="Debug">
|
||||
<CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="" warninglevel="4" nowarn="" includedebuginformation="True" optimize="False" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="Library" definesymbols="" generatexmldocumentation="False" win32Icon="" noconfig="False" nostdlib="False" />
|
||||
<Execution commandlineparameters="" consolepause="False" />
|
||||
<Output directory="..\bin\Debug" assembly="TechBot.Library" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />
|
||||
</Configuration>
|
||||
<Configurations active="Debug">
|
||||
<Configuration runwithwarnings="True" name="Debug">
|
||||
<CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="" warninglevel="4" nowarn="" includedebuginformation="True" optimize="False" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="Library" definesymbols="" generatexmldocumentation="False" win32Icon="" noconfig="False" nostdlib="False" />
|
||||
<Execution commandlineparameters="" consolepause="False" />
|
||||
<Output directory="..\bin\Debug" assembly="TechBot.Library" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />
|
||||
</Configuration>
|
||||
<Configuration runwithwarnings="True" name="Release">
|
||||
<CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="" warninglevel="4" nowarn="" includedebuginformation="False" optimize="True" unsafecodeallowed="False" generateoverflowchecks="False" mainclass="" target="Library" definesymbols="" generatexmldocumentation="False" win32Icon="" noconfig="False" nostdlib="False" />
|
||||
<Execution commandlineparameters="" consolepause="False" />
|
||||
<Output directory="..\bin\Release" assembly="TechBot.Library" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
</Project>
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Data;
|
||||
using System.Threading;
|
||||
|
@ -18,19 +19,19 @@ namespace TechBot.Library
|
|||
private string wmXml;
|
||||
private string svnCommand;
|
||||
private string bugUrl, WineBugUrl, SambaBugUrl;
|
||||
private ArrayList commands = new ArrayList();
|
||||
private List<Command> commands = new List<Command>();
|
||||
|
||||
public TechBotService(IServiceOutput serviceOutput,
|
||||
string chmPath,
|
||||
string mainChm,
|
||||
string ntstatusXml,
|
||||
string winerrorXml,
|
||||
string hresultXml,
|
||||
string wmXml,
|
||||
string svnCommand,
|
||||
string bugUrl,
|
||||
string WineBugUrl,
|
||||
string SambaBugUrl)
|
||||
string mainChm)
|
||||
//string ntstatusXml,
|
||||
//string winerrorXml,
|
||||
//string hresultXml,
|
||||
//string wmXml,
|
||||
//string svnCommand,
|
||||
//string bugUrl,
|
||||
//string WineBugUrl,
|
||||
//string SambaBugUrl)
|
||||
{
|
||||
this.serviceOutput = serviceOutput;
|
||||
this.chmPath = chmPath;
|
||||
|
@ -44,33 +45,33 @@ namespace TechBot.Library
|
|||
this.WineBugUrl = WineBugUrl;
|
||||
this.SambaBugUrl = SambaBugUrl;
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
commands.Add(new HelpCommand(serviceOutput,
|
||||
commands));
|
||||
/*commands.Add(new ApiCommand(serviceOutput,
|
||||
chmPath,
|
||||
mainChm));*/
|
||||
commands.Add(new NtStatusCommand(serviceOutput,
|
||||
ntstatusXml));
|
||||
commands.Add(new WinerrorCommand(serviceOutput,
|
||||
winerrorXml));
|
||||
commands.Add(new HresultCommand(serviceOutput,
|
||||
hresultXml));
|
||||
commands.Add(new ErrorCommand(serviceOutput,
|
||||
ntstatusXml,
|
||||
winerrorXml,
|
||||
hresultXml));
|
||||
commands.Add(new WmCommand(serviceOutput,
|
||||
wmXml));
|
||||
commands.Add(new SvnCommand(serviceOutput,
|
||||
svnCommand));
|
||||
commands.Add(new BugCommand(serviceOutput,
|
||||
bugUrl,
|
||||
WineBugUrl,
|
||||
SambaBugUrl));
|
||||
}
|
||||
|
||||
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; }
|
||||
}
|
||||
|
||||
public void InjectMessage(MessageContext context,
|
||||
string message)
|
||||
|
@ -94,23 +95,27 @@ namespace TechBot.Library
|
|||
message = message.Substring(1).Trim();
|
||||
int index = message.IndexOf(' ');
|
||||
string commandName;
|
||||
string parameters = "";
|
||||
string commandParams = "";
|
||||
if (index != -1)
|
||||
{
|
||||
commandName = message.Substring(0, index).Trim();
|
||||
parameters = message.Substring(index).Trim();
|
||||
commandParams = message.Substring(index).Trim();
|
||||
}
|
||||
else
|
||||
commandName = message.Trim();
|
||||
|
||||
foreach (ICommand command in commands)
|
||||
foreach (Command command in commands)
|
||||
{
|
||||
if (command.CanHandle(commandName))
|
||||
{
|
||||
command.Handle(context,
|
||||
commandName, parameters);
|
||||
return;
|
||||
}
|
||||
foreach (string cmd in command.AvailableCommands)
|
||||
{
|
||||
if (cmd == commandName)
|
||||
{
|
||||
command.Handle(context,
|
||||
commandName,
|
||||
commandParams);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
29
irc/TechBot/TechBot.Library/WineBugUrl.cs
Normal file
29
irc/TechBot/TechBot.Library/WineBugUrl.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
class WineBugUrl : BugCommand
|
||||
{
|
||||
public WineBugUrl(TechBotService techBot)
|
||||
: base(techBot)
|
||||
{
|
||||
}
|
||||
|
||||
public override string[] AvailableCommands
|
||||
{
|
||||
get { return new string[] { "winebug" }; }
|
||||
}
|
||||
|
||||
protected override string BugUrl
|
||||
{
|
||||
get { return "http://bugs.winehq.org/show_bug.cgi?id={0}"; }
|
||||
}
|
||||
|
||||
public override string Help()
|
||||
{
|
||||
return "!winebug <number>";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,35 +3,31 @@ using System.Xml;
|
|||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class WinerrorCommand : BaseCommand, ICommand
|
||||
public class WinerrorCommand : XmlCommand
|
||||
{
|
||||
private IServiceOutput serviceOutput;
|
||||
private string winerrorXml;
|
||||
private XmlDocument winerrorXmlDocument;
|
||||
|
||||
public WinerrorCommand(IServiceOutput serviceOutput,
|
||||
string winerrorXml)
|
||||
public WinerrorCommand(TechBotService techBot)
|
||||
: base(techBot)
|
||||
{
|
||||
this.serviceOutput = serviceOutput;
|
||||
this.winerrorXml = winerrorXml;
|
||||
winerrorXmlDocument = new XmlDocument();
|
||||
winerrorXmlDocument.Load(winerrorXml);
|
||||
}
|
||||
|
||||
public bool CanHandle(string commandName)
|
||||
{
|
||||
return CanHandle(commandName,
|
||||
new string[] { "winerror" });
|
||||
}
|
||||
|
||||
public void Handle(MessageContext context,
|
||||
public override string XmlFile
|
||||
{
|
||||
get { return Settings.Default.WinErrorXml; }
|
||||
}
|
||||
|
||||
public override string[] AvailableCommands
|
||||
{
|
||||
get { return new string[] { "winerror" }; }
|
||||
}
|
||||
|
||||
public override void Handle(MessageContext context,
|
||||
string commandName,
|
||||
string parameters)
|
||||
{
|
||||
string winerrorText = parameters;
|
||||
if (winerrorText.Equals(String.Empty))
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
"Please provide a valid System Error Code value.");
|
||||
return;
|
||||
}
|
||||
|
@ -40,7 +36,7 @@ namespace TechBot.Library
|
|||
long winerror = np.Parse(winerrorText);
|
||||
if (np.Error)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("{0} is not a valid System Error Code value.",
|
||||
winerrorText));
|
||||
return;
|
||||
|
@ -49,27 +45,27 @@ namespace TechBot.Library
|
|||
string description = GetWinerrorDescription(winerror);
|
||||
if (description != null)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("{0} is {1}.",
|
||||
winerrorText,
|
||||
description));
|
||||
}
|
||||
else
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("I don't know about System Error Code {0}.",
|
||||
winerrorText));
|
||||
}
|
||||
}
|
||||
|
||||
public string Help()
|
||||
|
||||
public override string Help()
|
||||
{
|
||||
return "!winerror <value>";
|
||||
}
|
||||
|
||||
public string GetWinerrorDescription(long winerror)
|
||||
{
|
||||
XmlElement root = winerrorXmlDocument.DocumentElement;
|
||||
XmlElement root = base.m_XmlDocument.DocumentElement;
|
||||
XmlNode node = root.SelectSingleNode(String.Format("Winerror[@value='{0}']",
|
||||
winerror));
|
||||
if (node != null)
|
||||
|
|
|
@ -3,35 +3,31 @@ using System.Xml;
|
|||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class WmCommand : BaseCommand, ICommand
|
||||
public class WMCommand : XmlCommand
|
||||
{
|
||||
private IServiceOutput serviceOutput;
|
||||
private string wmXml;
|
||||
private XmlDocument wmXmlDocument;
|
||||
|
||||
public WmCommand(IServiceOutput serviceOutput,
|
||||
string wmXml)
|
||||
public WMCommand(TechBotService techBot)
|
||||
: base(techBot)
|
||||
{
|
||||
this.serviceOutput = serviceOutput;
|
||||
this.wmXml = wmXml;
|
||||
wmXmlDocument = new XmlDocument();
|
||||
wmXmlDocument.Load(wmXml);
|
||||
}
|
||||
|
||||
public override string XmlFile
|
||||
{
|
||||
get { return Settings.Default.WMXml; }
|
||||
}
|
||||
|
||||
public bool CanHandle(string commandName)
|
||||
{
|
||||
return CanHandle(commandName,
|
||||
new string[] { "wm" });
|
||||
}
|
||||
public override string[] AvailableCommands
|
||||
{
|
||||
get { return new string[] { "wm" }; }
|
||||
}
|
||||
|
||||
public void Handle(MessageContext context,
|
||||
public override void Handle(MessageContext context,
|
||||
string commandName,
|
||||
string parameters)
|
||||
{
|
||||
string wmText = parameters;
|
||||
if (wmText.Equals(String.Empty))
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
"Please provide a valid window message value or name.");
|
||||
return;
|
||||
}
|
||||
|
@ -51,27 +47,27 @@ namespace TechBot.Library
|
|||
|
||||
if (output != null)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("{0} is {1}.",
|
||||
wmText,
|
||||
output));
|
||||
}
|
||||
else
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("I don't know about window message {0}.",
|
||||
wmText));
|
||||
}
|
||||
}
|
||||
|
||||
public string Help()
|
||||
|
||||
public override string Help()
|
||||
{
|
||||
return "!wm <value> or !wm <name>";
|
||||
}
|
||||
|
||||
private string GetWmDescription(long wm)
|
||||
{
|
||||
XmlElement root = wmXmlDocument.DocumentElement;
|
||||
XmlElement root = base.m_XmlDocument.DocumentElement;
|
||||
XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@value='{0}']",
|
||||
wm));
|
||||
if (node != null)
|
||||
|
@ -87,7 +83,7 @@ namespace TechBot.Library
|
|||
|
||||
private string GetWmNumber(string wmName)
|
||||
{
|
||||
XmlElement root = wmXmlDocument.DocumentElement;
|
||||
XmlElement root = base.m_XmlDocument.DocumentElement;
|
||||
XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@text='{0}']",
|
||||
wmName));
|
||||
if (node != null)
|
||||
|
|
27
irc/TechBot/TechBot.Library/app.config
Normal file
27
irc/TechBot/TechBot.Library/app.config
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="TechBot.Library.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<applicationSettings>
|
||||
<TechBot.Library.Settings>
|
||||
<setting name="NtStatusXml" serializeAs="String">
|
||||
<value>C:\Ros\current\irc\TechBot\Resources\ntstatus.xml</value>
|
||||
</setting>
|
||||
<setting name="WinErrorXml" serializeAs="String">
|
||||
<value>C:\Ros\current\irc\TechBot\Resources\winerror.xml</value>
|
||||
</setting>
|
||||
<setting name="HResultXml" serializeAs="String">
|
||||
<value>C:\Ros\current\irc\TechBot\Resources\hresult.xml</value>
|
||||
</setting>
|
||||
<setting name="WMXml" serializeAs="String">
|
||||
<value>C:\Ros\current\irc\TechBot\Resources\wm.xml</value>
|
||||
</setting>
|
||||
<setting name="SVNRoot" serializeAs="String">
|
||||
<value>svn://svn.reactos.org/trunk/reactos</value>
|
||||
</setting>
|
||||
</TechBot.Library.Settings>
|
||||
</applicationSettings>
|
||||
</configuration>
|
|
@ -58,11 +58,11 @@ namespace TechBot
|
|||
IRCBotPassword,
|
||||
ChmPath,
|
||||
MainChm,
|
||||
NtstatusXml,
|
||||
WinerrorXml,
|
||||
HresultXml,
|
||||
WmXml,
|
||||
SvnCommand,
|
||||
//NtstatusXml,
|
||||
//WinerrorXml,
|
||||
//HresultXml,
|
||||
//WmXml,
|
||||
//SvnCommand,
|
||||
BugUrl,
|
||||
WineBugUrl,
|
||||
SambaBugUrl);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TechBot</RootNamespace>
|
||||
<AssemblyName>TechBot</AssemblyName>
|
||||
<StartupObject>TechBot.TechBotService</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
|
Loading…
Reference in a new issue