6 namespace TechBot.Commands.Common
8 [Command("ntstatus", Help = "!ntstatus <value>")]
9 public class NtStatusCommand : XmlLookupCommand
11 public NtStatusCommand()
15 public override string XmlFile
17 get { return Settings.Default.NtStatusXml; }
20 public override void ExecuteCommand()
22 if (string.IsNullOrEmpty(Text))
24 Say("Please provide a valid NTSTATUS value.");
28 NumberParser np = new NumberParser();
29 long ntstatus = np.Parse(Text);
32 Say("{0} is not a valid NTSTATUS value.", Text);
36 string description = GetNtstatusDescription(ntstatus);
37 if (description != null)
45 Say("I don't know about NTSTATUS {0}.", Text);
50 public string GetNtstatusDescription(long ntstatus)
52 XmlElement root = base.m_XmlDocument.DocumentElement;
53 XmlNode node = root.SelectSingleNode(String.Format("Ntstatus[@value='{0}']",
54 ntstatus.ToString("X8")));
57 XmlAttribute text = node.Attributes["text"];
59 throw new Exception("Node has no text attribute.");