private void OnOther(IrcMessage message) { int code; if (int.TryParse(message.Command, out code)) { var e = new IrcInfoEventArgs(message); if (e.Code == IrcCode.RPL_WELCOME) { if (e.Text.StartsWith("Welcome to the ")) { var parts = e.Text.Split(' '); this.NetworkName = parts[3]; } this.State = IrcSessionState.Connected; } if (_captures.Count > 0) { lock (_captures) { var capture = _captures.Where((c) => c.Codes.Contains(e.Code)).FirstOrDefault(); if (capture != null) { if (capture.Handler(e)) { _captures.Remove(capture); } if (e.Handled) { return; } } } } this.RaiseEvent(this.InfoReceived, e); } }
private void session_InfoReceived(object sender, IrcInfoEventArgs e) { var session = sender as IrcSession; switch (e.Code) { case IrcCode.RPL_LISTSTART: App.Create(session, new ListControl(session), true); break; } }
private void Session_InfoReceived(object sender, IrcInfoEventArgs e) { switch (e.Code) { case IrcCode.ERR_NICKNAMEINUSE: if (this.IsServer && this.Session.State == IrcSessionState.Connecting) { if (_usingAlternateNick || string.IsNullOrEmpty(App.Settings.Current.User.AlternateNickname)) { this.SetInputText("/nick "); } else { this.Session.Nick(App.Settings.Current.User.AlternateNickname); _usingAlternateNick = true; } } break; case IrcCode.RPL_TOPIC: if (e.Message.Parameters.Count == 3 && !this.IsServer && this.Target.Equals(new IrcTarget(e.Message.Parameters[1]))) { _topic = e.Message.Parameters[2]; this.SetTitle(); this.Write("Topic", e.Message.Time, string.Format("Topic is: {0}", _topic)); } return; case IrcCode.RPL_TOPICSETBY: if (e.Message.Parameters.Count == 4 && !this.IsServer && this.Target.Equals(new IrcTarget(e.Message.Parameters[1]))) { this.Write("Topic", e.Message.Time, string.Format("Topic set by {0} on {1}", e.Message.Parameters[2], this.FormatTime(e.Message.Parameters[3]))); } return; case IrcCode.RPL_CHANNELCREATEDON: if (e.Message.Parameters.Count == 3 && !this.IsServer && this.Target.Equals(new IrcTarget(e.Message.Parameters[1]))) { //this.Write("ServerInfo", string.Format("* Channel created on {0}", this.FormatTime(e.Message.Parameters[2]))); } return; case IrcCode.RPL_WHOISUSER: case IrcCode.RPL_WHOWASUSER: if (e.Message.Parameters.Count == 6 && this.IsDefault) { this.Write("ServerInfo", e.Message.Time, string.Format("{1} " + (e.Code == IrcCode.RPL_WHOWASUSER ? "was" : "is") + " {2}@{3} {4} {5}", (object[])e.Message.Parameters)); return; } break; case IrcCode.RPL_WHOISCHANNELS: if (e.Message.Parameters.Count == 3 && this.IsDefault) { this.Write("ServerInfo", e.Message.Time, string.Format("{1} is on {2}", (object[])e.Message.Parameters)); return; } break; case IrcCode.RPL_WHOISSERVER: if (e.Message.Parameters.Count == 4 && this.IsDefault) { this.Write("ServerInfo", e.Message.Time, string.Format("{1} using {2} {3}", (object[])e.Message.Parameters)); return; } break; case IrcCode.RPL_WHOISIDLE: if (e.Message.Parameters.Count == 5 && this.IsDefault) { this.Write("ServerInfo", e.Message.Time, string.Format("{0} has been idle {1}, signed on {2}", e.Message.Parameters[1], this.FormatTimeSpan(e.Message.Parameters[2]), this.FormatTime(e.Message.Parameters[3]))); return; } break; case IrcCode.RPL_INVITING: if (e.Message.Parameters.Count == 3 && this.IsDefault) { this.Write("ServerInfo", e.Message.Time, string.Format("Invited {0} to channel {1}", e.Message.Parameters[1], e.Message.Parameters[2])); return; } break; case IrcCode.RPL_LIST: case IrcCode.RPL_LISTSTART: case IrcCode.RPL_LISTEND: e.Handled = true; break; } if (!e.Handled && ((int)e.Code < 200 && this.IsServer || this.IsDefault)) { this.Write("ServerInfo", e.Message.Time, e.Text); } }
private void Session_InfoReceived(object sender, IrcInfoEventArgs e) { this.BeginInvoke(() => { switch (e.Code) { case IrcCode.NicknameInUse: if (this.IsServer && this.Session.State == IrcSessionState.Connecting) { if (_usingAlternateNick || string.IsNullOrEmpty(App.Settings.Current.User.AlternateNickname)) { this.SetInputText("/nick "); } else { this.Session.Nick(App.Settings.Current.User.AlternateNickname); _usingAlternateNick = true; } } break; case IrcCode.Topic: if (e.Message.Parameters.Count == 3 && !this.IsServer && this.Target.Equals(new IrcTarget(e.Message.Parameters[1]))) { _topic = e.Message.Parameters[2]; this.SetTitle(); this.Write("Topic", string.Format("Topic is: {0}", _topic)); } return; case IrcCode.TopicSetBy: if (e.Message.Parameters.Count == 4 && !this.IsServer && this.Target.Equals(new IrcTarget(e.Message.Parameters[1]))) { this.Write("Topic", string.Format("Topic set by {0} on {1}", e.Message.Parameters[2], this.FormatTime(e.Message.Parameters[3]))); } return; case IrcCode.ChannelCreatedOn: if (e.Message.Parameters.Count == 3 && !this.IsServer && this.Target.Equals(new IrcTarget(e.Message.Parameters[1]))) { //this.Write("ServerInfo", string.Format("* Channel created on {0}", this.FormatTime(e.Message.Parameters[2]))); } return; case IrcCode.WhoisUser: case IrcCode.WhoWas: if (e.Message.Parameters.Count == 6 && this.IsDefault) { this.Write("ServerInfo", string.Format("{1} " + (e.Code == IrcCode.WhoWas ? "was" : "is") + " {2}@{3} {4} {5}", (object[])e.Message.Parameters)); return; } break; case IrcCode.WhoisChannels: if (e.Message.Parameters.Count == 3 && this.IsDefault) { this.Write("ServerInfo", string.Format("{1} is on {2}", (object[])e.Message.Parameters)); return; } break; case IrcCode.WhoisServer: if (e.Message.Parameters.Count == 4 && this.IsDefault) { this.Write("ServerInfo", string.Format("{1} using {2} {3}", (object[])e.Message.Parameters)); return; } break; case IrcCode.WhoisIdle: if (e.Message.Parameters.Count == 5 && this.IsDefault) { this.Write("ServerInfo", string.Format("{0} has been idle {1}, signed on {2}", e.Message.Parameters[1], this.FormatTimeSpan(e.Message.Parameters[2]), this.FormatTime(e.Message.Parameters[3]))); return; } break; } if ((int)e.Code < 200 && this.IsServer || this.IsDefault) { this.Write("ServerInfo", e.Text); } }); }