private ParseResult ParseModeCommand(string payload)
{
ParseResult retval;
string pattern = @"/mode(\s+(?<target>[^\s]+))?(\s+(?<modestr>[^\s]+))?(\s+(?<args>.+))?";
Regex regex = new Regex(pattern, RegexOptions.IgnoreCase);
Match match = regex.Match(payload);
if (match.Success)
{
List<string> parameters = new List<string>();
if (match.Groups["target"].Success)
{
parameters.Add(match.Groups["target"].Value);
if (match.Groups["modestr"].Success)
{
parameters.Add(match.Groups["modestr"].Value);
if (match.Groups["args"].Success)
{
parameters.AddRange(match.Groups["args"].Value.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries));
}
}
}
this.Parameters = parameters.ToArray();
retval = new ParseResult(true, string.Empty);
}
else
{
retval = new ParseResult(false, string.Empty);
}
return retval;
}