Beispiel #1
0
        /// <summary>
        /// Process RPL_ENDOFNAMES message.
        /// </summary>
        /// <param name="message">Received IRC message.</param>
        private void RPL_ENDOFNAMESMessageReceived(object sender, IrcMessageReceivedEventArgs e)
        {
            IrcMessage message = e.Message;

            try
            {
                /* <channel> :End of NAMES list */
                if (message.Parameters == null)
                {
                    System.Diagnostics.Debug.WriteLine(String.Format("Message has no parameters."));
                    return;
                }

                string[]   parameters = message.Parameters.Split(new char[] { ' ' });
                IrcChannel channel    = LocateChannel(parameters[1].Substring(1));
                if (channel == null)
                {
                    System.Diagnostics.Debug.WriteLine(String.Format("Channel not found '{0}'.",
                                                                     parameters[0].Substring(1)));
                    return;
                }

                OnChannelUserDatabaseChanged(channel);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(String.Format("Ex. {0}", ex));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Send a PONG message when a PING message is received.
        /// </summary>
        /// <param name="message">Received IRC message.</param>
        private void PingMessageReceived(object sender, IrcMessageReceivedEventArgs e)
        {
            IrcMessage message = e.Message;

            SendMessage(new IrcMessage(IRC.PONG, message.Parameters));
            firstPingReceived = true;
        }
Beispiel #3
0
        /// <summary>
        /// Send a PONG message when a PING message is received.
        /// </summary>
        /// <param name="message">Received IRC message.</param>
        private void NoticeMessageReceived(object sender, IrcMessageReceivedEventArgs e)
        {
            IrcMessage message = e.Message;

            if (awaitingGhostDeath)
            {
                string str = string.Format("{0} has been ghosted", reqNickname);
                if (message.Parameters.Contains(str))
                {
                    ChangeNick(reqNickname);
                    SubmitPassword(password);
                    awaitingGhostDeath = false;
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Process ERR_NICKNAMEINUSE message.
        /// </summary>
        /// <param name="message">Received IRC message.</param>
        private void ERR_NICKNAMEINUSEMessageReceived(object sender, IrcMessageReceivedEventArgs e)
        {
            IrcMessage message = e.Message;

            try
            {
                if (message.Parameters == null)
                {
                    System.Diagnostics.Debug.WriteLine(String.Format("Message has no parameters."));
                    return;
                }

                /* Connect with a different name */
                string[] parameters = message.Parameters.Split(new char[] { ' ' });
                string   nickname   = parameters[1];
                ChangeNick(nickname + "__");
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(String.Format("Ex. {0}", ex));
            }
        }
Beispiel #5
0
        /// <summary>
        /// Process RPL_NAMREPLY message.
        /// </summary>
        /// <param name="message">Received IRC message.</param>
        private void RPL_NAMREPLYMessageReceived(object sender, IrcMessageReceivedEventArgs e)
        {
            IrcMessage message = e.Message;

            try
            {
                // :Oslo2.NO.EU.undernet.org 353 E101 = #E101 :E101 KongFu_uK @Exception

                /* "( "=" / "*" / "@" ) <channel>
                 * :[ "@" / "+" ] <nick> *( " " [ "@" / "+" ] <nick> )
                 *      - "@" is used for secret channels, "*" for private
                 *      channels, and "=" for others (public channels). */
                if (message.Parameters == null)
                {
                    System.Diagnostics.Debug.WriteLine(String.Format("Message has no parameters."));
                    return;
                }
                string[] parameters = message.Parameters.Split(new char[] { ' ' });
                if (parameters.Length < 5)
                {
                    System.Diagnostics.Debug.WriteLine(String.Format("{0} is two few parameters.", parameters.Length));
                    return;
                }
                IrcChannelType type;
                switch (parameters[1])
                {
                case "=":
                    type = IrcChannelType.Public;
                    break;

                case "*":
                    type = IrcChannelType.Private;
                    break;

                case "@":
                    type = IrcChannelType.Secret;
                    break;

                default:
                    type = IrcChannelType.Public;
                    break;
                }
                IrcChannel channel = LocateChannel(parameters[2].Substring(1));
                if (channel == null)
                {
                    System.Diagnostics.Debug.WriteLine(String.Format("Channel not found '{0}'.",
                                                                     parameters[2].Substring(1)));
                    return;
                }
                else
                {
                    channel.Type = type;
                }
                string nickname = parameters[3];
                if (nickname[0] != ':')
                {
                    System.Diagnostics.Debug.WriteLine(String.Format("String should start with : and not {0}.", nickname[0]));
                    return;
                }
                /* Skip : */
                IrcUser user = channel.LocateUser(nickname.Substring(1));
                if (user == null)
                {
                    user = new IrcUser(this,
                                       nickname.Substring(1));
                    channel.Users.Add(user);
                }
                for (int i = 4; i < parameters.Length; i++)
                {
                    nickname = parameters[i];
                    user     = channel.LocateUser(nickname);
                    if (user == null)
                    {
                        user = new IrcUser(this,
                                           nickname);
                        channel.Users.Add(user);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(String.Format("Ex. {0}", ex));
            }
        }