Esempio n. 1
0
        /// <summary>
        /// Join an IRC channel.
        /// </summary>
        /// <param name="name">Name of channel (without leading #).</param>
        /// <returns>New channel.</returns>
        public IrcChannel JoinChannel(string name)
        {
            IrcChannel channel = new IrcChannel(this, name);

            channels.Add(channel);
            /* JOIN ( <channel> *( "," <channel> ) [ <key> *( "," <key> ) ] ) / "0" */
            SendMessage(new IrcMessage(IRC.JOIN, String.Format("#{0}", name)));
            return(channel);
        }
Esempio n. 2
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));
            }
        }
Esempio n. 3
0
 public ChannelUserDatabaseChangedEventArgs(IrcChannel item)
 {
     Channel = item;
 }