/// <summary> /// Parses and handles raw server messages /// </summary> /// <param name="message">The raw message from the server</param> public void Parse(string message) { OnAnything.Fire(this, new EventArgs()); Debug.WriteLine(string.Format("RAW: \"{0}\"", message)); IrcMessage ircMessage = ParseIrcMessage(message); switch (ircMessage.Tokens[0]) { case PING: OnPing?.Invoke(ircMessage.Message); break; case NOTICE: OnPrivateNotice.Fire(this, new UserMessageEventArgs(User.Empty, ircMessage.Message)); break; case ERROR: Error(ReplyCode.IrcServerError, ircMessage.Message); break; default: if (_replyRegex.IsMatch(message)) { ParseReply(ircMessage.Tokens); } else { ParseCommand(ircMessage.Tokens); } break; } }
public void ProcessNoticeCommand(IrcMessage ircMessage) { var fromUser = Rfc2812Util.UserFromString(ircMessage.From); if (Rfc2812Util.IsValidChannelName(ircMessage.Target)) { OnPublicNotice.Fire(this, new UserChannelMessageEventArgs( fromUser, ircMessage.Target, ircMessage.Message)); //Trace.WriteLine("Public notice", "IRC"); } else { OnPrivateNotice.Fire(this, new UserMessageEventArgs(fromUser, ircMessage.Message)); //Trace.WriteLine("Private notice", "IRC"); } }
public void ProcessNoticeCommand(string[] tokens) { tokens[3] = RemoveLeadingColon(tokens[3]); if (Rfc2812Util.IsValidChannelName(tokens[2])) { OnPublicNotice.Fire(this, new UserChannelMessageEventArgs( Rfc2812Util.UserFromString(tokens[0]), tokens[2], CondenseStrings(tokens, 3))); //Trace.WriteLine("Public notice", "IRC"); } else { OnPrivateNotice.Fire(this, new UserMessageEventArgs( Rfc2812Util.UserFromString(tokens[0]), CondenseStrings(tokens, 3))); //Trace.WriteLine("Private notice", "IRC"); } }