private static string BuildParameterList(Dictionary<string, ObjectOutput> properties) { return properties.None() ? "no properties " : properties .Select(kv => "{0} [{1}]".FormatWith(kv.Key, GetTypeName(kv.Value.GetTypedValue()))) .Join(", "); }
/// <summary> /// Lists the modules. /// </summary> /// <param name="user">The user.</param> /// <param name="channel">The channel.</param> /// <param name="messageType">Type of the message.</param> /// <param name="messageFormat">The message format.</param> /// <param name="message">The message.</param> /// <param name="arguments">The arguments.</param> private void ListModules(User user, string channel, MessageType messageType, MessageFormat messageFormat, string message, Dictionary<string, string> arguments) { var targets = new[] { user.Nick }; if (arguments.None()) { this.SendCommandUsageExamples(this, targets, messageType, messageFormat); } foreach (var key in arguments.Keys) { AccessLevel level; if (Enum.TryParse(key, ignoreCase: true, result: out level)) { foreach (var module in this.IrcClient.Modules.Where(m => m.Commands.Any(c => c.LevelRequired <= level && c.LevelRequired <= user.AccessLevel))) { var moduleInfoResponse = new Response("{0}: {1}".FormatWith(module.Name, module.Description), targets, MessageFormat.Notice, messageType); this.SendResponse(moduleInfoResponse); } } } if (arguments.ContainsKey("list")) { #region Send all Module descriptions foreach (var module in this.IrcClient.Modules.Where(m => m.Commands.Any(c => c.LevelRequired <= user.AccessLevel))) { var moduleInfoResponse = new Response("{0}: {1}".FormatWith(module.Name, module.Description), targets, MessageFormat.Notice, messageType); this.SendResponse(moduleInfoResponse); } #endregion this.GetMoreInformation(messageType, targets); } if (arguments.ContainsKey("examples")) { // For each module where the module has a command that is accessible by this user foreach (var module in this.IrcClient.Modules.Where(m => m.Commands.Any(c => c.LevelRequired <= user.AccessLevel))) { #region Module Description var response = new Response("{0}: {1}".FormatWith(module.Name, module.Description), targets, MessageFormat.Notice, messageType); this.SendResponse(response); #endregion #region Usage Examples response.Message = "Usage Examples: "; this.SendResponse(response); this.SendCommandUsageExamples(module, targets, messageType, MessageFormat.Notice); #endregion } } }