public static bool TryParse(string input, out IRCMessage output) { Regex parser = new Regex(@"^:(?<nick>[^ \t\n]+?)(?([^ ]+)!(?<uname>[^\n\t ]+)@(?<host>[^\n\t\s ]+)) (?<type>[A-Z]+) ((?<target>[^ ]+) )?:(?<content>.*)"); Match match = parser.Match(input); if (match.Length == 0) { output = new IRCMessage(); return false; } else { output = new IRCMessage(); GroupCollection groups = match.Groups; output.type = groups["type"].Value; output.sender = groups["nick"].Value; if (groups["uname"].Success) { output.username = groups["uname"].Value; output.host = groups["host"].Value; } if (groups["target"].Success) output.target = groups["target"].Value; output.content = groups["content"].Value; return true; } }
public bool ReadMessage(out IRCMessage output) { return MessageQueue.TryDequeue(out output); }