* refactor the code to make it more OOP and extensible
authorMarc Piulachs <marc.piulachs@live.com>
Mon, 10 Dec 2007 19:08:13 +0000 (19:08 +0000)
committerMarc Piulachs <marc.piulachs@live.com>
Mon, 10 Dec 2007 19:08:13 +0000 (19:08 +0000)
* remove old outdated SD project files
* make it use some .NET 2.0 features as generic collections and settings

svn path=/trunk/; revision=31130

31 files changed:
irc/TechBot/TechBot.Console/App.config
irc/TechBot/TechBot.Console/Main.cs
irc/TechBot/TechBot.Console/TechBot.Console.csproj
irc/TechBot/TechBot.Library/ApiCommand.cs
irc/TechBot/TechBot.Library/BugCommand.cs
irc/TechBot/TechBot.Library/Command.cs [new file with mode: 0644]
irc/TechBot/TechBot.Library/Commands/Base/XmlCommand.cs [new file with mode: 0644]
irc/TechBot/TechBot.Library/Default.build [deleted file]
irc/TechBot/TechBot.Library/ErrorCommand.cs
irc/TechBot/TechBot.Library/HelpCommand.cs
irc/TechBot/TechBot.Library/HresultCommand.cs
irc/TechBot/TechBot.Library/ICommand.cs [deleted file]
irc/TechBot/TechBot.Library/IrcService.cs
irc/TechBot/TechBot.Library/NtStatusCommand.cs
irc/TechBot/TechBot.Library/Properties/AssemblyInfo.cs [moved from irc/TechBot/TechBot.Library/AssemblyInfo.cs with 97% similarity]
irc/TechBot/TechBot.Library/ReactOSBugUrl.cs [new file with mode: 0644]
irc/TechBot/TechBot.Library/SambaBugUrl.cs [new file with mode: 0644]
irc/TechBot/TechBot.Library/Settings.Designer.cs [new file with mode: 0644]
irc/TechBot/TechBot.Library/Settings.cs [new file with mode: 0644]
irc/TechBot/TechBot.Library/Settings.settings [new file with mode: 0644]
irc/TechBot/TechBot.Library/SvnCommand.cs
irc/TechBot/TechBot.Library/TechBot.Library.cmbx [deleted file]
irc/TechBot/TechBot.Library/TechBot.Library.csproj
irc/TechBot/TechBot.Library/TechBot.Library.prjx [deleted file]
irc/TechBot/TechBot.Library/TechBotService.cs
irc/TechBot/TechBot.Library/WineBugUrl.cs [new file with mode: 0644]
irc/TechBot/TechBot.Library/WinerrorCommand.cs
irc/TechBot/TechBot.Library/WmCommand.cs
irc/TechBot/TechBot.Library/app.config [new file with mode: 0644]
irc/TechBot/TechBot/ServiceThread.cs
irc/TechBot/TechBot/TechBot.csproj

index a7d7eeb..f6678d8 100644 (file)
@@ -8,11 +8,6 @@
                <add key="IRCBotPassword" value="MyPassword" />\r
                <add key="ChmPath" value="C:\IRC\TechBot\CHM" />\r
                <add key="MainChm" value="kmarch.chm" />\r
-               <add key="NtstatusXml" value="ntstatus.xml" />\r
-               <add key="WinerrorXml" value="winerror.xml" />\r
-               <add key="HresultXml" value="hresult.xml" />\r
-               <add key="WmXml" value="wm.xml" />\r
-               <add key="SvnCommand" value="svn co svn://svn.reactos.org/trunk/reactos" />\r
                <add key="BugUrl" value="http://www.reactos.org/bugzilla/show_bug.cgi?id={0}" />\r
                <add key="WineBugUrl" value="http://bugs.winehq.org/show_bug.cgi?id={0}" />\r
                <add key="SambaBugUrl" value="https://bugzilla.samba.org/show_bug.cgi?id={0}" />\r
index 8a29172..6826558 100644 (file)
@@ -217,11 +217,11 @@ namespace TechBot.Console
                                                               IRCBotPassword,\r
                                                               ChmPath,\r
                                                               MainChm,\r
-                                                              NtstatusXml,\r
-                                                              WinerrorXml,\r
-                                                              HresultXml,\r
-                                                              WmXml,\r
-                                                              SvnCommand,\r
+                                                   //NtstatusXml,\r
+                                                   //WinerrorXml,\r
+                                                   //HresultXml,\r
+                                                   //WmXml,\r
+                                                              //SvnCommand,\r
                                                               BugUrl,\r
                                                               WineBugUrl,\r
                                                               SambaBugUrl);\r
@@ -239,15 +239,15 @@ namespace TechBot.Console
                        System.Console.WriteLine("TechBot running console service...");\r
                        TechBotService service = new TechBotService(new ConsoleServiceOutput(),\r
                                                                    ChmPath,\r
-                                                                   MainChm,\r
-                                                                   NtstatusXml,\r
-                                                                   WinerrorXml,\r
-                                                                   HresultXml,\r
-                                                                   WmXml,\r
-                                                                   SvnCommand,\r
-                                                                   BugUrl,\r
-                                                                   WineBugUrl,\r
-                                                                   SambaBugUrl);\r
+                                                                   MainChm);\r
+                                                        //NtstatusXml,\r
+                                                        //WinerrorXml,\r
+                                                        //HresultXml,\r
+                                                        //WmXml,\r
+                                                                   //SvnCommand,\r
+                                                        //BugUrl,\r
+                                                        //WineBugUrl,\r
+                                                        //SambaBugUrl);\r
                        service.Run();\r
                        while (true)\r
                        {\r
index bc18afb..1044ed8 100644 (file)
@@ -53,6 +53,9 @@
       <Name>TechBot.Library</Name>
     </ProjectReference>
   </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
   <ItemGroup>
     <Folder Include="Properties\" />
   </ItemGroup>
index b6aab95..c0f3cc1 100644 (file)
@@ -7,22 +7,17 @@ using HtmlHelp.ChmDecoding;
 \r
 namespace TechBot.Library\r
 {\r
-       public class ApiCommand : BaseCommand, ICommand\r
+       public class ApiCommand : Command\r
        {\r
                private const bool IsVerbose = false;\r
 \r
                private HtmlHelpSystem chm;\r
-               private IServiceOutput serviceOutput;\r
                private string chmPath;\r
                private string mainChm;\r
-               \r
-               public ApiCommand(IServiceOutput serviceOutput,\r
-                                 string chmPath,\r
-                                 string mainChm)\r
+\r
+        public ApiCommand(TechBotService techBot)\r
+            : base(techBot)\r
                {\r
-                       this.serviceOutput = serviceOutput;\r
-                       this.chmPath = chmPath;\r
-                       this.mainChm = mainChm;\r
                        Run();\r
                }\r
                \r
@@ -30,7 +25,7 @@ namespace TechBot.Library
                                            string message)\r
                {\r
                        if (IsVerbose)\r
-                               serviceOutput.WriteLine(context,\r
+                TechBot.ServiceOutput.WriteLine(context,\r
                                                        message);\r
                }\r
 \r
@@ -65,14 +60,21 @@ namespace TechBot.Library
                        Console.WriteLine(String.Format("Loaded {0} CHMs",\r
                                                        chm.FileList.Length));\r
                }\r
-               \r
+\r
+        public override string[] AvailableCommands\r
+        {\r
+            get { return new string[] { "api" }; }\r
+        }\r
+\r
+        /*\r
                public bool CanHandle(string commandName)\r
                {\r
                        return CanHandle(commandName,\r
                                         new string[] { "api" });\r
                }\r
+*/\r
                \r
-               public void Handle(MessageContext context,\r
+               public override void Handle(MessageContext context,\r
                                   string commandName,\r
                                   string parameters)\r
                {\r
@@ -82,8 +84,8 @@ namespace TechBot.Library
                                Search(context,\r
                                       parameters);\r
                }\r
-               \r
-               public string Help()\r
+\r
+        public override string Help()\r
                {\r
                        return "!api <apiname>";\r
                }\r
@@ -177,7 +179,7 @@ namespace TechBot.Library
                        if (prototype == null || prototype.Trim().Equals(String.Empty))\r
                                return false;\r
                        string formattedPrototype = FormatPrototype(prototype);\r
-                       serviceOutput.WriteLine(context,\r
+            TechBot.ServiceOutput.WriteLine(context,\r
                                                formattedPrototype);\r
                        return true;\r
                }\r
@@ -203,7 +205,7 @@ namespace TechBot.Library
                                        if (prototype == null || prototype.Trim().Equals(String.Empty))\r
                                                continue;\r
                                        string formattedPrototype = FormatPrototype(prototype);\r
-                                       serviceOutput.WriteLine(context,\r
+                    TechBot.ServiceOutput.WriteLine(context,\r
                                                                formattedPrototype);\r
                                        return true;\r
                                }\r
@@ -214,14 +216,14 @@ namespace TechBot.Library
                private void DisplayNoResult(MessageContext context,\r
                                             string keyword)\r
                {\r
-                       serviceOutput.WriteLine(context,\r
+            TechBot.ServiceOutput.WriteLine(context,\r
                                                String.Format("I don't know about keyword {0}",\r
                                                              keyword));\r
                }\r
 \r
                private void DisplayNoKeyword(MessageContext context)\r
                {\r
-                       serviceOutput.WriteLine(context,\r
+            TechBot.ServiceOutput.WriteLine(context,\r
                                                "Please give me a keyword.");\r
                }\r
 \r
index afba680..9942738 100644 (file)
@@ -2,70 +2,49 @@ using System;
 \r
 namespace TechBot.Library\r
 {\r
-       public class BugCommand : BaseCommand, ICommand\r
+       public abstract class BugCommand : Command//, ICommand\r
        {\r
-               private IServiceOutput serviceOutput;\r
-               private string RosBugUrl;\r
-               private string WineBugUrl;\r
-               private string SambaBugUrl;\r
-\r
-               public BugCommand(IServiceOutput serviceOutput,\r
-                                 string RosBugUrl,\r
-                                 string WineBugUrl,\r
-                                 string SambaBugUrl)\r
-               {\r
-                       this.serviceOutput = serviceOutput;\r
-                       this.RosBugUrl = RosBugUrl;\r
-                       this.WineBugUrl = WineBugUrl;\r
-                       this.SambaBugUrl = SambaBugUrl;\r
-               }\r
-               \r
-               public bool CanHandle(string commandName)\r
+               public BugCommand(TechBotService techBot) : base (techBot)\r
                {\r
-                       return CanHandle(commandName,\r
-                                        new string[] { "bug" });\r
                }\r
 \r
-               public void Handle(MessageContext context,\r
-                                  string commandName,\r
-                                  string parameters)\r
-               {\r
-                       string bugText = parameters;\r
-                       if (bugText.Equals(String.Empty))\r
-                       {\r
-                               serviceOutput.WriteLine(context,\r
-                                                       "Please provide a valid bug number.");\r
-                               return;\r
-                       }\r
+        public override void Handle(MessageContext context,\r
+                           string commandName,\r
+                           string parameters)\r
+        {\r
+            string bugText = parameters;\r
+            if (bugText.Equals(String.Empty))\r
+            {\r
+                TechBot.ServiceOutput.WriteLine(context,\r
+                                        "Please provide a valid bug number.");\r
+                return;\r
+            }\r
 \r
-                       NumberParser np = new NumberParser();\r
-                       long bug = np.Parse(bugText);\r
-                       if (np.Error)\r
-                       {\r
-                               serviceOutput.WriteLine(context,\r
-                                                       String.Format("{0} is not a valid bug number.",\r
-                                                                     bugText));\r
-                               return;\r
-                       }\r
-                       \r
-                       string bugUrl = this.RosBugUrl;\r
+            NumberParser np = new NumberParser();\r
+            long bug = np.Parse(bugText);\r
+            if (np.Error)\r
+            {\r
+                TechBot.ServiceOutput.WriteLine(context,\r
+                                        String.Format("{0} is not a valid bug number.",\r
+                                                      bugText));\r
+                return;\r
+            }\r
 \r
-                       if (context is ChannelMessageContext)\r
-                       {\r
-                               ChannelMessageContext channelContext = context as ChannelMessageContext;\r
-                               if (channelContext.Channel.Name == "winehackers")\r
-                                       bugUrl = this.WineBugUrl;\r
-                               else if (channelContext.Channel.Name == "samba-technical")\r
-                                       bugUrl = this.SambaBugUrl;\r
-                       }\r
-                       \r
-                       serviceOutput.WriteLine(context,\r
-                                               String.Format(bugUrl, bug));\r
-               }\r
-               \r
-               public string Help()\r
-               {\r
-                       return "!bug <number>";\r
-               }\r
+            /*\r
+            string bugUrl = this.RosBugUrl;\r
+\r
+            if (context is ChannelMessageContext)\r
+            {\r
+                ChannelMessageContext channelContext = context as ChannelMessageContext;\r
+                if (channelContext.Channel.Name == "winehackers")\r
+                    bugUrl = this.WineBugUrl;\r
+                else if (channelContext.Channel.Name == "samba-technical")\r
+                    bugUrl = this.SambaBugUrl;\r
+            }*/\r
+\r
+            TechBot.ServiceOutput.WriteLine(context, String.Format(BugUrl, bug));\r
+        }\r
+\r
+        protected abstract string BugUrl { get; }\r
        }\r
 }\r
diff --git a/irc/TechBot/TechBot.Library/Command.cs b/irc/TechBot/TechBot.Library/Command.cs
new file mode 100644 (file)
index 0000000..b6ae0a1
--- /dev/null
@@ -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 (file)
index 0000000..f5d39df
--- /dev/null
@@ -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 (file)
index 0b20ec3..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0"?>\r
-<project name="TechBot.Library" default="build">\r
-\r
-       <property name="output.dir" value="..\bin" />\r
-\r
-       <target name="build" description="Build component">\r
-               <mkdir dir="${output.dir}" />\r
-               <csc target="library"\r
-                       output="${output.dir}\TechBot.Library.dll"\r
-                       optimize="true"\r
-                       debug="true"\r
-                       doc="${output.dir}\TechBot.Library.xml"\r
-                       warninglevel="0">\r
-                       <sources>\r
-                               <include name="*.cs" />\r
-                       </sources>\r
-                       <references>\r
-                               <include name="${output.dir}\CHMLibrary.dll" />\r
-                               <include name="${output.dir}\TechBot.IRCLibrary.dll" />\r
-                       </references>\r
-               </csc>\r
-       </target>\r
-\r
-</project>\r
index 35b7789..3d7a7cf 100644 (file)
@@ -4,30 +4,32 @@ using System.Collections;
 \r
 namespace TechBot.Library\r
 {\r
-       public class ErrorCommand : BaseCommand, ICommand\r
+       public class ErrorCommand : Command\r
        {\r
-               private IServiceOutput serviceOutput;\r
                private NtStatusCommand ntStatus;\r
                private WinerrorCommand winerror;\r
-               private HresultCommand hresult;\r
+               private HResultCommand hresult;\r
 \r
-               public ErrorCommand(IServiceOutput serviceOutput, string ntstatusXml,\r
-                                                                       string winerrorXml, string hresultXml)\r
+        public ErrorCommand(TechBotService techBot)\r
+            : base(techBot)\r
                {\r
-                       this.serviceOutput = serviceOutput;\r
-                       this.ntStatus = new NtStatusCommand(serviceOutput,\r
-                                                                                        ntstatusXml);\r
-                       this.winerror = new WinerrorCommand(serviceOutput,\r
-                                                                                       winerrorXml);\r
-                       this.hresult = new HresultCommand(serviceOutput,\r
-                                                                                       hresultXml);\r
+                       this.ntStatus = new NtStatusCommand(techBot);\r
+                       this.winerror = new WinerrorCommand(techBot);\r
+                       this.hresult = new HResultCommand(techBot);\r
                }\r
                \r
+        /*\r
                public bool CanHandle(string commandName)\r
                {\r
                        return CanHandle(commandName,\r
                                         new string[] { "error" });\r
                }\r
+        */\r
+\r
+        public override string[] AvailableCommands\r
+        {\r
+            get { return new string[] { "error" }; }\r
+        }\r
 \r
                private static int GetSeverity(long error)\r
                {\r
@@ -79,14 +81,14 @@ namespace TechBot.Library
                        return code.ToString();\r
                }\r
 \r
-               public void Handle(MessageContext context,\r
+               public override  void Handle(MessageContext context,\r
                                   string commandName,\r
                                   string parameters)\r
                {\r
                        string originalErrorText = parameters.Trim();\r
                        if (originalErrorText.Equals(String.Empty))\r
                        {\r
-                               serviceOutput.WriteLine(context,\r
+                               TechBot.ServiceOutput.WriteLine(context,\r
                                                        "Please provide an Error Code.");\r
                                return;\r
                        }\r
@@ -98,7 +100,7 @@ namespace TechBot.Library
                        long error = np.Parse(errorText);\r
                        if (np.Error)\r
                        {\r
-                               serviceOutput.WriteLine(context,\r
+                TechBot.ServiceOutput.WriteLine(context,\r
                                                        String.Format("{0} is not a valid Error Code.",\r
                                                                                                          originalErrorText));\r
                                return;\r
@@ -173,30 +175,30 @@ namespace TechBot.Library
                                        goto retry;\r
                                }\r
 \r
-                               serviceOutput.WriteLine(context,\r
+                TechBot.ServiceOutput.WriteLine(context,\r
                                                                                String.Format("I don't know about Error Code {0}.",\r
                                                                                                          originalErrorText));\r
                        }\r
                        else if (descriptions.Count == 1)\r
                        {\r
                                string description = (string)descriptions[0];\r
-                               serviceOutput.WriteLine(context,\r
+                TechBot.ServiceOutput.WriteLine(context,\r
                                                                                String.Format("{0} is {1}.",\r
                                                                                                          originalErrorText,\r
                                                                                                          description));\r
                        }\r
                        else\r
                        {\r
-                               serviceOutput.WriteLine(context,\r
+                TechBot.ServiceOutput.WriteLine(context,\r
                                                        String.Format("{0} could be:",\r
                                                                      originalErrorText));\r
                                \r
                                foreach(string description in descriptions)\r
-                                       serviceOutput.WriteLine(context, String.Format("\t{0}", description));\r
+                    TechBot.ServiceOutput.WriteLine(context, String.Format("\t{0}", description));\r
                        }\r
                }\r
-               \r
-               public string Help()\r
+\r
+        public override string Help()\r
                {\r
                        return "!error <value>";\r
                }\r
index 4e5ce73..b007a7e 100644 (file)
@@ -3,38 +3,33 @@ using System.Collections;
 \r
 namespace TechBot.Library\r
 {\r
-       public class HelpCommand : BaseCommand, ICommand\r
+       public class HelpCommand : Command\r
        {\r
-               private IServiceOutput serviceOutput;\r
-               private ArrayList commands;\r
-               \r
-               public HelpCommand(IServiceOutput serviceOutput,\r
-                                  ArrayList commands)\r
+        public HelpCommand(TechBotService techBot)\r
+            : base(techBot)\r
                {\r
-                       this.serviceOutput = serviceOutput;\r
-                       this.commands = commands;\r
                }\r
 \r
-               public bool CanHandle(string commandName)\r
-               {\r
-                       return CanHandle(commandName,\r
-                                        new string[] { "help" });\r
-               }\r
-               \r
-               public void Handle(MessageContext context,\r
-                                  string commandName,\r
-                                  string parameters)\r
-               {\r
-                       serviceOutput.WriteLine(context,\r
-                                               "I support the following commands:");\r
-                       foreach (ICommand command in commands)\r
-                       {\r
-                               serviceOutput.WriteLine(context,\r
-                                                       command.Help());\r
-                       }\r
-               }\r
-               \r
-               public string Help()\r
+        public override string[] AvailableCommands\r
+        {\r
+            get { return new string[] { "help" }; }\r
+        }\r
+\r
+        public override void Handle(\r
+            MessageContext context,\r
+                           string commandName,\r
+                           string parameters)\r
+        {\r
+            TechBot.ServiceOutput.WriteLine(context, "I support the following commands:");\r
+\r
+            foreach (Command command in TechBot.Commands)\r
+            {\r
+                TechBot.ServiceOutput.WriteLine(context,\r
+                                        command.Help());\r
+            }\r
+        }\r
+\r
+        public override string Help()\r
                {\r
                        return "!help";\r
                }\r
index 32b7667..c8842cd 100644 (file)
@@ -3,33 +3,39 @@ using System.Xml;
 \r
 namespace TechBot.Library\r
 {\r
-       public class HresultCommand : BaseCommand, ICommand\r
+       public class HResultCommand : XmlCommand\r
        {\r
-               private IServiceOutput serviceOutput;\r
-               private XmlDocument hresultXmlDocument;\r
-\r
-               public HresultCommand(IServiceOutput serviceOutput,\r
-                                     string hresultXml)\r
+        public HResultCommand(TechBotService techBot)\r
+            : base(techBot)\r
                {\r
-                       this.serviceOutput = serviceOutput;\r
-                       hresultXmlDocument = new XmlDocument();\r
-                       hresultXmlDocument.Load(hresultXml);\r
                }\r
-               \r
+\r
+        public override string XmlFile\r
+        {\r
+            get { return Settings.Default.HResultXml; }\r
+        }\r
+\r
+        public override string[] AvailableCommands\r
+        {\r
+            get { return new string[] { "hresult" }; }\r
+        }\r
+\r
+        /*\r
                public bool CanHandle(string commandName)\r
                {\r
                        return CanHandle(commandName,\r
                                         new string[] { "hresult" });\r
                }\r
+        */\r
 \r
-               public void Handle(MessageContext context,\r
+               public override void Handle(MessageContext context,\r
                                   string commandName,\r
                                   string parameters)\r
                {\r
                        string hresultText = parameters;\r
                        if (hresultText.Equals(String.Empty))\r
                        {\r
-                               serviceOutput.WriteLine(context,\r
+                               TechBot.ServiceOutput.WriteLine(context,\r
                                                        "Please provide a valid HRESULT value.");\r
                                return;\r
                        }\r
@@ -38,7 +44,7 @@ namespace TechBot.Library
                        long hresult = np.Parse(hresultText);\r
                        if (np.Error)\r
                        {\r
-                               serviceOutput.WriteLine(context,\r
+                TechBot.ServiceOutput.WriteLine(context,\r
                                                        String.Format("{0} is not a valid HRESULT value.",\r
                                                                      hresultText));\r
                                return;\r
@@ -47,27 +53,27 @@ namespace TechBot.Library
                        string description = GetHresultDescription(hresult);\r
                        if (description != null)\r
                        {\r
-                               serviceOutput.WriteLine(context,\r
+                TechBot.ServiceOutput.WriteLine(context,\r
                                                        String.Format("{0} is {1}.",\r
                                                                      hresultText,\r
                                                                      description));\r
                        }\r
                        else\r
                        {\r
-                               serviceOutput.WriteLine(context,\r
+                TechBot.ServiceOutput.WriteLine(context,\r
                                                        String.Format("I don't know about HRESULT {0}.",\r
                                                                      hresultText));\r
                        }\r
                }\r
                \r
-               public string Help()\r
+               public override string Help()\r
                {\r
                        return "!hresult <value>";\r
                }\r
                \r
                public string GetHresultDescription(long hresult)\r
                {\r
-                       XmlElement root = hresultXmlDocument.DocumentElement;\r
+                       XmlElement root = base.m_XmlDocument.DocumentElement;\r
                        XmlNode node = root.SelectSingleNode(String.Format("Hresult[@value='{0}']",\r
                                                                           hresult.ToString("X8")));\r
                        if (node != null)\r
diff --git a/irc/TechBot/TechBot.Library/ICommand.cs b/irc/TechBot/TechBot.Library/ICommand.cs
deleted file mode 100644 (file)
index b88c911..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-using System;\r
-\r
-namespace TechBot.Library\r
-{\r
-       public interface ICommand\r
-       {\r
-               bool CanHandle(string commandName);\r
-               void Handle(MessageContext context,\r
-                           string commandName,\r
-                           string parameters);\r
-               string Help();\r
-       }\r
-\r
-       \r
-       \r
-       public class BaseCommand\r
-       {\r
-               protected bool CanHandle(string commandName,\r
-                                        string[] availableCommands)\r
-               {\r
-                       foreach (string availableCommand in availableCommands)\r
-                       {\r
-                               if (String.Compare(availableCommand, commandName, true) == 0)\r
-                                       return true;\r
-                       }\r
-                       return false;\r
-               }\r
-       }\r
-}\r
index 2e7229f..bfd2867 100644 (file)
@@ -1,6 +1,8 @@
 using System;\r
+using System.Text;\r
 using System.Collections;\r
 using System.Threading;\r
+\r
 using TechBot.IRCLibrary;\r
 \r
 namespace TechBot.Library\r
@@ -20,7 +22,7 @@ namespace TechBot.Library
                private string wmXml;\r
                private string svnCommand;\r
                private string bugUrl, WineBugUrl, SambaBugUrl;\r
-               private IrcClient client;\r
+               private IrcClient m_IrcClient;\r
                private ArrayList channels = new ArrayList(); /* IrcChannel */\r
                private TechBotService service;\r
                private bool isStopped = false;\r
@@ -32,11 +34,11 @@ namespace TechBot.Library
                                  string password,\r
                                  string chmPath,\r
                                  string mainChm,\r
-                                 string ntstatusXml,\r
-                                 string winerrorXml,\r
-                                 string hresultXml,\r
-                                 string wmXml,\r
-                                 string svnCommand,\r
+                          //string ntstatusXml,\r
+                          //string winerrorXml,\r
+                          //string hresultXml,\r
+                          //string wmXml,\r
+                                 //string svnCommand,\r
                                  string BugUrl,\r
                                  string WineBugUrl,\r
                                  string SambaBugUrl)\r
@@ -61,42 +63,43 @@ namespace TechBot.Library
                        this.SambaBugUrl = SambaBugUrl;\r
                }\r
 \r
-               public void Run()\r
-               {\r
-                       service = new TechBotService(this,\r
-                                                    chmPath,\r
-                                                    mainChm,\r
-                                                    ntstatusXml,\r
-                                                    winerrorXml,\r
-                                                    hresultXml,\r
-                                                    wmXml,\r
-                                                    svnCommand,\r
-                                                    bugUrl,\r
-                                                    WineBugUrl,\r
-                                                    SambaBugUrl);\r
-                       service.Run();\r
+        public void Run()\r
+        {\r
+            service = new TechBotService(this,\r
+                                         chmPath,\r
+                                         mainChm);\r
+                                         //ntstatusXml,\r
+                                         //winerrorXml,\r
+                                         //hresultXml,\r
+                                         //wmXml,\r
+                                         //svnCommand,\r
+                                         //bugUrl,\r
+                                         //WineBugUrl,\r
+                                         //SambaBugUrl);\r
+            service.Run();\r
 \r
-                       client = new IrcClient();\r
-                       client.Encoding = System.Text.Encoding.GetEncoding("iso-8859-1");\r
-                       client.MessageReceived += new MessageReceivedHandler(client_MessageReceived);\r
-                       client.ChannelUserDatabaseChanged += new ChannelUserDatabaseChangedHandler(client_ChannelUserDatabaseChanged);\r
-                       System.Console.WriteLine(String.Format("Connecting to {0} port {1}",\r
-                                                              hostname, port));\r
-                       client.Connect(hostname, port);\r
-                       System.Console.WriteLine("Connected...");\r
-                       client.Register(botname, password, null);\r
-                       System.Console.WriteLine(String.Format("Registered as {0}...", botname));\r
-                       JoinChannels();\r
-                       \r
-                       while (!isStopped)\r
-                       {\r
-                               Thread.Sleep(1000);\r
-                       }\r
+            m_IrcClient = new IrcClient();\r
+            m_IrcClient.Encoding = Encoding.GetEncoding("iso-8859-1");\r
+            m_IrcClient.MessageReceived += new MessageReceivedHandler(client_MessageReceived);\r
+            m_IrcClient.ChannelUserDatabaseChanged += new ChannelUserDatabaseChangedHandler(client_ChannelUserDatabaseChanged);\r
+            Console.WriteLine("Connecting to {0} port {1}",\r
+                                                   hostname,\r
+                                                   port);\r
+            m_IrcClient.Connect(hostname, port);\r
+            Console.WriteLine("Connected...");\r
+            m_IrcClient.Register(botname, password, null);\r
+            Console.WriteLine("Registered as {0}...", botname);\r
+            JoinChannels();\r
 \r
-                       PartChannels();\r
-                       client.Diconnect();\r
-                       System.Console.WriteLine("Disconnected...");\r
-               }\r
+            while (!isStopped)\r
+            {\r
+                Thread.Sleep(1000);\r
+            }\r
+\r
+            PartChannels();\r
+            m_IrcClient.Diconnect();\r
+            Console.WriteLine("Disconnected...");\r
+        }\r
 \r
                public void Stop()\r
                {\r
@@ -107,7 +110,7 @@ namespace TechBot.Library
                {\r
                        foreach (string channelname in channelnames.Split(new char[] { ';' }))\r
                        {\r
-                               IrcChannel channel = client.JoinChannel(channelname);\r
+                               IrcChannel channel = m_IrcClient.JoinChannel(channelname);\r
                                channels.Add(channel);\r
                                System.Console.WriteLine(String.Format("Joined channel #{0}...",\r
                                                                       channel.Name));\r
@@ -118,7 +121,7 @@ namespace TechBot.Library
                {\r
                        foreach (IrcChannel channel in channels)\r
                        {\r
-                               client.PartChannel(channel, "Caught in the bitstream...");\r
+                               m_IrcClient.PartChannel(channel, "Caught in the bitstream...");\r
                                System.Console.WriteLine(String.Format("Parted channel #{0}...",\r
                                                                       channel.Name));\r
                        }\r
@@ -235,11 +238,11 @@ namespace TechBot.Library
                                else if (GetTargetNickname(message,\r
                                                           out nickname))\r
                                {\r
-                                       IrcUser targetUser = new IrcUser(client,\r
+                                       IrcUser targetUser = new IrcUser(m_IrcClient,\r
                                                                         nickname);\r
                                        if (String.Compare(targetUser.Nickname, botname, true) == 0)\r
                                        {\r
-                                               IrcUser sourceUser = new IrcUser(client,\r
+                                               IrcUser sourceUser = new IrcUser(m_IrcClient,\r
                                                                                 message.PrefixNickname);\r
                                                context = new UserMessageContext(sourceUser);\r
                                                return true;\r
index 034df26..4833c57 100644 (file)
@@ -3,35 +3,37 @@ using System.Xml;
 \r
 namespace TechBot.Library\r
 {\r
-       public class NtStatusCommand : BaseCommand, ICommand\r
+       public class NtStatusCommand : XmlCommand\r
        {\r
-               private IServiceOutput serviceOutput;\r
-               private string ntstatusXml;\r
-               private XmlDocument ntstatusXmlDocument;\r
-\r
-               public NtStatusCommand(IServiceOutput serviceOutput,\r
-                                      string ntstatusXml)\r
+        public NtStatusCommand(TechBotService techBot)\r
+            : base(techBot)\r
                {\r
-                       this.serviceOutput = serviceOutput;\r
-                       this.ntstatusXml = ntstatusXml;\r
-                       ntstatusXmlDocument = new XmlDocument();\r
-                       ntstatusXmlDocument.Load(ntstatusXml);\r
                }\r
-               \r
+\r
+        public override string XmlFile\r
+        {\r
+            get { return Settings.Default.NtStatusXml; }\r
+        }\r
+\r
+        public override string[] AvailableCommands\r
+        {\r
+            get { return new string[] { "ntstatus" }; }\r
+        }\r
+/*             \r
                public bool CanHandle(string commandName)\r
                {\r
                        return CanHandle(commandName,\r
                                         new string[] { "ntstatus" });\r
                }\r
-\r
-               public void Handle(MessageContext context,\r
+*/\r
+               public override void Handle(MessageContext context,\r
                                   string commandName,\r
                                   string parameters)\r
                {\r
                        string ntstatusText = parameters;\r
                        if (ntstatusText.Equals(String.Empty))\r
                        {\r
-                               serviceOutput.WriteLine(context,\r
+                               TechBot.ServiceOutput.WriteLine(context,\r
                                                        "Please provide a valid NTSTATUS value.");\r
                                return;\r
                        }\r
@@ -40,7 +42,7 @@ namespace TechBot.Library
                        long ntstatus = np.Parse(ntstatusText);\r
                        if (np.Error)\r
                        {\r
-                               serviceOutput.WriteLine(context,\r
+                TechBot.ServiceOutput.WriteLine(context,\r
                                                        String.Format("{0} is not a valid NTSTATUS value.",\r
                                                                      ntstatusText));\r
                                return;\r
@@ -49,27 +51,27 @@ namespace TechBot.Library
                        string description = GetNtstatusDescription(ntstatus);\r
                        if (description != null)\r
                        {\r
-                               serviceOutput.WriteLine(context,\r
+                TechBot.ServiceOutput.WriteLine(context,\r
                                                        String.Format("{0} is {1}.",\r
                                                                      ntstatusText,\r
                                                                      description));\r
                        }\r
                        else\r
                        {\r
-                               serviceOutput.WriteLine(context,\r
+                TechBot.ServiceOutput.WriteLine(context,\r
                                                        String.Format("I don't know about NTSTATUS {0}.",\r
                                                                      ntstatusText));\r
                        }\r
                }\r
-               \r
-               public string Help()\r
+\r
+        public override string Help()\r
                {\r
                        return "!ntstatus <value>";\r
                }\r
                \r
                public string GetNtstatusDescription(long ntstatus)\r
                {\r
-                       XmlElement root = ntstatusXmlDocument.DocumentElement;\r
+                       XmlElement root = base.m_XmlDocument.DocumentElement;\r
                        XmlNode node = root.SelectSingleNode(String.Format("Ntstatus[@value='{0}']",\r
                                                                           ntstatus.ToString("X8")));\r
                        if (node != null)\r
@@ -1,32 +1,32 @@
-using System.Reflection;\r
-using System.Runtime.CompilerServices;\r
-\r
-// Information about this assembly is defined by the following\r
-// attributes.\r
-//\r
-// change them to the information which is associated with the assembly\r
-// you compile.\r
-\r
-[assembly: AssemblyTitle("")]\r
-[assembly: AssemblyDescription("")]\r
-[assembly: AssemblyConfiguration("")]\r
-[assembly: AssemblyCompany("")]\r
-[assembly: AssemblyProduct("")]\r
-[assembly: AssemblyCopyright("")]\r
-[assembly: AssemblyTrademark("")]\r
-[assembly: AssemblyCulture("")]\r
-\r
-// The assembly version has following format :\r
-//\r
-// Major.Minor.Build.Revision\r
-//\r
-// You can specify all values by your own or you can build default build and revision\r
-// numbers with the '*' character (the default):\r
-\r
-[assembly: AssemblyVersion("1.0.*")]\r
-\r
-// The following attributes specify the key for the sign of your assembly. See the\r
-// .NET Framework documentation for more information about signing.\r
-// This is not required, if you don't want signing let these attributes like they're.\r
-[assembly: AssemblyDelaySign(false)]\r
-[assembly: AssemblyKeyFile("")]\r
+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 (file)
index 0000000..daa0e5c
--- /dev/null
@@ -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>";
+        }
+    }
+}
diff --git a/irc/TechBot/TechBot.Library/SambaBugUrl.cs b/irc/TechBot/TechBot.Library/SambaBugUrl.cs
new file mode 100644 (file)
index 0000000..6b70fac
--- /dev/null
@@ -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>";
+        }
+    }
+}
diff --git a/irc/TechBot/TechBot.Library/Settings.Designer.cs b/irc/TechBot/TechBot.Library/Settings.Designer.cs
new file mode 100644 (file)
index 0000000..4a88a84
--- /dev/null
@@ -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"]));
+            }
+        }
+    }
+}
diff --git a/irc/TechBot/TechBot.Library/Settings.cs b/irc/TechBot/TechBot.Library/Settings.cs
new file mode 100644 (file)
index 0000000..e1543b0
--- /dev/null
@@ -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 (file)
index 0000000..65c52e1
--- /dev/null
@@ -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>
\ No newline at end of file
index 7b2fce5..aef633b 100644 (file)
@@ -2,33 +2,29 @@ using System;
 \r
 namespace TechBot.Library\r
 {\r
-       public class SvnCommand : BaseCommand, ICommand\r
+       public class SvnCommand : Command\r
        {\r
-               private IServiceOutput serviceOutput;\r
-               private string svnCommand;\r
+               private string m_SvnRoot;\r
 \r
-               public SvnCommand(IServiceOutput serviceOutput,\r
-                                      string svnCommand)\r
+        public SvnCommand(TechBotService techBot)\r
+            : base(techBot)\r
                {\r
-                       this.serviceOutput = serviceOutput;\r
-                       this.svnCommand = svnCommand;\r
-               }\r
-               \r
-               public bool CanHandle(string commandName)\r
-               {\r
-                       return CanHandle(commandName,\r
-                                        new string[] { "svn" });\r
+                       m_SvnRoot = Settings.Default.SVNRoot;\r
                }\r
 \r
-               public void Handle(MessageContext context,\r
+        public override string[] AvailableCommands\r
+        {\r
+            get { return new string[] { "svn" }; }\r
+        }\r
+               \r
+               public override void Handle(MessageContext context,\r
                                   string commandName,\r
                                   string parameters)\r
                {\r
-                       serviceOutput.WriteLine(context,\r
-                                               svnCommand);\r
+                       TechBot.ServiceOutput.WriteLine(context, string.Format("svn co {0}" , m_SvnRoot));\r
                }\r
-               \r
-               public string Help()\r
+\r
+        public override string Help()\r
                {\r
                        return "!svn";\r
                }\r
diff --git a/irc/TechBot/TechBot.Library/TechBot.Library.cmbx b/irc/TechBot/TechBot.Library/TechBot.Library.cmbx
deleted file mode 100644 (file)
index 6b132a5..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<Combine fileversion="1.0" name="TechBot.Library" description="">\r
-  <StartMode startupentry="TechBot.Library" single="True">\r
-    <Execute entry="TechBot.Library" type="None" />\r
-  </StartMode>\r
-  <Entries>\r
-    <Entry filename=".\.\TechBot.Library.prjx" />\r
-  </Entries>\r
-  <Configurations active="Debug">\r
-    <Configuration name="Release">\r
-      <Entry name="TechBot.Library" configurationname="Debug" build="False" />\r
-    </Configuration>\r
-    <Configuration name="Debug">\r
-      <Entry name="TechBot.Library" configurationname="Debug" build="False" />\r
-    </Configuration>\r
-  </Configurations>\r
-</Combine>
\ No newline at end of file
index 84e3061..8970884 100644 (file)
   -->
   <ItemGroup>
     <Compile Include="ApiCommand.cs" />
-    <Compile Include="AssemblyInfo.cs" />
     <Compile Include="BugCommand.cs" />
+    <Compile Include="Commands\Base\XmlCommand.cs" />
+    <Compile Include="SambaBugUrl.cs" />
+    <Compile Include="WineBugUrl.cs" />
     <Compile Include="ErrorCommand.cs" />
     <Compile Include="HelpCommand.cs" />
     <Compile Include="HresultCommand.cs" />
     <Compile Include="MessageContext.cs" />
     <Compile Include="NtStatusCommand.cs" />
     <Compile Include="NumberParser.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="ReactOSBugUrl.cs" />
     <Compile Include="ServiceOutput.cs" />
+    <Compile Include="Settings.cs" />
+    <Compile Include="Settings.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
+      <DependentUpon>Settings.settings</DependentUpon>
+    </Compile>
     <Compile Include="SvnCommand.cs" />
     <Compile Include="TechBotService.cs" />
     <Compile Include="WinerrorCommand.cs" />
     </ProjectReference>
   </ItemGroup>
   <ItemGroup>
-    <Folder Include="Properties\" />
+    <None Include="app.config" />
+    <None Include="Settings.settings">
+      <Generator>SettingsSingleFileGenerator</Generator>
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+    </None>
   </ItemGroup>
 </Project>
\ 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 (file)
index cf716a4..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-<Project name="TechBot.Library" standardNamespace="TechBot.Library" description="" newfilesearch="None" enableviewstate="True" version="1.1" projecttype="C#">\r
-  <Contents>\r
-    <File name=".\AssemblyInfo.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
-    <File name=".\Default.build" subtype="Code" buildaction="Nothing" dependson="" data="" />\r
-    <File name=".\TechBotService.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
-    <File name=".\ServiceOutput.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
-    <File name=".\IrcService.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
-    <File name=".\ApiCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
-    <File name=".\ICommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
-    <File name=".\HelpCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
-    <File name=".\NtStatusCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
-    <File name=".\NumberParser.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
-    <File name=".\HresultCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
-    <File name=".\WinerrorCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
-    <File name=".\ErrorCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
-    <File name=".\SvnCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
-    <File name=".\BugCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
-    <File name=".\WmCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
-    <File name=".\MessageContext.cs" subtype="Code" buildaction="Compile" dependson="" data="" />\r
-  </Contents>\r
-  <References>\r
-    <Reference type="Project" refto="CHMLibrary" localcopy="True" />\r
-    <Reference type="Project" refto="TechBot.IRCLibrary" localcopy="True" />\r
-  </References>\r
-  <DeploymentInformation target="" script="" strategy="File" />\r
-  <Configuration runwithwarnings="True" name="Debug">\r
-    <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" />\r
-    <Execution commandlineparameters="" consolepause="False" />\r
-    <Output directory="..\bin\Debug" assembly="TechBot.Library" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />\r
-  </Configuration>\r
-  <Configurations active="Debug">\r
-    <Configuration runwithwarnings="True" name="Debug">\r
-      <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" />\r
-      <Execution commandlineparameters="" consolepause="False" />\r
-      <Output directory="..\bin\Debug" assembly="TechBot.Library" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />\r
-    </Configuration>\r
-    <Configuration runwithwarnings="True" name="Release">\r
-      <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" />\r
-      <Execution commandlineparameters="" consolepause="False" />\r
-      <Output directory="..\bin\Release" assembly="TechBot.Library" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />\r
-    </Configuration>\r
-  </Configurations>\r
-</Project>\r
index f727c33..d40ab91 100644 (file)
@@ -1,5 +1,6 @@
 using System;\r
 using System.Collections;\r
+using System.Collections.Generic;\r
 using System.IO;\r
 using System.Data;\r
 using System.Threading;\r
@@ -18,19 +19,19 @@ namespace TechBot.Library
                private string wmXml;\r
                private string svnCommand;\r
                private string bugUrl, WineBugUrl, SambaBugUrl;\r
-               private ArrayList commands = new ArrayList();\r
+        private List<Command> commands = new List<Command>();\r
                \r
                public TechBotService(IServiceOutput serviceOutput,\r
                                      string chmPath,\r
-                                     string mainChm,\r
-                                     string ntstatusXml,\r
-                                     string winerrorXml,\r
-                                     string hresultXml,\r
-                                     string wmXml,\r
-                                     string svnCommand,\r
-                                     string bugUrl,\r
-                                     string WineBugUrl,\r
-                                     string SambaBugUrl)\r
+                                     string mainChm)\r
+                              //string ntstatusXml,\r
+                              //string winerrorXml,\r
+                              //string hresultXml,\r
+                              //string wmXml,\r
+                                     //string svnCommand,\r
+                              //string bugUrl,\r
+                              //string WineBugUrl,\r
+                              //string SambaBugUrl)\r
                {\r
                        this.serviceOutput = serviceOutput;\r
                        this.chmPath = chmPath;\r
@@ -44,33 +45,33 @@ namespace TechBot.Library
                        this.WineBugUrl = WineBugUrl;\r
                        this.SambaBugUrl = SambaBugUrl;\r
                }\r
-               \r
-               public void Run()\r
-               {\r
-                       commands.Add(new HelpCommand(serviceOutput,\r
-                                                    commands));\r
-                       /*commands.Add(new ApiCommand(serviceOutput,\r
-                                                   chmPath,\r
-                                                   mainChm));*/\r
-                       commands.Add(new NtStatusCommand(serviceOutput,\r
-                                                        ntstatusXml));\r
-                       commands.Add(new WinerrorCommand(serviceOutput,\r
-                                                        winerrorXml));\r
-                       commands.Add(new HresultCommand(serviceOutput,\r
-                                                       hresultXml));\r
-                       commands.Add(new ErrorCommand(serviceOutput,\r
-                                                                                       ntstatusXml,\r
-                                                                                       winerrorXml,\r
-                                                                                       hresultXml));\r
-                       commands.Add(new WmCommand(serviceOutput,\r
-                                                  wmXml));\r
-                       commands.Add(new SvnCommand(serviceOutput,\r
-                                                   svnCommand));\r
-                       commands.Add(new BugCommand(serviceOutput,\r
-                                                   bugUrl,\r
-                                                   WineBugUrl,\r
-                                                   SambaBugUrl));\r
-               }\r
+\r
+        public void Run()\r
+        {\r
+            commands.Add(new HelpCommand(this));\r
+            /*commands.Add(new ApiCommand(serviceOutput,\r
+                                        chmPath,\r
+                                        mainChm));*/\r
+            commands.Add(new NtStatusCommand(this));\r
+            commands.Add(new WinerrorCommand(this));\r
+            commands.Add(new HResultCommand(this));\r
+            commands.Add(new ErrorCommand(this));\r
+            commands.Add(new WMCommand(this));\r
+            commands.Add(new SvnCommand(this));\r
+            commands.Add(new ReactOSBugUrl(this));\r
+            commands.Add(new SambaBugUrl(this));\r
+            commands.Add(new WineBugUrl(this));\r
+        }\r
+\r
+        public IServiceOutput ServiceOutput\r
+        {\r
+            get { return serviceOutput; }\r
+        }\r
+\r
+        public IList<Command> Commands\r
+        {\r
+            get { return commands; }\r
+        }\r
                \r
                public void InjectMessage(MessageContext context,\r
                                          string message)\r
@@ -94,23 +95,27 @@ namespace TechBot.Library
                        message = message.Substring(1).Trim();\r
                        int index = message.IndexOf(' ');\r
                        string commandName;\r
-                       string parameters = "";\r
+                       string commandParams = "";\r
                        if (index != -1)\r
                        {\r
                                commandName = message.Substring(0, index).Trim();\r
-                               parameters = message.Substring(index).Trim();\r
+                               commandParams = message.Substring(index).Trim();\r
                        }\r
                        else\r
                                commandName = message.Trim();\r
 \r
-                       foreach (ICommand command in commands)\r
+                       foreach (Command command in commands)\r
                        {\r
-                               if (command.CanHandle(commandName))\r
-                               {\r
-                                       command.Handle(context,\r
-                                                      commandName, parameters);\r
-                                       return;\r
-                               }\r
+                foreach (string cmd in command.AvailableCommands)\r
+                {\r
+                    if (cmd == commandName)\r
+                    {\r
+                        command.Handle(context,\r
+                                       commandName, \r
+                                       commandParams);\r
+                        return;\r
+                    }\r
+                }\r
                        }\r
                }\r
        }\r
diff --git a/irc/TechBot/TechBot.Library/WineBugUrl.cs b/irc/TechBot/TechBot.Library/WineBugUrl.cs
new file mode 100644 (file)
index 0000000..94464a1
--- /dev/null
@@ -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>";
+        }
+    }
+}
index 9fd79c4..5121575 100644 (file)
@@ -3,35 +3,31 @@ using System.Xml;
 \r
 namespace TechBot.Library\r
 {\r
-       public class WinerrorCommand : BaseCommand, ICommand\r
+       public class WinerrorCommand : XmlCommand\r
        {\r
-               private IServiceOutput serviceOutput;\r
-               private string winerrorXml;\r
-               private XmlDocument winerrorXmlDocument;\r
-\r
-               public WinerrorCommand(IServiceOutput serviceOutput,\r
-                                      string winerrorXml)\r
-               {\r
-                       this.serviceOutput = serviceOutput;\r
-                       this.winerrorXml = winerrorXml;\r
-                       winerrorXmlDocument = new XmlDocument();\r
-                       winerrorXmlDocument.Load(winerrorXml);\r
-               }\r
-               \r
-               public bool CanHandle(string commandName)\r
+        public WinerrorCommand(TechBotService techBot)\r
+            : base(techBot)\r
                {\r
-                       return CanHandle(commandName,\r
-                                        new string[] { "winerror" });\r
                }\r
 \r
-               public void Handle(MessageContext context,\r
+        public override string XmlFile\r
+        {\r
+            get { return Settings.Default.WinErrorXml; }\r
+        }\r
+\r
+        public override string[] AvailableCommands\r
+        {\r
+            get { return new string[] { "winerror" }; }\r
+        }\r
+\r
+               public override void Handle(MessageContext context,\r
                                   string commandName,\r
                                   string parameters)\r
                {\r
                        string winerrorText = parameters;\r
                        if (winerrorText.Equals(String.Empty))\r
                        {\r
-                               serviceOutput.WriteLine(context,\r
+                               TechBot.ServiceOutput.WriteLine(context,\r
                                                        "Please provide a valid System Error Code value.");\r
                                return;\r
                        }\r
@@ -40,7 +36,7 @@ namespace TechBot.Library
                        long winerror = np.Parse(winerrorText);\r
                        if (np.Error)\r
                        {\r
-                               serviceOutput.WriteLine(context,\r
+                TechBot.ServiceOutput.WriteLine(context,\r
                                                        String.Format("{0} is not a valid System Error Code value.",\r
                                                                      winerrorText));\r
                                return;\r
@@ -49,27 +45,27 @@ namespace TechBot.Library
                        string description = GetWinerrorDescription(winerror);\r
                        if (description != null)\r
                        {\r
-                               serviceOutput.WriteLine(context,\r
+                TechBot.ServiceOutput.WriteLine(context,\r
                                                        String.Format("{0} is {1}.",\r
                                                                      winerrorText,\r
                                                                      description));\r
                        }\r
                        else\r
                        {\r
-                               serviceOutput.WriteLine(context,\r
+                TechBot.ServiceOutput.WriteLine(context,\r
                                                        String.Format("I don't know about System Error Code {0}.",\r
                                                                      winerrorText));\r
                        }\r
                }\r
-               \r
-               public string Help()\r
+\r
+        public override string Help()\r
                {\r
                        return "!winerror <value>";\r
                }\r
                \r
                public string GetWinerrorDescription(long winerror)\r
                {\r
-                       XmlElement root = winerrorXmlDocument.DocumentElement;\r
+                       XmlElement root = base.m_XmlDocument.DocumentElement;\r
                        XmlNode node = root.SelectSingleNode(String.Format("Winerror[@value='{0}']",\r
                                                                           winerror));\r
                        if (node != null)\r
index 0809c3e..31d6701 100644 (file)
@@ -3,35 +3,31 @@ using System.Xml;
 \r
 namespace TechBot.Library\r
 {\r
-       public class WmCommand : BaseCommand, ICommand\r
+       public class WMCommand : XmlCommand\r
        {\r
-               private IServiceOutput serviceOutput;\r
-               private string wmXml;\r
-               private XmlDocument wmXmlDocument;\r
-\r
-               public WmCommand(IServiceOutput serviceOutput,\r
-                                string wmXml)\r
+        public WMCommand(TechBotService techBot)\r
+            : base(techBot)\r
                {\r
-                       this.serviceOutput = serviceOutput;\r
-                       this.wmXml = wmXml;\r
-                       wmXmlDocument = new XmlDocument();\r
-                       wmXmlDocument.Load(wmXml);\r
                }\r
+\r
+        public override string XmlFile\r
+        {\r
+            get { return Settings.Default.WMXml; }\r
+        }\r
                \r
-               public bool CanHandle(string commandName)\r
-               {\r
-                       return CanHandle(commandName,\r
-                                        new string[] { "wm" });\r
-               }\r
+        public override string[] AvailableCommands\r
+        {\r
+            get { return new string[] { "wm" }; }\r
+        }\r
 \r
-               public void Handle(MessageContext context,\r
+               public override void Handle(MessageContext context,\r
                                   string commandName,\r
                                   string parameters)\r
                {\r
                        string wmText = parameters;\r
                        if (wmText.Equals(String.Empty))\r
                        {\r
-                               serviceOutput.WriteLine(context,\r
+                               TechBot.ServiceOutput.WriteLine(context,\r
                                                        "Please provide a valid window message value or name.");\r
                                return;\r
                        }\r
@@ -51,27 +47,27 @@ namespace TechBot.Library
 \r
                        if (output != null)\r
                        {\r
-                               serviceOutput.WriteLine(context,\r
+                TechBot.ServiceOutput.WriteLine(context,\r
                                                        String.Format("{0} is {1}.",\r
                                                                      wmText,\r
                                                                      output));\r
                        }\r
                        else\r
                        {\r
-                               serviceOutput.WriteLine(context,\r
+                TechBot.ServiceOutput.WriteLine(context,\r
                                                        String.Format("I don't know about window message {0}.",\r
                                                                      wmText));\r
                        }\r
                }\r
-               \r
-               public string Help()\r
+\r
+        public override string Help()\r
                {\r
                        return "!wm <value> or !wm <name>";\r
                }\r
                \r
                private string GetWmDescription(long wm)\r
                {\r
-                       XmlElement root = wmXmlDocument.DocumentElement;\r
+                       XmlElement root = base.m_XmlDocument.DocumentElement;\r
                        XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@value='{0}']",\r
                                                                           wm));\r
                        if (node != null)\r
@@ -87,7 +83,7 @@ namespace TechBot.Library
                \r
                private string GetWmNumber(string wmName)\r
                {\r
-                       XmlElement root = wmXmlDocument.DocumentElement;\r
+                       XmlElement root = base.m_XmlDocument.DocumentElement;\r
                        XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@text='{0}']",\r
                                                                           wmName));\r
                        if (node != null)\r
diff --git a/irc/TechBot/TechBot.Library/app.config b/irc/TechBot/TechBot.Library/app.config
new file mode 100644 (file)
index 0000000..c2ac070
--- /dev/null
@@ -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>
\ No newline at end of file
index 48b30d2..9e22beb 100644 (file)
@@ -58,11 +58,11 @@ namespace TechBot
                                                               IRCBotPassword,\r
                                                               ChmPath,\r
                                                               MainChm,\r
-                                                              NtstatusXml,\r
-                                                              WinerrorXml,\r
-                                                              HresultXml,\r
-                                                              WmXml,\r
-                                                              SvnCommand,\r
+                                                   //NtstatusXml,\r
+                                                   //WinerrorXml,\r
+                                                   //HresultXml,\r
+                                                   //WmXml,\r
+                                                              //SvnCommand,\r
                                                               BugUrl,\r
                                                               WineBugUrl,\r
                                                               SambaBugUrl);\r
index 604d2d4..692e473 100644 (file)
@@ -10,6 +10,7 @@
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>TechBot</RootNamespace>
     <AssemblyName>TechBot</AssemblyName>
+    <StartupObject>TechBot.TechBotService</StartupObject>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>