2 using System.Reflection;
3 using System.Collections;
5 namespace TechBot.Library
7 [Command("help", Help = "!help or !help -name:[CommandName]", Description = "Shows this help , type 'help -name:[CommandName]'")]
8 public class HelpCommand : Command
10 private string m_CommandName = null;
16 [CommandParameter("Name", "The command name to show help")]
17 public string CommandName
19 get { return Parameters; }
20 set { Parameters = value; }
23 public override void ExecuteCommand()
25 if (CommandName == null)
27 Say("I support the following commands:");
29 foreach (CommandBuilder command in TechBot.Commands)
32 Settings.Default.CommandPrefix,
39 CommandBuilder cmdBuilder = TechBot.Commands.Find(CommandName);
41 if (cmdBuilder == null)
43 Say("Command '{0}' is not recognized. Type '!help' to show all available commands", CommandName);
47 Say("Command '{0}' help:", CommandName);
49 Say(cmdBuilder.Description);
56 PropertyInfo[] propertyInfoArray = cmdBuilder.Type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
57 foreach (PropertyInfo propertyInfo in propertyInfoArray)
59 CommandParameterAttribute[] commandAttributes = (CommandParameterAttribute[])
60 Attribute.GetCustomAttributes(propertyInfo, typeof(CommandParameterAttribute));
62 foreach (CommandParameterAttribute parameter in commandAttributes)
66 parameter.Description);