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 public override bool AnswerInPublic
19 [CommandParameter("Name", "The command name to show help")]
20 public string CommandName
22 get { return Parameters; }
23 set { Parameters = value; }
26 public override void ExecuteCommand()
28 if (string.IsNullOrEmpty(CommandName))
30 Say("I support the following commands:");
32 foreach (CommandBuilder command in TechBot.Commands)
35 Settings.Default.CommandPrefix,
42 CommandBuilder cmdBuilder = TechBot.Commands.Find(CommandName);
44 if (cmdBuilder == null)
46 Say("Command '{0}' is not recognized. Type '!help' to show all available commands", CommandName);
50 Say("Command '{0}' help:", CommandName);
52 Say(cmdBuilder.Description);
59 PropertyInfo[] propertyInfoArray = cmdBuilder.Type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
60 foreach (PropertyInfo propertyInfo in propertyInfoArray)
62 CommandParameterAttribute[] commandAttributes = (CommandParameterAttribute[])
63 Attribute.GetCustomAttributes(propertyInfo, typeof(CommandParameterAttribute));
65 foreach (CommandParameterAttribute parameter in commandAttributes)
69 parameter.Description);