Yaircc.Net.IRC.ModeMessage.ParseOpCommand C# (CSharp) Method

ParseOpCommand() private method

Parse a deop/dehop/hop/op command into the message.
private ParseOpCommand ( string payload ) : ParseResult
payload string The raw deop/dehop/hop/op command.
return ParseResult
        private ParseResult ParseOpCommand(string payload)
        {
            ParseResult retval;
            string pattern = @"/(?<command>deop|dehop|hop|op)\s+((?<channel>[#&!\+][^\x07\x2C\s]{1,199})\s+)?(?<nickname>.+)";
            Regex regex = new Regex(pattern, RegexOptions.IgnoreCase);
            Match match = regex.Match(payload);

            if (match.Success)
            {
                string modifier = match.Groups["command"].Value.StartsWith("de") ? "-" : "+";
                string mode = match.Groups["command"].Value.EndsWith("hop") ? "h" : "o";
                string channel = this.ChannelName;

                if (match.Groups["channel"].Success)
                {
                    channel = match.Groups["channel"].Value;
                }

                this.Parameters = new string[] { channel, modifier + mode, match.Groups["nickname"].Value };
                retval = new ParseResult(true, string.Empty);
            }
            else
            {
                retval = new ParseResult(false, Strings_MessageParseResults.MissingParameter_Nickname);
            }

            return retval;
        }