From 82b5e2eb8bb087d52c1f5a7199be1974a4b20d14 Mon Sep 17 00:00:00 2001 From: Marc Piulachs Date: Mon, 10 Dec 2007 19:08:13 +0000 Subject: [PATCH] * 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 --- irc/TechBot/TechBot.Console/App.config | 5 - irc/TechBot/TechBot.Console/Main.cs | 28 +++--- .../TechBot.Console/TechBot.Console.csproj | 3 + irc/TechBot/TechBot.Library/ApiCommand.cs | 38 ++++---- irc/TechBot/TechBot.Library/BugCommand.cs | 97 ++++++++----------- irc/TechBot/TechBot.Library/Command.cs | 53 ++++++++++ .../Commands/Base/XmlCommand.cs | 26 +++++ irc/TechBot/TechBot.Library/Default.build | 24 ----- irc/TechBot/TechBot.Library/ErrorCommand.cs | 44 +++++---- irc/TechBot/TechBot.Library/HelpCommand.cs | 51 +++++----- irc/TechBot/TechBot.Library/HresultCommand.cs | 40 ++++---- irc/TechBot/TechBot.Library/ICommand.cs | 29 ------ irc/TechBot/TechBot.Library/IrcService.cs | 91 ++++++++--------- .../TechBot.Library/NtStatusCommand.cs | 44 +++++---- .../{ => Properties}/AssemblyInfo.cs | 64 ++++++------ irc/TechBot/TechBot.Library/ReactOSBugUrl.cs | 29 ++++++ irc/TechBot/TechBot.Library/SambaBugUrl.cs | 29 ++++++ .../TechBot.Library/Settings.Designer.cs | 71 ++++++++++++++ irc/TechBot/TechBot.Library/Settings.cs | 28 ++++++ irc/TechBot/TechBot.Library/Settings.settings | 21 ++++ irc/TechBot/TechBot.Library/SvnCommand.cs | 32 +++--- .../TechBot.Library/TechBot.Library.cmbx | 16 --- .../TechBot.Library/TechBot.Library.csproj | 18 +++- .../TechBot.Library/TechBot.Library.prjx | 43 -------- irc/TechBot/TechBot.Library/TechBotService.cs | 97 ++++++++++--------- irc/TechBot/TechBot.Library/WineBugUrl.cs | 29 ++++++ .../TechBot.Library/WinerrorCommand.cs | 46 ++++----- irc/TechBot/TechBot.Library/WmCommand.cs | 44 ++++----- irc/TechBot/TechBot.Library/app.config | 27 ++++++ irc/TechBot/TechBot/ServiceThread.cs | 10 +- irc/TechBot/TechBot/TechBot.csproj | 1 + 31 files changed, 687 insertions(+), 491 deletions(-) create mode 100644 irc/TechBot/TechBot.Library/Command.cs create mode 100644 irc/TechBot/TechBot.Library/Commands/Base/XmlCommand.cs delete mode 100644 irc/TechBot/TechBot.Library/Default.build delete mode 100644 irc/TechBot/TechBot.Library/ICommand.cs rename irc/TechBot/TechBot.Library/{ => Properties}/AssemblyInfo.cs (97%) create mode 100644 irc/TechBot/TechBot.Library/ReactOSBugUrl.cs create mode 100644 irc/TechBot/TechBot.Library/SambaBugUrl.cs create mode 100644 irc/TechBot/TechBot.Library/Settings.Designer.cs create mode 100644 irc/TechBot/TechBot.Library/Settings.cs create mode 100644 irc/TechBot/TechBot.Library/Settings.settings delete mode 100644 irc/TechBot/TechBot.Library/TechBot.Library.cmbx delete mode 100644 irc/TechBot/TechBot.Library/TechBot.Library.prjx create mode 100644 irc/TechBot/TechBot.Library/WineBugUrl.cs create mode 100644 irc/TechBot/TechBot.Library/app.config diff --git a/irc/TechBot/TechBot.Console/App.config b/irc/TechBot/TechBot.Console/App.config index a7d7eeb7a5f..f6678d802b3 100644 --- a/irc/TechBot/TechBot.Console/App.config +++ b/irc/TechBot/TechBot.Console/App.config @@ -8,11 +8,6 @@ - - - - - diff --git a/irc/TechBot/TechBot.Console/Main.cs b/irc/TechBot/TechBot.Console/Main.cs index 8a291725360..6826558a7c6 100644 --- a/irc/TechBot/TechBot.Console/Main.cs +++ b/irc/TechBot/TechBot.Console/Main.cs @@ -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) { diff --git a/irc/TechBot/TechBot.Console/TechBot.Console.csproj b/irc/TechBot/TechBot.Console/TechBot.Console.csproj index bc18afbc975..1044ed8c029 100644 --- a/irc/TechBot/TechBot.Console/TechBot.Console.csproj +++ b/irc/TechBot/TechBot.Console/TechBot.Console.csproj @@ -53,6 +53,9 @@ TechBot.Library + + + diff --git a/irc/TechBot/TechBot.Library/ApiCommand.cs b/irc/TechBot/TechBot.Library/ApiCommand.cs index b6aab953f09..c0f3cc1d5c7 100644 --- a/irc/TechBot/TechBot.Library/ApiCommand.cs +++ b/irc/TechBot/TechBot.Library/ApiCommand.cs @@ -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 "; } @@ -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."); } diff --git a/irc/TechBot/TechBot.Library/BugCommand.cs b/irc/TechBot/TechBot.Library/BugCommand.cs index afba6800a33..99427388eb9 100644 --- a/irc/TechBot/TechBot.Library/BugCommand.cs +++ b/irc/TechBot/TechBot.Library/BugCommand.cs @@ -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 "; - } + /* + 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; } } } diff --git a/irc/TechBot/TechBot.Library/Command.cs b/irc/TechBot/TechBot.Library/Command.cs new file mode 100644 index 00000000000..b6ae0a14e58 --- /dev/null +++ b/irc/TechBot/TechBot.Library/Command.cs @@ -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"; + } + } +} diff --git a/irc/TechBot/TechBot.Library/Commands/Base/XmlCommand.cs b/irc/TechBot/TechBot.Library/Commands/Base/XmlCommand.cs new file mode 100644 index 00000000000..f5d39df1ab3 --- /dev/null +++ b/irc/TechBot/TechBot.Library/Commands/Base/XmlCommand.cs @@ -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; } + } + } +} \ No newline at end of file diff --git a/irc/TechBot/TechBot.Library/Default.build b/irc/TechBot/TechBot.Library/Default.build deleted file mode 100644 index 0b20ec3ff50..00000000000 --- a/irc/TechBot/TechBot.Library/Default.build +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/irc/TechBot/TechBot.Library/ErrorCommand.cs b/irc/TechBot/TechBot.Library/ErrorCommand.cs index 35b7789b71e..3d7a7cf8c1a 100644 --- a/irc/TechBot/TechBot.Library/ErrorCommand.cs +++ b/irc/TechBot/TechBot.Library/ErrorCommand.cs @@ -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 "; } diff --git a/irc/TechBot/TechBot.Library/HelpCommand.cs b/irc/TechBot/TechBot.Library/HelpCommand.cs index 4e5ce731fb2..b007a7e5cc3 100644 --- a/irc/TechBot/TechBot.Library/HelpCommand.cs +++ b/irc/TechBot/TechBot.Library/HelpCommand.cs @@ -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"; } diff --git a/irc/TechBot/TechBot.Library/HresultCommand.cs b/irc/TechBot/TechBot.Library/HresultCommand.cs index 32b76672b30..c8842cdbb98 100644 --- a/irc/TechBot/TechBot.Library/HresultCommand.cs +++ b/irc/TechBot/TechBot.Library/HresultCommand.cs @@ -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 "; } 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) diff --git a/irc/TechBot/TechBot.Library/ICommand.cs b/irc/TechBot/TechBot.Library/ICommand.cs deleted file mode 100644 index b88c911e70a..00000000000 --- a/irc/TechBot/TechBot.Library/ICommand.cs +++ /dev/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; - } - } -} diff --git a/irc/TechBot/TechBot.Library/IrcService.cs b/irc/TechBot/TechBot.Library/IrcService.cs index 2e7229f37cd..bfd2867df36 100644 --- a/irc/TechBot/TechBot.Library/IrcService.cs +++ b/irc/TechBot/TechBot.Library/IrcService.cs @@ -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; diff --git a/irc/TechBot/TechBot.Library/NtStatusCommand.cs b/irc/TechBot/TechBot.Library/NtStatusCommand.cs index 034df26cd2a..4833c57487d 100644 --- a/irc/TechBot/TechBot.Library/NtStatusCommand.cs +++ b/irc/TechBot/TechBot.Library/NtStatusCommand.cs @@ -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 "; } 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) diff --git a/irc/TechBot/TechBot.Library/AssemblyInfo.cs b/irc/TechBot/TechBot.Library/Properties/AssemblyInfo.cs similarity index 97% rename from irc/TechBot/TechBot.Library/AssemblyInfo.cs rename to irc/TechBot/TechBot.Library/Properties/AssemblyInfo.cs index dbacda112e8..af4e2756b62 100644 --- a/irc/TechBot/TechBot.Library/AssemblyInfo.cs +++ b/irc/TechBot/TechBot.Library/Properties/AssemblyInfo.cs @@ -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("")] diff --git a/irc/TechBot/TechBot.Library/ReactOSBugUrl.cs b/irc/TechBot/TechBot.Library/ReactOSBugUrl.cs new file mode 100644 index 00000000000..daa0e5c5c73 --- /dev/null +++ b/irc/TechBot/TechBot.Library/ReactOSBugUrl.cs @@ -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 "; + } + } +} diff --git a/irc/TechBot/TechBot.Library/SambaBugUrl.cs b/irc/TechBot/TechBot.Library/SambaBugUrl.cs new file mode 100644 index 00000000000..6b70fac0aeb --- /dev/null +++ b/irc/TechBot/TechBot.Library/SambaBugUrl.cs @@ -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 "; + } + } +} diff --git a/irc/TechBot/TechBot.Library/Settings.Designer.cs b/irc/TechBot/TechBot.Library/Settings.Designer.cs new file mode 100644 index 00000000000..4a88a841664 --- /dev/null +++ b/irc/TechBot/TechBot.Library/Settings.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +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"])); + } + } + } +} diff --git a/irc/TechBot/TechBot.Library/Settings.cs b/irc/TechBot/TechBot.Library/Settings.cs new file mode 100644 index 00000000000..e1543b0e887 --- /dev/null +++ b/irc/TechBot/TechBot.Library/Settings.cs @@ -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. + } + } +} diff --git a/irc/TechBot/TechBot.Library/Settings.settings b/irc/TechBot/TechBot.Library/Settings.settings new file mode 100644 index 00000000000..65c52e18b81 --- /dev/null +++ b/irc/TechBot/TechBot.Library/Settings.settings @@ -0,0 +1,21 @@ + + + + + + C:\Ros\current\irc\TechBot\Resources\ntstatus.xml + + + C:\Ros\current\irc\TechBot\Resources\winerror.xml + + + C:\Ros\current\irc\TechBot\Resources\hresult.xml + + + C:\Ros\current\irc\TechBot\Resources\wm.xml + + + svn://svn.reactos.org/trunk/reactos + + + \ No newline at end of file diff --git a/irc/TechBot/TechBot.Library/SvnCommand.cs b/irc/TechBot/TechBot.Library/SvnCommand.cs index 7b2fce56cee..aef633b2b7b 100644 --- a/irc/TechBot/TechBot.Library/SvnCommand.cs +++ b/irc/TechBot/TechBot.Library/SvnCommand.cs @@ -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"; } diff --git a/irc/TechBot/TechBot.Library/TechBot.Library.cmbx b/irc/TechBot/TechBot.Library/TechBot.Library.cmbx deleted file mode 100644 index 6b132a5e2f6..00000000000 --- a/irc/TechBot/TechBot.Library/TechBot.Library.cmbx +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Library/TechBot.Library.csproj b/irc/TechBot/TechBot.Library/TechBot.Library.csproj index 84e3061274c..897088404d9 100644 --- a/irc/TechBot/TechBot.Library/TechBot.Library.csproj +++ b/irc/TechBot/TechBot.Library/TechBot.Library.csproj @@ -40,8 +40,10 @@ --> - + + + @@ -50,7 +52,15 @@ + + + + + True + True + Settings.settings + @@ -72,6 +82,10 @@ - + + + SettingsSingleFileGenerator + Settings.Designer.cs + \ No newline at end of file diff --git a/irc/TechBot/TechBot.Library/TechBot.Library.prjx b/irc/TechBot/TechBot.Library/TechBot.Library.prjx deleted file mode 100644 index cf716a49996..00000000000 --- a/irc/TechBot/TechBot.Library/TechBot.Library.prjx +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/irc/TechBot/TechBot.Library/TechBotService.cs b/irc/TechBot/TechBot.Library/TechBotService.cs index f727c33fc00..d40ab91e2c7 100644 --- a/irc/TechBot/TechBot.Library/TechBotService.cs +++ b/irc/TechBot/TechBot.Library/TechBotService.cs @@ -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 commands = new List(); 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 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; + } + } } } } diff --git a/irc/TechBot/TechBot.Library/WineBugUrl.cs b/irc/TechBot/TechBot.Library/WineBugUrl.cs new file mode 100644 index 00000000000..94464a1fdc8 --- /dev/null +++ b/irc/TechBot/TechBot.Library/WineBugUrl.cs @@ -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 "; + } + } +} diff --git a/irc/TechBot/TechBot.Library/WinerrorCommand.cs b/irc/TechBot/TechBot.Library/WinerrorCommand.cs index 9fd79c425b1..512157575a8 100644 --- a/irc/TechBot/TechBot.Library/WinerrorCommand.cs +++ b/irc/TechBot/TechBot.Library/WinerrorCommand.cs @@ -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 "; } 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) diff --git a/irc/TechBot/TechBot.Library/WmCommand.cs b/irc/TechBot/TechBot.Library/WmCommand.cs index 0809c3e81fe..31d670109ae 100644 --- a/irc/TechBot/TechBot.Library/WmCommand.cs +++ b/irc/TechBot/TechBot.Library/WmCommand.cs @@ -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 or !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}']", 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) diff --git a/irc/TechBot/TechBot.Library/app.config b/irc/TechBot/TechBot.Library/app.config new file mode 100644 index 00000000000..c2ac070e60e --- /dev/null +++ b/irc/TechBot/TechBot.Library/app.config @@ -0,0 +1,27 @@ + + + + +
+ + + + + + C:\Ros\current\irc\TechBot\Resources\ntstatus.xml + + + C:\Ros\current\irc\TechBot\Resources\winerror.xml + + + C:\Ros\current\irc\TechBot\Resources\hresult.xml + + + C:\Ros\current\irc\TechBot\Resources\wm.xml + + + svn://svn.reactos.org/trunk/reactos + + + + \ No newline at end of file diff --git a/irc/TechBot/TechBot/ServiceThread.cs b/irc/TechBot/TechBot/ServiceThread.cs index 48b30d2ae75..9e22beb25fb 100644 --- a/irc/TechBot/TechBot/ServiceThread.cs +++ b/irc/TechBot/TechBot/ServiceThread.cs @@ -58,11 +58,11 @@ namespace TechBot IRCBotPassword, ChmPath, MainChm, - NtstatusXml, - WinerrorXml, - HresultXml, - WmXml, - SvnCommand, + //NtstatusXml, + //WinerrorXml, + //HresultXml, + //WmXml, + //SvnCommand, BugUrl, WineBugUrl, SambaBugUrl); diff --git a/irc/TechBot/TechBot/TechBot.csproj b/irc/TechBot/TechBot/TechBot.csproj index 604d2d4c801..692e4739541 100644 --- a/irc/TechBot/TechBot/TechBot.csproj +++ b/irc/TechBot/TechBot/TechBot.csproj @@ -10,6 +10,7 @@ Properties TechBot TechBot + TechBot.TechBotService true