Exemple #1
0
 public IRCMessage()
 {
     this.Tags    = null;
     this.Prefix  = null;
     this.Command = null;
     this.Params  = null;
 }
Exemple #2
0
        public IRCMessage Parse(string text)
        {
            var span = new StringSpan(text);
            var peek = span.PeekChar();

            if (peek == IRCMessage.TagsPrefix)
            {
                span.NextChar();
                var tagsText = span.TakeToSeparator(IRCMessage.TagsSuffix, false, true);
                this.Tags = new IRCTags().Parse(tagsText);
            }
            else
            {
                this.Tags = null;
            }

            peek = span.PeekChar();

            if (peek == IRCMessage.PrefixsPrefix)
            {
                span.NextChar();
                var prefixText = span.TakeToSeparator(IRCMessage.PrefixsSuffix, false, true);
                this.Prefix = new IRCPrefix().Parse(prefixText);
            }
            else
            {
                this.Prefix = null;
            }

            var commandText = span.TakeToSeparator(IRCParams.ParamsPrefix, false);

            this.Command = commandText;

            var paramsText = span.TakeToEnd();

            this.Params = new IRCParams().Parse(paramsText);

            return(this);
        }