- code refactoring
[reactos.git] / irc / TechBot / TechBot.Library / Commands / BugCommand.cs
diff --git a/irc/TechBot/TechBot.Library/Commands/BugCommand.cs b/irc/TechBot/TechBot.Library/Commands/BugCommand.cs
new file mode 100644 (file)
index 0000000..1beb5fc
--- /dev/null
@@ -0,0 +1,41 @@
+using System;
+
+namespace TechBot.Library
+{
+       public abstract class BugCommand : Command
+       {
+        private string m_BugID = null;
+
+               public BugCommand()
+               {
+               }
+
+        [CommandParameter("id", "The bug ID")]
+        public string BugID
+        {
+            get { return m_BugID; }
+            set { m_BugID = value; }
+        }
+
+        public override void ExecuteCommand()
+        {
+            if (BugID == null)
+            {
+                Say("Please provide a valid bug number.");
+            }
+            else
+            {
+                try
+                {
+                    Say(BugUrl, Int32.Parse(BugID));
+                }
+                catch (Exception)
+                {
+                    Say("{0} is not a valid bug number.", BugID);
+                }
+            }
+        }
+
+        protected abstract string BugUrl { get; }
+       }
+}