public override void Process(CmdTrigger trigger)
{
var match = trigger.Args.NextWord();
IList<Command> cmds;
if (match.Length > 0)
{
cmds = new List<Command>();
foreach (var cmd in IrcCommandHandler.List)
{
if (cmd.Enabled &&
trigger.MayTrigger(cmd) &&
cmd.Aliases.FirstOrDefault(ali => ali.IndexOf(match, StringComparison.InvariantCultureIgnoreCase) != -1) != null)
{
cmds.Add(cmd);
}
}
if (cmds.Count == 0)
{
trigger.Reply("Could not find a command matching '{0}'", match);
}
else
{
trigger.Reply("Found {0} matching commands: ", cmds.Count);
}
}
else
{
trigger.Reply("Use \"Help <searchterm>\" to receive help on a certain command. - All current commands:");
cmds = IrcCommandHandler.List.Where(cmd => cmd.Enabled && trigger.MayTrigger(cmd)).ToList();
}
var line = "";
foreach (var cmd in cmds)
{
if (cmds.Count <= MaxUncompressedCommands)
{
var desc = string.Format("{0} ({1})", cmd.Usage, cmd.Description);
trigger.Reply(desc);
}
else
{
var info = cmd.Name;
info += " (" + cmd.Aliases.ToString(", ") + ") ";
if (line.Length + info.Length >= IrcProtocol.MaxLineLength)
{
trigger.Reply(line);
line = "";
}
line += info;
}
}
if (line.Length > 0)
{
trigger.Reply(line);
}
}