mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +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="IRCBotPassword" value="MyPassword" />
|
||||||
<add key="ChmPath" value="C:\IRC\TechBot\CHM" />
|
<add key="ChmPath" value="C:\IRC\TechBot\CHM" />
|
||||||
<add key="MainChm" value="kmarch.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="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="WineBugUrl" value="http://bugs.winehq.org/show_bug.cgi?id={0}" />
|
||||||
<add key="SambaBugUrl" value="https://bugzilla.samba.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,
|
IRCBotPassword,
|
||||||
ChmPath,
|
ChmPath,
|
||||||
MainChm,
|
MainChm,
|
||||||
NtstatusXml,
|
//NtstatusXml,
|
||||||
WinerrorXml,
|
//WinerrorXml,
|
||||||
HresultXml,
|
//HresultXml,
|
||||||
WmXml,
|
//WmXml,
|
||||||
SvnCommand,
|
//SvnCommand,
|
||||||
BugUrl,
|
BugUrl,
|
||||||
WineBugUrl,
|
WineBugUrl,
|
||||||
SambaBugUrl);
|
SambaBugUrl);
|
||||||
|
@ -239,15 +239,15 @@ namespace TechBot.Console
|
||||||
System.Console.WriteLine("TechBot running console service...");
|
System.Console.WriteLine("TechBot running console service...");
|
||||||
TechBotService service = new TechBotService(new ConsoleServiceOutput(),
|
TechBotService service = new TechBotService(new ConsoleServiceOutput(),
|
||||||
ChmPath,
|
ChmPath,
|
||||||
MainChm,
|
MainChm);
|
||||||
NtstatusXml,
|
//NtstatusXml,
|
||||||
WinerrorXml,
|
//WinerrorXml,
|
||||||
HresultXml,
|
//HresultXml,
|
||||||
WmXml,
|
//WmXml,
|
||||||
SvnCommand,
|
//SvnCommand,
|
||||||
BugUrl,
|
//BugUrl,
|
||||||
WineBugUrl,
|
//WineBugUrl,
|
||||||
SambaBugUrl);
|
//SambaBugUrl);
|
||||||
service.Run();
|
service.Run();
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,6 +53,9 @@
|
||||||
<Name>TechBot.Library</Name>
|
<Name>TechBot.Library</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Properties\" />
|
<Folder Include="Properties\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -7,22 +7,17 @@ using HtmlHelp.ChmDecoding;
|
||||||
|
|
||||||
namespace TechBot.Library
|
namespace TechBot.Library
|
||||||
{
|
{
|
||||||
public class ApiCommand : BaseCommand, ICommand
|
public class ApiCommand : Command
|
||||||
{
|
{
|
||||||
private const bool IsVerbose = false;
|
private const bool IsVerbose = false;
|
||||||
|
|
||||||
private HtmlHelpSystem chm;
|
private HtmlHelpSystem chm;
|
||||||
private IServiceOutput serviceOutput;
|
|
||||||
private string chmPath;
|
private string chmPath;
|
||||||
private string mainChm;
|
private string mainChm;
|
||||||
|
|
||||||
public ApiCommand(IServiceOutput serviceOutput,
|
public ApiCommand(TechBotService techBot)
|
||||||
string chmPath,
|
: base(techBot)
|
||||||
string mainChm)
|
|
||||||
{
|
{
|
||||||
this.serviceOutput = serviceOutput;
|
|
||||||
this.chmPath = chmPath;
|
|
||||||
this.mainChm = mainChm;
|
|
||||||
Run();
|
Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +25,7 @@ namespace TechBot.Library
|
||||||
string message)
|
string message)
|
||||||
{
|
{
|
||||||
if (IsVerbose)
|
if (IsVerbose)
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
message);
|
message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,14 +60,21 @@ namespace TechBot.Library
|
||||||
Console.WriteLine(String.Format("Loaded {0} CHMs",
|
Console.WriteLine(String.Format("Loaded {0} CHMs",
|
||||||
chm.FileList.Length));
|
chm.FileList.Length));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string[] AvailableCommands
|
||||||
|
{
|
||||||
|
get { return new string[] { "api" }; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public bool CanHandle(string commandName)
|
public bool CanHandle(string commandName)
|
||||||
{
|
{
|
||||||
return CanHandle(commandName,
|
return CanHandle(commandName,
|
||||||
new string[] { "api" });
|
new string[] { "api" });
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public void Handle(MessageContext context,
|
public override void Handle(MessageContext context,
|
||||||
string commandName,
|
string commandName,
|
||||||
string parameters)
|
string parameters)
|
||||||
{
|
{
|
||||||
|
@ -82,8 +84,8 @@ namespace TechBot.Library
|
||||||
Search(context,
|
Search(context,
|
||||||
parameters);
|
parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Help()
|
public override string Help()
|
||||||
{
|
{
|
||||||
return "!api <apiname>";
|
return "!api <apiname>";
|
||||||
}
|
}
|
||||||
|
@ -177,7 +179,7 @@ namespace TechBot.Library
|
||||||
if (prototype == null || prototype.Trim().Equals(String.Empty))
|
if (prototype == null || prototype.Trim().Equals(String.Empty))
|
||||||
return false;
|
return false;
|
||||||
string formattedPrototype = FormatPrototype(prototype);
|
string formattedPrototype = FormatPrototype(prototype);
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
formattedPrototype);
|
formattedPrototype);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -203,7 +205,7 @@ namespace TechBot.Library
|
||||||
if (prototype == null || prototype.Trim().Equals(String.Empty))
|
if (prototype == null || prototype.Trim().Equals(String.Empty))
|
||||||
continue;
|
continue;
|
||||||
string formattedPrototype = FormatPrototype(prototype);
|
string formattedPrototype = FormatPrototype(prototype);
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
formattedPrototype);
|
formattedPrototype);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -214,14 +216,14 @@ namespace TechBot.Library
|
||||||
private void DisplayNoResult(MessageContext context,
|
private void DisplayNoResult(MessageContext context,
|
||||||
string keyword)
|
string keyword)
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
String.Format("I don't know about keyword {0}",
|
String.Format("I don't know about keyword {0}",
|
||||||
keyword));
|
keyword));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DisplayNoKeyword(MessageContext context)
|
private void DisplayNoKeyword(MessageContext context)
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
"Please give me a keyword.");
|
"Please give me a keyword.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,70 +2,49 @@ using System;
|
||||||
|
|
||||||
namespace TechBot.Library
|
namespace TechBot.Library
|
||||||
{
|
{
|
||||||
public class BugCommand : BaseCommand, ICommand
|
public abstract class BugCommand : Command//, ICommand
|
||||||
{
|
{
|
||||||
private IServiceOutput serviceOutput;
|
public BugCommand(TechBotService techBot) : base (techBot)
|
||||||
private string RosBugUrl;
|
|
||||||
private string WineBugUrl;
|
|
||||||
private string SambaBugUrl;
|
|
||||||
|
|
||||||
public BugCommand(IServiceOutput serviceOutput,
|
|
||||||
string RosBugUrl,
|
|
||||||
string WineBugUrl,
|
|
||||||
string SambaBugUrl)
|
|
||||||
{
|
{
|
||||||
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,
|
public override void Handle(MessageContext context,
|
||||||
string commandName,
|
string commandName,
|
||||||
string parameters)
|
string parameters)
|
||||||
{
|
{
|
||||||
string bugText = parameters;
|
string bugText = parameters;
|
||||||
if (bugText.Equals(String.Empty))
|
if (bugText.Equals(String.Empty))
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
"Please provide a valid bug number.");
|
"Please provide a valid bug number.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NumberParser np = new NumberParser();
|
NumberParser np = new NumberParser();
|
||||||
long bug = np.Parse(bugText);
|
long bug = np.Parse(bugText);
|
||||||
if (np.Error)
|
if (np.Error)
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
String.Format("{0} is not a valid bug number.",
|
String.Format("{0} is not a valid bug number.",
|
||||||
bugText));
|
bugText));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string bugUrl = this.RosBugUrl;
|
|
||||||
|
|
||||||
if (context is ChannelMessageContext)
|
/*
|
||||||
{
|
string bugUrl = this.RosBugUrl;
|
||||||
ChannelMessageContext channelContext = context as ChannelMessageContext;
|
|
||||||
if (channelContext.Channel.Name == "winehackers")
|
if (context is ChannelMessageContext)
|
||||||
bugUrl = this.WineBugUrl;
|
{
|
||||||
else if (channelContext.Channel.Name == "samba-technical")
|
ChannelMessageContext channelContext = context as ChannelMessageContext;
|
||||||
bugUrl = this.SambaBugUrl;
|
if (channelContext.Channel.Name == "winehackers")
|
||||||
}
|
bugUrl = this.WineBugUrl;
|
||||||
|
else if (channelContext.Channel.Name == "samba-technical")
|
||||||
serviceOutput.WriteLine(context,
|
bugUrl = this.SambaBugUrl;
|
||||||
String.Format(bugUrl, bug));
|
}*/
|
||||||
}
|
|
||||||
|
TechBot.ServiceOutput.WriteLine(context, String.Format(BugUrl, bug));
|
||||||
public string Help()
|
}
|
||||||
{
|
|
||||||
return "!bug <number>";
|
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
|
namespace TechBot.Library
|
||||||
{
|
{
|
||||||
public class ErrorCommand : BaseCommand, ICommand
|
public class ErrorCommand : Command
|
||||||
{
|
{
|
||||||
private IServiceOutput serviceOutput;
|
|
||||||
private NtStatusCommand ntStatus;
|
private NtStatusCommand ntStatus;
|
||||||
private WinerrorCommand winerror;
|
private WinerrorCommand winerror;
|
||||||
private HresultCommand hresult;
|
private HResultCommand hresult;
|
||||||
|
|
||||||
public ErrorCommand(IServiceOutput serviceOutput, string ntstatusXml,
|
public ErrorCommand(TechBotService techBot)
|
||||||
string winerrorXml, string hresultXml)
|
: base(techBot)
|
||||||
{
|
{
|
||||||
this.serviceOutput = serviceOutput;
|
this.ntStatus = new NtStatusCommand(techBot);
|
||||||
this.ntStatus = new NtStatusCommand(serviceOutput,
|
this.winerror = new WinerrorCommand(techBot);
|
||||||
ntstatusXml);
|
this.hresult = new HResultCommand(techBot);
|
||||||
this.winerror = new WinerrorCommand(serviceOutput,
|
|
||||||
winerrorXml);
|
|
||||||
this.hresult = new HresultCommand(serviceOutput,
|
|
||||||
hresultXml);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public bool CanHandle(string commandName)
|
public bool CanHandle(string commandName)
|
||||||
{
|
{
|
||||||
return CanHandle(commandName,
|
return CanHandle(commandName,
|
||||||
new string[] { "error" });
|
new string[] { "error" });
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
public override string[] AvailableCommands
|
||||||
|
{
|
||||||
|
get { return new string[] { "error" }; }
|
||||||
|
}
|
||||||
|
|
||||||
private static int GetSeverity(long error)
|
private static int GetSeverity(long error)
|
||||||
{
|
{
|
||||||
|
@ -79,14 +81,14 @@ namespace TechBot.Library
|
||||||
return code.ToString();
|
return code.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Handle(MessageContext context,
|
public override void Handle(MessageContext context,
|
||||||
string commandName,
|
string commandName,
|
||||||
string parameters)
|
string parameters)
|
||||||
{
|
{
|
||||||
string originalErrorText = parameters.Trim();
|
string originalErrorText = parameters.Trim();
|
||||||
if (originalErrorText.Equals(String.Empty))
|
if (originalErrorText.Equals(String.Empty))
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
"Please provide an Error Code.");
|
"Please provide an Error Code.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -98,7 +100,7 @@ namespace TechBot.Library
|
||||||
long error = np.Parse(errorText);
|
long error = np.Parse(errorText);
|
||||||
if (np.Error)
|
if (np.Error)
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
String.Format("{0} is not a valid Error Code.",
|
String.Format("{0} is not a valid Error Code.",
|
||||||
originalErrorText));
|
originalErrorText));
|
||||||
return;
|
return;
|
||||||
|
@ -173,30 +175,30 @@ namespace TechBot.Library
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
String.Format("I don't know about Error Code {0}.",
|
String.Format("I don't know about Error Code {0}.",
|
||||||
originalErrorText));
|
originalErrorText));
|
||||||
}
|
}
|
||||||
else if (descriptions.Count == 1)
|
else if (descriptions.Count == 1)
|
||||||
{
|
{
|
||||||
string description = (string)descriptions[0];
|
string description = (string)descriptions[0];
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
String.Format("{0} is {1}.",
|
String.Format("{0} is {1}.",
|
||||||
originalErrorText,
|
originalErrorText,
|
||||||
description));
|
description));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
String.Format("{0} could be:",
|
String.Format("{0} could be:",
|
||||||
originalErrorText));
|
originalErrorText));
|
||||||
|
|
||||||
foreach(string description in descriptions)
|
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>";
|
return "!error <value>";
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,38 +3,33 @@ using System.Collections;
|
||||||
|
|
||||||
namespace TechBot.Library
|
namespace TechBot.Library
|
||||||
{
|
{
|
||||||
public class HelpCommand : BaseCommand, ICommand
|
public class HelpCommand : Command
|
||||||
{
|
{
|
||||||
private IServiceOutput serviceOutput;
|
public HelpCommand(TechBotService techBot)
|
||||||
private ArrayList commands;
|
: base(techBot)
|
||||||
|
|
||||||
public HelpCommand(IServiceOutput serviceOutput,
|
|
||||||
ArrayList commands)
|
|
||||||
{
|
{
|
||||||
this.serviceOutput = serviceOutput;
|
|
||||||
this.commands = commands;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanHandle(string commandName)
|
public override string[] AvailableCommands
|
||||||
{
|
{
|
||||||
return CanHandle(commandName,
|
get { return new string[] { "help" }; }
|
||||||
new string[] { "help" });
|
}
|
||||||
}
|
|
||||||
|
public override void Handle(
|
||||||
public void Handle(MessageContext context,
|
MessageContext context,
|
||||||
string commandName,
|
string commandName,
|
||||||
string parameters)
|
string parameters)
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context, "I support the following commands:");
|
||||||
"I support the following commands:");
|
|
||||||
foreach (ICommand command in commands)
|
foreach (Command command in TechBot.Commands)
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
command.Help());
|
command.Help());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Help()
|
public override string Help()
|
||||||
{
|
{
|
||||||
return "!help";
|
return "!help";
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,33 +3,39 @@ using System.Xml;
|
||||||
|
|
||||||
namespace TechBot.Library
|
namespace TechBot.Library
|
||||||
{
|
{
|
||||||
public class HresultCommand : BaseCommand, ICommand
|
public class HResultCommand : XmlCommand
|
||||||
{
|
{
|
||||||
private IServiceOutput serviceOutput;
|
public HResultCommand(TechBotService techBot)
|
||||||
private XmlDocument hresultXmlDocument;
|
: base(techBot)
|
||||||
|
|
||||||
public HresultCommand(IServiceOutput serviceOutput,
|
|
||||||
string hresultXml)
|
|
||||||
{
|
{
|
||||||
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)
|
public bool CanHandle(string commandName)
|
||||||
{
|
{
|
||||||
return CanHandle(commandName,
|
return CanHandle(commandName,
|
||||||
new string[] { "hresult" });
|
new string[] { "hresult" });
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public void Handle(MessageContext context,
|
public override void Handle(MessageContext context,
|
||||||
string commandName,
|
string commandName,
|
||||||
string parameters)
|
string parameters)
|
||||||
{
|
{
|
||||||
string hresultText = parameters;
|
string hresultText = parameters;
|
||||||
if (hresultText.Equals(String.Empty))
|
if (hresultText.Equals(String.Empty))
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
"Please provide a valid HRESULT value.");
|
"Please provide a valid HRESULT value.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +44,7 @@ namespace TechBot.Library
|
||||||
long hresult = np.Parse(hresultText);
|
long hresult = np.Parse(hresultText);
|
||||||
if (np.Error)
|
if (np.Error)
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
String.Format("{0} is not a valid HRESULT value.",
|
String.Format("{0} is not a valid HRESULT value.",
|
||||||
hresultText));
|
hresultText));
|
||||||
return;
|
return;
|
||||||
|
@ -47,27 +53,27 @@ namespace TechBot.Library
|
||||||
string description = GetHresultDescription(hresult);
|
string description = GetHresultDescription(hresult);
|
||||||
if (description != null)
|
if (description != null)
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
String.Format("{0} is {1}.",
|
String.Format("{0} is {1}.",
|
||||||
hresultText,
|
hresultText,
|
||||||
description));
|
description));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
String.Format("I don't know about HRESULT {0}.",
|
String.Format("I don't know about HRESULT {0}.",
|
||||||
hresultText));
|
hresultText));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Help()
|
public override string Help()
|
||||||
{
|
{
|
||||||
return "!hresult <value>";
|
return "!hresult <value>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetHresultDescription(long hresult)
|
public string GetHresultDescription(long hresult)
|
||||||
{
|
{
|
||||||
XmlElement root = hresultXmlDocument.DocumentElement;
|
XmlElement root = base.m_XmlDocument.DocumentElement;
|
||||||
XmlNode node = root.SelectSingleNode(String.Format("Hresult[@value='{0}']",
|
XmlNode node = root.SelectSingleNode(String.Format("Hresult[@value='{0}']",
|
||||||
hresult.ToString("X8")));
|
hresult.ToString("X8")));
|
||||||
if (node != null)
|
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;
|
||||||
|
using System.Text;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
using TechBot.IRCLibrary;
|
using TechBot.IRCLibrary;
|
||||||
|
|
||||||
namespace TechBot.Library
|
namespace TechBot.Library
|
||||||
|
@ -20,7 +22,7 @@ namespace TechBot.Library
|
||||||
private string wmXml;
|
private string wmXml;
|
||||||
private string svnCommand;
|
private string svnCommand;
|
||||||
private string bugUrl, WineBugUrl, SambaBugUrl;
|
private string bugUrl, WineBugUrl, SambaBugUrl;
|
||||||
private IrcClient client;
|
private IrcClient m_IrcClient;
|
||||||
private ArrayList channels = new ArrayList(); /* IrcChannel */
|
private ArrayList channels = new ArrayList(); /* IrcChannel */
|
||||||
private TechBotService service;
|
private TechBotService service;
|
||||||
private bool isStopped = false;
|
private bool isStopped = false;
|
||||||
|
@ -32,11 +34,11 @@ namespace TechBot.Library
|
||||||
string password,
|
string password,
|
||||||
string chmPath,
|
string chmPath,
|
||||||
string mainChm,
|
string mainChm,
|
||||||
string ntstatusXml,
|
//string ntstatusXml,
|
||||||
string winerrorXml,
|
//string winerrorXml,
|
||||||
string hresultXml,
|
//string hresultXml,
|
||||||
string wmXml,
|
//string wmXml,
|
||||||
string svnCommand,
|
//string svnCommand,
|
||||||
string BugUrl,
|
string BugUrl,
|
||||||
string WineBugUrl,
|
string WineBugUrl,
|
||||||
string SambaBugUrl)
|
string SambaBugUrl)
|
||||||
|
@ -61,42 +63,43 @@ namespace TechBot.Library
|
||||||
this.SambaBugUrl = SambaBugUrl;
|
this.SambaBugUrl = SambaBugUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
service = new TechBotService(this,
|
service = new TechBotService(this,
|
||||||
chmPath,
|
chmPath,
|
||||||
mainChm,
|
mainChm);
|
||||||
ntstatusXml,
|
//ntstatusXml,
|
||||||
winerrorXml,
|
//winerrorXml,
|
||||||
hresultXml,
|
//hresultXml,
|
||||||
wmXml,
|
//wmXml,
|
||||||
svnCommand,
|
//svnCommand,
|
||||||
bugUrl,
|
//bugUrl,
|
||||||
WineBugUrl,
|
//WineBugUrl,
|
||||||
SambaBugUrl);
|
//SambaBugUrl);
|
||||||
service.Run();
|
service.Run();
|
||||||
|
|
||||||
client = new IrcClient();
|
m_IrcClient = new IrcClient();
|
||||||
client.Encoding = System.Text.Encoding.GetEncoding("iso-8859-1");
|
m_IrcClient.Encoding = Encoding.GetEncoding("iso-8859-1");
|
||||||
client.MessageReceived += new MessageReceivedHandler(client_MessageReceived);
|
m_IrcClient.MessageReceived += new MessageReceivedHandler(client_MessageReceived);
|
||||||
client.ChannelUserDatabaseChanged += new ChannelUserDatabaseChangedHandler(client_ChannelUserDatabaseChanged);
|
m_IrcClient.ChannelUserDatabaseChanged += new ChannelUserDatabaseChangedHandler(client_ChannelUserDatabaseChanged);
|
||||||
System.Console.WriteLine(String.Format("Connecting to {0} port {1}",
|
Console.WriteLine("Connecting to {0} port {1}",
|
||||||
hostname, port));
|
hostname,
|
||||||
client.Connect(hostname, port);
|
port);
|
||||||
System.Console.WriteLine("Connected...");
|
m_IrcClient.Connect(hostname, port);
|
||||||
client.Register(botname, password, null);
|
Console.WriteLine("Connected...");
|
||||||
System.Console.WriteLine(String.Format("Registered as {0}...", botname));
|
m_IrcClient.Register(botname, password, null);
|
||||||
JoinChannels();
|
Console.WriteLine("Registered as {0}...", botname);
|
||||||
|
JoinChannels();
|
||||||
while (!isStopped)
|
|
||||||
{
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
PartChannels();
|
while (!isStopped)
|
||||||
client.Diconnect();
|
{
|
||||||
System.Console.WriteLine("Disconnected...");
|
Thread.Sleep(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PartChannels();
|
||||||
|
m_IrcClient.Diconnect();
|
||||||
|
Console.WriteLine("Disconnected...");
|
||||||
|
}
|
||||||
|
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
|
@ -107,7 +110,7 @@ namespace TechBot.Library
|
||||||
{
|
{
|
||||||
foreach (string channelname in channelnames.Split(new char[] { ';' }))
|
foreach (string channelname in channelnames.Split(new char[] { ';' }))
|
||||||
{
|
{
|
||||||
IrcChannel channel = client.JoinChannel(channelname);
|
IrcChannel channel = m_IrcClient.JoinChannel(channelname);
|
||||||
channels.Add(channel);
|
channels.Add(channel);
|
||||||
System.Console.WriteLine(String.Format("Joined channel #{0}...",
|
System.Console.WriteLine(String.Format("Joined channel #{0}...",
|
||||||
channel.Name));
|
channel.Name));
|
||||||
|
@ -118,7 +121,7 @@ namespace TechBot.Library
|
||||||
{
|
{
|
||||||
foreach (IrcChannel channel in channels)
|
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}...",
|
System.Console.WriteLine(String.Format("Parted channel #{0}...",
|
||||||
channel.Name));
|
channel.Name));
|
||||||
}
|
}
|
||||||
|
@ -235,11 +238,11 @@ namespace TechBot.Library
|
||||||
else if (GetTargetNickname(message,
|
else if (GetTargetNickname(message,
|
||||||
out nickname))
|
out nickname))
|
||||||
{
|
{
|
||||||
IrcUser targetUser = new IrcUser(client,
|
IrcUser targetUser = new IrcUser(m_IrcClient,
|
||||||
nickname);
|
nickname);
|
||||||
if (String.Compare(targetUser.Nickname, botname, true) == 0)
|
if (String.Compare(targetUser.Nickname, botname, true) == 0)
|
||||||
{
|
{
|
||||||
IrcUser sourceUser = new IrcUser(client,
|
IrcUser sourceUser = new IrcUser(m_IrcClient,
|
||||||
message.PrefixNickname);
|
message.PrefixNickname);
|
||||||
context = new UserMessageContext(sourceUser);
|
context = new UserMessageContext(sourceUser);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -3,35 +3,37 @@ using System.Xml;
|
||||||
|
|
||||||
namespace TechBot.Library
|
namespace TechBot.Library
|
||||||
{
|
{
|
||||||
public class NtStatusCommand : BaseCommand, ICommand
|
public class NtStatusCommand : XmlCommand
|
||||||
{
|
{
|
||||||
private IServiceOutput serviceOutput;
|
public NtStatusCommand(TechBotService techBot)
|
||||||
private string ntstatusXml;
|
: base(techBot)
|
||||||
private XmlDocument ntstatusXmlDocument;
|
|
||||||
|
|
||||||
public NtStatusCommand(IServiceOutput serviceOutput,
|
|
||||||
string ntstatusXml)
|
|
||||||
{
|
{
|
||||||
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)
|
public bool CanHandle(string commandName)
|
||||||
{
|
{
|
||||||
return CanHandle(commandName,
|
return CanHandle(commandName,
|
||||||
new string[] { "ntstatus" });
|
new string[] { "ntstatus" });
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
public void Handle(MessageContext context,
|
public override void Handle(MessageContext context,
|
||||||
string commandName,
|
string commandName,
|
||||||
string parameters)
|
string parameters)
|
||||||
{
|
{
|
||||||
string ntstatusText = parameters;
|
string ntstatusText = parameters;
|
||||||
if (ntstatusText.Equals(String.Empty))
|
if (ntstatusText.Equals(String.Empty))
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
"Please provide a valid NTSTATUS value.");
|
"Please provide a valid NTSTATUS value.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +42,7 @@ namespace TechBot.Library
|
||||||
long ntstatus = np.Parse(ntstatusText);
|
long ntstatus = np.Parse(ntstatusText);
|
||||||
if (np.Error)
|
if (np.Error)
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
String.Format("{0} is not a valid NTSTATUS value.",
|
String.Format("{0} is not a valid NTSTATUS value.",
|
||||||
ntstatusText));
|
ntstatusText));
|
||||||
return;
|
return;
|
||||||
|
@ -49,27 +51,27 @@ namespace TechBot.Library
|
||||||
string description = GetNtstatusDescription(ntstatus);
|
string description = GetNtstatusDescription(ntstatus);
|
||||||
if (description != null)
|
if (description != null)
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
String.Format("{0} is {1}.",
|
String.Format("{0} is {1}.",
|
||||||
ntstatusText,
|
ntstatusText,
|
||||||
description));
|
description));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
String.Format("I don't know about NTSTATUS {0}.",
|
String.Format("I don't know about NTSTATUS {0}.",
|
||||||
ntstatusText));
|
ntstatusText));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Help()
|
public override string Help()
|
||||||
{
|
{
|
||||||
return "!ntstatus <value>";
|
return "!ntstatus <value>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetNtstatusDescription(long ntstatus)
|
public string GetNtstatusDescription(long ntstatus)
|
||||||
{
|
{
|
||||||
XmlElement root = ntstatusXmlDocument.DocumentElement;
|
XmlElement root = base.m_XmlDocument.DocumentElement;
|
||||||
XmlNode node = root.SelectSingleNode(String.Format("Ntstatus[@value='{0}']",
|
XmlNode node = root.SelectSingleNode(String.Format("Ntstatus[@value='{0}']",
|
||||||
ntstatus.ToString("X8")));
|
ntstatus.ToString("X8")));
|
||||||
if (node != null)
|
if (node != null)
|
||||||
|
|
|
@ -1,32 +1,32 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
// Information about this assembly is defined by the following
|
// Information about this assembly is defined by the following
|
||||||
// attributes.
|
// attributes.
|
||||||
//
|
//
|
||||||
// change them to the information which is associated with the assembly
|
// change them to the information which is associated with the assembly
|
||||||
// you compile.
|
// you compile.
|
||||||
|
|
||||||
[assembly: AssemblyTitle("")]
|
[assembly: AssemblyTitle("")]
|
||||||
[assembly: AssemblyDescription("")]
|
[assembly: AssemblyDescription("")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("")]
|
[assembly: AssemblyProduct("")]
|
||||||
[assembly: AssemblyCopyright("")]
|
[assembly: AssemblyCopyright("")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
// The assembly version has following format :
|
// The assembly version has following format :
|
||||||
//
|
//
|
||||||
// Major.Minor.Build.Revision
|
// Major.Minor.Build.Revision
|
||||||
//
|
//
|
||||||
// You can specify all values by your own or you can build default build and revision
|
// You can specify all values by your own or you can build default build and revision
|
||||||
// numbers with the '*' character (the default):
|
// numbers with the '*' character (the default):
|
||||||
|
|
||||||
[assembly: AssemblyVersion("1.0.*")]
|
[assembly: AssemblyVersion("1.0.*")]
|
||||||
|
|
||||||
// The following attributes specify the key for the sign of your assembly. See the
|
// The following attributes specify the key for the sign of your assembly. See the
|
||||||
// .NET Framework documentation for more information about signing.
|
// .NET Framework documentation for more information about signing.
|
||||||
// This is not required, if you don't want signing let these attributes like they're.
|
// This is not required, if you don't want signing let these attributes like they're.
|
||||||
[assembly: AssemblyDelaySign(false)]
|
[assembly: AssemblyDelaySign(false)]
|
||||||
[assembly: AssemblyKeyFile("")]
|
[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
|
namespace TechBot.Library
|
||||||
{
|
{
|
||||||
public class SvnCommand : BaseCommand, ICommand
|
public class SvnCommand : Command
|
||||||
{
|
{
|
||||||
private IServiceOutput serviceOutput;
|
private string m_SvnRoot;
|
||||||
private string svnCommand;
|
|
||||||
|
|
||||||
public SvnCommand(IServiceOutput serviceOutput,
|
public SvnCommand(TechBotService techBot)
|
||||||
string svnCommand)
|
: base(techBot)
|
||||||
{
|
{
|
||||||
this.serviceOutput = serviceOutput;
|
m_SvnRoot = Settings.Default.SVNRoot;
|
||||||
this.svnCommand = svnCommand;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string[] AvailableCommands
|
||||||
|
{
|
||||||
|
get { return new string[] { "svn" }; }
|
||||||
|
}
|
||||||
|
|
||||||
public bool CanHandle(string commandName)
|
public override void Handle(MessageContext context,
|
||||||
{
|
|
||||||
return CanHandle(commandName,
|
|
||||||
new string[] { "svn" });
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Handle(MessageContext context,
|
|
||||||
string commandName,
|
string commandName,
|
||||||
string parameters)
|
string parameters)
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context, string.Format("svn co {0}" , m_SvnRoot));
|
||||||
svnCommand);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Help()
|
public override string Help()
|
||||||
{
|
{
|
||||||
return "!svn";
|
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>
|
<ItemGroup>
|
||||||
<Compile Include="ApiCommand.cs" />
|
<Compile Include="ApiCommand.cs" />
|
||||||
<Compile Include="AssemblyInfo.cs" />
|
|
||||||
<Compile Include="BugCommand.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="ErrorCommand.cs" />
|
||||||
<Compile Include="HelpCommand.cs" />
|
<Compile Include="HelpCommand.cs" />
|
||||||
<Compile Include="HresultCommand.cs" />
|
<Compile Include="HresultCommand.cs" />
|
||||||
|
@ -50,7 +52,15 @@
|
||||||
<Compile Include="MessageContext.cs" />
|
<Compile Include="MessageContext.cs" />
|
||||||
<Compile Include="NtStatusCommand.cs" />
|
<Compile Include="NtStatusCommand.cs" />
|
||||||
<Compile Include="NumberParser.cs" />
|
<Compile Include="NumberParser.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="ReactOSBugUrl.cs" />
|
||||||
<Compile Include="ServiceOutput.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="SvnCommand.cs" />
|
||||||
<Compile Include="TechBotService.cs" />
|
<Compile Include="TechBotService.cs" />
|
||||||
<Compile Include="WinerrorCommand.cs" />
|
<Compile Include="WinerrorCommand.cs" />
|
||||||
|
@ -72,6 +82,10 @@
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Properties\" />
|
<None Include="app.config" />
|
||||||
|
<None Include="Settings.settings">
|
||||||
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</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;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
@ -18,19 +19,19 @@ namespace TechBot.Library
|
||||||
private string wmXml;
|
private string wmXml;
|
||||||
private string svnCommand;
|
private string svnCommand;
|
||||||
private string bugUrl, WineBugUrl, SambaBugUrl;
|
private string bugUrl, WineBugUrl, SambaBugUrl;
|
||||||
private ArrayList commands = new ArrayList();
|
private List<Command> commands = new List<Command>();
|
||||||
|
|
||||||
public TechBotService(IServiceOutput serviceOutput,
|
public TechBotService(IServiceOutput serviceOutput,
|
||||||
string chmPath,
|
string chmPath,
|
||||||
string mainChm,
|
string mainChm)
|
||||||
string ntstatusXml,
|
//string ntstatusXml,
|
||||||
string winerrorXml,
|
//string winerrorXml,
|
||||||
string hresultXml,
|
//string hresultXml,
|
||||||
string wmXml,
|
//string wmXml,
|
||||||
string svnCommand,
|
//string svnCommand,
|
||||||
string bugUrl,
|
//string bugUrl,
|
||||||
string WineBugUrl,
|
//string WineBugUrl,
|
||||||
string SambaBugUrl)
|
//string SambaBugUrl)
|
||||||
{
|
{
|
||||||
this.serviceOutput = serviceOutput;
|
this.serviceOutput = serviceOutput;
|
||||||
this.chmPath = chmPath;
|
this.chmPath = chmPath;
|
||||||
|
@ -44,33 +45,33 @@ namespace TechBot.Library
|
||||||
this.WineBugUrl = WineBugUrl;
|
this.WineBugUrl = WineBugUrl;
|
||||||
this.SambaBugUrl = SambaBugUrl;
|
this.SambaBugUrl = SambaBugUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
commands.Add(new HelpCommand(serviceOutput,
|
commands.Add(new HelpCommand(this));
|
||||||
commands));
|
/*commands.Add(new ApiCommand(serviceOutput,
|
||||||
/*commands.Add(new ApiCommand(serviceOutput,
|
chmPath,
|
||||||
chmPath,
|
mainChm));*/
|
||||||
mainChm));*/
|
commands.Add(new NtStatusCommand(this));
|
||||||
commands.Add(new NtStatusCommand(serviceOutput,
|
commands.Add(new WinerrorCommand(this));
|
||||||
ntstatusXml));
|
commands.Add(new HResultCommand(this));
|
||||||
commands.Add(new WinerrorCommand(serviceOutput,
|
commands.Add(new ErrorCommand(this));
|
||||||
winerrorXml));
|
commands.Add(new WMCommand(this));
|
||||||
commands.Add(new HresultCommand(serviceOutput,
|
commands.Add(new SvnCommand(this));
|
||||||
hresultXml));
|
commands.Add(new ReactOSBugUrl(this));
|
||||||
commands.Add(new ErrorCommand(serviceOutput,
|
commands.Add(new SambaBugUrl(this));
|
||||||
ntstatusXml,
|
commands.Add(new WineBugUrl(this));
|
||||||
winerrorXml,
|
}
|
||||||
hresultXml));
|
|
||||||
commands.Add(new WmCommand(serviceOutput,
|
public IServiceOutput ServiceOutput
|
||||||
wmXml));
|
{
|
||||||
commands.Add(new SvnCommand(serviceOutput,
|
get { return serviceOutput; }
|
||||||
svnCommand));
|
}
|
||||||
commands.Add(new BugCommand(serviceOutput,
|
|
||||||
bugUrl,
|
public IList<Command> Commands
|
||||||
WineBugUrl,
|
{
|
||||||
SambaBugUrl));
|
get { return commands; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InjectMessage(MessageContext context,
|
public void InjectMessage(MessageContext context,
|
||||||
string message)
|
string message)
|
||||||
|
@ -94,23 +95,27 @@ namespace TechBot.Library
|
||||||
message = message.Substring(1).Trim();
|
message = message.Substring(1).Trim();
|
||||||
int index = message.IndexOf(' ');
|
int index = message.IndexOf(' ');
|
||||||
string commandName;
|
string commandName;
|
||||||
string parameters = "";
|
string commandParams = "";
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
commandName = message.Substring(0, index).Trim();
|
commandName = message.Substring(0, index).Trim();
|
||||||
parameters = message.Substring(index).Trim();
|
commandParams = message.Substring(index).Trim();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
commandName = message.Trim();
|
commandName = message.Trim();
|
||||||
|
|
||||||
foreach (ICommand command in commands)
|
foreach (Command command in commands)
|
||||||
{
|
{
|
||||||
if (command.CanHandle(commandName))
|
foreach (string cmd in command.AvailableCommands)
|
||||||
{
|
{
|
||||||
command.Handle(context,
|
if (cmd == commandName)
|
||||||
commandName, parameters);
|
{
|
||||||
return;
|
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
|
namespace TechBot.Library
|
||||||
{
|
{
|
||||||
public class WinerrorCommand : BaseCommand, ICommand
|
public class WinerrorCommand : XmlCommand
|
||||||
{
|
{
|
||||||
private IServiceOutput serviceOutput;
|
public WinerrorCommand(TechBotService techBot)
|
||||||
private string winerrorXml;
|
: base(techBot)
|
||||||
private XmlDocument winerrorXmlDocument;
|
|
||||||
|
|
||||||
public WinerrorCommand(IServiceOutput serviceOutput,
|
|
||||||
string winerrorXml)
|
|
||||||
{
|
{
|
||||||
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 commandName,
|
||||||
string parameters)
|
string parameters)
|
||||||
{
|
{
|
||||||
string winerrorText = parameters;
|
string winerrorText = parameters;
|
||||||
if (winerrorText.Equals(String.Empty))
|
if (winerrorText.Equals(String.Empty))
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
"Please provide a valid System Error Code value.");
|
"Please provide a valid System Error Code value.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +36,7 @@ namespace TechBot.Library
|
||||||
long winerror = np.Parse(winerrorText);
|
long winerror = np.Parse(winerrorText);
|
||||||
if (np.Error)
|
if (np.Error)
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
String.Format("{0} is not a valid System Error Code value.",
|
String.Format("{0} is not a valid System Error Code value.",
|
||||||
winerrorText));
|
winerrorText));
|
||||||
return;
|
return;
|
||||||
|
@ -49,27 +45,27 @@ namespace TechBot.Library
|
||||||
string description = GetWinerrorDescription(winerror);
|
string description = GetWinerrorDescription(winerror);
|
||||||
if (description != null)
|
if (description != null)
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
String.Format("{0} is {1}.",
|
String.Format("{0} is {1}.",
|
||||||
winerrorText,
|
winerrorText,
|
||||||
description));
|
description));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
String.Format("I don't know about System Error Code {0}.",
|
String.Format("I don't know about System Error Code {0}.",
|
||||||
winerrorText));
|
winerrorText));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Help()
|
public override string Help()
|
||||||
{
|
{
|
||||||
return "!winerror <value>";
|
return "!winerror <value>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetWinerrorDescription(long winerror)
|
public string GetWinerrorDescription(long winerror)
|
||||||
{
|
{
|
||||||
XmlElement root = winerrorXmlDocument.DocumentElement;
|
XmlElement root = base.m_XmlDocument.DocumentElement;
|
||||||
XmlNode node = root.SelectSingleNode(String.Format("Winerror[@value='{0}']",
|
XmlNode node = root.SelectSingleNode(String.Format("Winerror[@value='{0}']",
|
||||||
winerror));
|
winerror));
|
||||||
if (node != null)
|
if (node != null)
|
||||||
|
|
|
@ -3,35 +3,31 @@ using System.Xml;
|
||||||
|
|
||||||
namespace TechBot.Library
|
namespace TechBot.Library
|
||||||
{
|
{
|
||||||
public class WmCommand : BaseCommand, ICommand
|
public class WMCommand : XmlCommand
|
||||||
{
|
{
|
||||||
private IServiceOutput serviceOutput;
|
public WMCommand(TechBotService techBot)
|
||||||
private string wmXml;
|
: base(techBot)
|
||||||
private XmlDocument wmXmlDocument;
|
|
||||||
|
|
||||||
public WmCommand(IServiceOutput serviceOutput,
|
|
||||||
string wmXml)
|
|
||||||
{
|
{
|
||||||
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)
|
public override string[] AvailableCommands
|
||||||
{
|
{
|
||||||
return CanHandle(commandName,
|
get { return new string[] { "wm" }; }
|
||||||
new string[] { "wm" });
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void Handle(MessageContext context,
|
public override void Handle(MessageContext context,
|
||||||
string commandName,
|
string commandName,
|
||||||
string parameters)
|
string parameters)
|
||||||
{
|
{
|
||||||
string wmText = parameters;
|
string wmText = parameters;
|
||||||
if (wmText.Equals(String.Empty))
|
if (wmText.Equals(String.Empty))
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
"Please provide a valid window message value or name.");
|
"Please provide a valid window message value or name.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -51,27 +47,27 @@ namespace TechBot.Library
|
||||||
|
|
||||||
if (output != null)
|
if (output != null)
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
String.Format("{0} is {1}.",
|
String.Format("{0} is {1}.",
|
||||||
wmText,
|
wmText,
|
||||||
output));
|
output));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
serviceOutput.WriteLine(context,
|
TechBot.ServiceOutput.WriteLine(context,
|
||||||
String.Format("I don't know about window message {0}.",
|
String.Format("I don't know about window message {0}.",
|
||||||
wmText));
|
wmText));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Help()
|
public override string Help()
|
||||||
{
|
{
|
||||||
return "!wm <value> or !wm <name>";
|
return "!wm <value> or !wm <name>";
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetWmDescription(long wm)
|
private string GetWmDescription(long wm)
|
||||||
{
|
{
|
||||||
XmlElement root = wmXmlDocument.DocumentElement;
|
XmlElement root = base.m_XmlDocument.DocumentElement;
|
||||||
XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@value='{0}']",
|
XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@value='{0}']",
|
||||||
wm));
|
wm));
|
||||||
if (node != null)
|
if (node != null)
|
||||||
|
@ -87,7 +83,7 @@ namespace TechBot.Library
|
||||||
|
|
||||||
private string GetWmNumber(string wmName)
|
private string GetWmNumber(string wmName)
|
||||||
{
|
{
|
||||||
XmlElement root = wmXmlDocument.DocumentElement;
|
XmlElement root = base.m_XmlDocument.DocumentElement;
|
||||||
XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@text='{0}']",
|
XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@text='{0}']",
|
||||||
wmName));
|
wmName));
|
||||||
if (node != null)
|
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,
|
IRCBotPassword,
|
||||||
ChmPath,
|
ChmPath,
|
||||||
MainChm,
|
MainChm,
|
||||||
NtstatusXml,
|
//NtstatusXml,
|
||||||
WinerrorXml,
|
//WinerrorXml,
|
||||||
HresultXml,
|
//HresultXml,
|
||||||
WmXml,
|
//WmXml,
|
||||||
SvnCommand,
|
//SvnCommand,
|
||||||
BugUrl,
|
BugUrl,
|
||||||
WineBugUrl,
|
WineBugUrl,
|
||||||
SambaBugUrl);
|
SambaBugUrl);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>TechBot</RootNamespace>
|
<RootNamespace>TechBot</RootNamespace>
|
||||||
<AssemblyName>TechBot</AssemblyName>
|
<AssemblyName>TechBot</AssemblyName>
|
||||||
|
<StartupObject>TechBot.TechBotService</StartupObject>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
|
Loading…
Reference in a new issue