- code refactoring
[reactos.git] / irc / TechBot / TechBot.Library / Commands / HelpCommand.cs
1 using System;
2 using System.Collections;
3
4 namespace TechBot.Library
5 {
6 [Command("help", Help = "!help")]
7 public class HelpCommand : Command
8 {
9 private string m_CommandName = null;
10
11 public HelpCommand()
12 {
13 }
14
15 [CommandParameter("Name", "The command name to show help")]
16 public string CommandName
17 {
18 get { return m_CommandName; }
19 set { m_CommandName = value; }
20 }
21
22 public override void ExecuteCommand()
23 {
24 if (CommandName == null)
25 {
26 Say("I support the following commands:");
27
28 foreach (CommandBuilder command in TechBot.Commands)
29 {
30 Say("!{0} - {1}",
31 command.Name,
32 command.Description);
33 }
34 }
35 else
36 {
37 CommandBuilder cmdBuilder = TechBot.Commands.Find(CommandName);
38
39 if (cmdBuilder == null)
40 {
41 Say("Command '{0}' is not recognized. Type '!help' to show all available commands", CommandName);
42 }
43 else
44 {
45 Say("Command '{0}' help:", CommandName);
46 Say("");
47 }
48 }
49 }
50 }
51 }