private void Session_InfoReceived(object sender, IrcInfoEventArgs e)
        {
            switch (e.Code)
            {
            case IrcCode.RPL_LIST:
                int count;
                if (e.Message.Parameters.Count == 4 &&
                    int.TryParse(e.Message.Parameters[2], out count))
                {
                    _channels.Add(new ChannelItem(e.Message.Parameters[1], count, e.Message.Parameters[3]));
                    this.Count++;
                }
                break;

            case IrcCode.RPL_LISTEND:
                this.IsCloseable           = true;
                this.Session.InfoReceived -= new EventHandler <IrcInfoEventArgs>(Session_InfoReceived);
                _channels.Sort();
                foreach (var c in _channels)
                {
                    lstChannels.Items.Add(c);
                }
                break;
            }
        }
Exemple #2
0
        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", 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", 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",
                               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", 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", 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", 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", 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.Text);
            }
        }