void Client_ModeReceived(Object sender, ModeReceivedEventArgs e) { IrcClient client = (IrcClient)sender; if (e.Aim != client.CurrentNick) return; StringBuilder modeLine = new StringBuilder(); for (int i = 1; i < e.BaseLine.Parameters.Length; i++) { modeLine.Append(e.BaseLine.Parameters[i]); modeLine.Append(' '); } AddLine(String.Format("{0} sets mode: {1}", e.Setter, modeLine)); }
/// <summary> /// Handles a line received from server. /// </summary> private void HandleLine(LineReceivedEventArgs e) { if (e.Line.IsNumeric) { if (NumericReceived != null) NumericReceived(this, new NumericReceivedEventArgs(e.Line)); switch (e.Line.Numeric) { case 1: // Parse the Server Info currentNick = e.Line.Parameters[0]; networkName = e.Line.Parameters[1].Split(' ')[3]; myUserInfo = new UserInfo(e.Line.Parameters[1].Split(' ')[6], this); break; case 3: // Parse Welcome-Message loggedIn = true; if (Login != null) Login(this, new LoginEventArgs(NetworkName, CurrentNick, this)); break; case 376: // End of MOTD message loggedIn = true; if (Login != null) Login(this, new LoginEventArgs(NetworkName, CurrentNick, this)); break; } } else { e.Handled = true; switch (e.Line.Command) { case "PING": // Handle the Ping here PingReceivedEventArgs pingArgs = new PingReceivedEventArgs(e.Line); if (PingReceived != null) PingReceived(this, pingArgs); if (!pingArgs.Handled) if (e.Line.Parameters.Length > 0) SendLine("PONG :" + e.Line.Parameters[0]); else SendLine("PONG"); break; case "JOIN": //Parse Join-Message JoinReceivedEventArgs joinArgs = new JoinReceivedEventArgs(e.Line); if (JoinReceived != null) JoinReceived(this, joinArgs); break; case "PART": //Parse Part-Message PartReceivedEventArgs partArgs = new PartReceivedEventArgs(e.Line); if (PartReceived != null) PartReceived(this, partArgs); break; case "QUIT": //Parse Quit-Message QuitReceivedEventArgs quitArgs = new QuitReceivedEventArgs(e.Line); if (QuitReceived != null) QuitReceived(this, quitArgs); break; case "NICK": //Parse Nick-Message if(e.Line.Client.ToString() == this.ToString()) this.currentNick = e.Line.Parameters[0]; NickChangeReceivedEventArgs nickChangeArgs = new NickChangeReceivedEventArgs(e.Line); if (NickChangeReceived != null) NickChangeReceived(this, nickChangeArgs); break; case "MODE": //Parse Mode-Message ModeReceivedEventArgs modeArgs = new ModeReceivedEventArgs(e.Line); if (ModeReceived != null) ModeReceived(this, modeArgs); break; case "NOTICE": //Parse Notice-Message NoticeReceivedEventArgs noticeArgs = new NoticeReceivedEventArgs(e.Line); if (NoticeReceived != null) NoticeReceived(this, noticeArgs); break; case "PRIVMSG": //Parse Private-Message PrivateMessageReceivedEventArgs privmsgArgs = new PrivateMessageReceivedEventArgs(e.Line); if (PrivateMessageReceived != null) PrivateMessageReceived(this, privmsgArgs); break; case "KICK": //Parse Kick-Message KickReceivedEventArgs kickArgs = new KickReceivedEventArgs(e.Line); if (KickReceived != null) KickReceived(this, kickArgs); break; default: e.Handled = false; break; } } }