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
14 [CommandParameter("Name", "The command name to show help")]
15 public string CommandName
17 get { return Parameters; }
18 set { Parameters = value; }
21 public override void ExecuteCommand()
23 if (string.IsNullOrEmpty(CommandName))
25 Say("I support the following commands:");
27 foreach (CommandBuilder command in TechBot.Commands)
30 Settings.Default.CommandPrefix,
37 CommandBuilder cmdBuilder = TechBot.Commands.Find(CommandName);
39 if (cmdBuilder == null)
41 Say("Command '{0}' is not recognized. Type '!help' to show all available commands", CommandName);
45 Say("Command '{0}' help:", CommandName);
47 Say(cmdBuilder.Description);
54 PropertyInfo[] propertyInfoArray = cmdBuilder.Type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
55 foreach (PropertyInfo propertyInfo in propertyInfoArray)
57 CommandParameterAttribute[] commandAttributes = (CommandParameterAttribute[])
58 Attribute.GetCustomAttributes(propertyInfo, typeof(CommandParameterAttribute));
60 foreach (CommandParameterAttribute parameter in commandAttributes)
64 parameter.Description);