}

        // TODO
        public virtual IRCUserConnection[] SearchUsers(string ident)
        {
            // sample *!~*@host*
            // *!~*@host.de
            // *[email protected]
            // [email protected]

            ArrayList list = new ArrayList();

            // TODO if (!RFC2812.isvalidident(ident)
            // return null
            foreach (IRCUserConnection src in this._users) // TODO: liste ist leer
            {
            //				if (src.Match(ident))
            //					list.Add(src);
            }

            IRCUserConnection[] all = new IRCUserConnection[list.Count];
            for (int i = 0; i < list.Count; i++)
            {
                all[i] = (IRCUserConnection)list[i];
            }
        // methode entfernen
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender">IRCUserConnection</param>
        /// <param name="command"></param>
        /// <param name="args"></param>
        public void SendCommand(IRCUserConnection sender, string command, params string[] args)
        {
            if (sender == null)
                throw new ArgumentNullException("sender");

            base.SendCommand(sender.UserPrefix(), command, args);
        }
        public void RegisterUser(IRCConnection con)
        {
            if (con == null)
                throw new ArgumentNullException("con");

            lock (con)
            {
                if (con is IRCConnection)
                {
                    IRCUserConnection usr;
                    this.RemoveConnection(con);
                    usr = new IRCUserConnection(con);
                    this.AddConnection(usr);
                    // TODO: if (this.IsFull)
                    // TODO: this.AddUser(usr.SimpleUser);
                    // send bounce 005
                }
                else
                {
                    con.SendLine("ERROR :You could not register! Internal error");
                }
            }
        }
        }

        /// <summary>
        /// </summary>
        public virtual void RemoveFromChannels(IRCUserConnection usr, string message)
        {
            //			throw new NotImplementedException("Add support for IRCUserConnection.Channels");

            Console.WriteLine("RemoveFromChannels()");
            foreach (DictionaryEntry entry in (Hashtable)usr.Channels.Clone())
            {
                Channel chan = (Channel)entry.Value;
                if (chan.HasConnection(usr))
                {
                    Console.WriteLine("Remove connection from: {0}", chan.Name);
                    chan.RemoveUser(usr.SimpleUser, ExitType.Quit);
                }
Esempio n. 5
0
 private void InformUsers(IRCUserConnection connection, string rquested_nick)
 {
 }
 /// <summary>
 /// Join a channel
 /// </summary>
 /// <param name="client">Connection</param>
 /// <param name="channel">Name of the channel to join</param>
 public virtual void Join(IRCUserConnection client, string channel)
 {
     lock (this._channels)
     {
         if (!this._channels.Contains(channel))
         {
             if (RFC2812.IsValidChannelName(channel)) // channel prefix(&,#), lenght, etc.
             {
                 this.CreateChannel(channel);
                 //connection.channel umode +creator
             }
         }
         lock (client)
         {
             Channel ch = (Channel)this._channels[channel];
             if (ch.CanJoin(client))
             {
                 Console.WriteLine("{0} can join {1}", client.ID, channel);
                 client.Join(ch);
             }
         }
     }
 }
Esempio n. 7
0
 private void NickTaken(IRCUserConnection connection)
 {
     // nick already in use
     // 433
 }
        public virtual void SendWho(IRCUserConnection client, bool only_ops)
        {
            Console.WriteLine(this + ".SendWho()");
            bool is_member, is_visible;

            if (!this.HasConnection(client))
                is_member = false;
            else
                is_member = true;
            #if false
            if (!is_member && this.HasMode('s')) // secret chan
                return; // user is not in the channel -> return
            #endif
            if (is_member || !this.HasMode('s'))
            {
                foreach (SimpleUser usr in this._users)
                {
            //					IRCUserConnection usr = (IRCUserConnection)dict.Value; // TODO: MUSS mal ein SimpleUser sein

                    if (usr.UserMode.HasMode(IRCUserModes.MODE_INVISIBLE))
                        is_visible = false;
                    else
                        is_visible = true;

                    if (is_visible || is_member)
                    {
                    //	if (only_ops && !usr.ChanUserMode.get(this, IRCUserModes.MODE_OP)) // TODO
                    //		continue;

                    //:irc.localhost 352 test #test ~aa localhost irc.localhost test H :0 aa
            //[channel] [user] [host] [server] [nick]( "H" / "G" > ["*"] [ ( "@" / "+" ) ] :[hopcount] [real name]
            //:amd                    352 blackdragon #test    aa    127.0.0.1      amd              blackdragon H :0 aa
            //:example.irc.org 352 blackdragon #test ~aa localhost.tux example.irc.org blackdragon H* :0 aa

                        client.SendCommand(ReplyCodes.RPL_WHOREPLY, client.NickName, this.Name, usr.UserName, "127.0.0.1" /*usr.HostName/*todo*/, this._server.ServerName, usr.NickName, "H"/*( "H" / "G" > ["*"] [ ( "@" / "+" ) ]*/, String.Format("{0} {1}", usr.HopCount, usr.RealName));//, true); // true ein ":" beim letzen parameter
                    }
                }
            }
            client.SendCommand(ReplyCodes.RPL_ENDOFWHO, client.NickName, this.Name, ":End of /WHO list.");
        }
        public virtual void SendNames(IRCUserConnection client)
        {
            string line = ":";
            string[] nicks = this.Nicks;
            for (int j = 0; j < nicks.Length; j++)
            {
                if (j == nicks.Length-1)
                    line += nicks[j];
                else
                    line += nicks[j] + ' ';
            }

            client.SendCommand(ReplyCodes.RPL_NAMREPLY, client.NickName, "=", this.Name, line); // TODO: liste kann zu lang werden
            client.SendCommand(ReplyCodes.RPL_ENDOFNAMES, client.NickName, this.Name, ":End of NAMES list");
        }
        public virtual void do_join(IRCUserConnection connection, bool confirmation)
        {
            Console.WriteLine("do_join() new; id: {0}", connection.ID);
            lock (connection)
            {
                if (this.CanJoin(connection))
                {
                    this.AddUser(connection.SimpleUser);

                    if (confirmation)
                    {
                        Console.WriteLine("Send Join command to client");
                        // TODO: SendCommand auch in do_part
                        connection.SendLine(":" + connection.NickName + "!" + connection.UserName + "@" +
                      	        connection.HostName + " JOIN :" + this.Name);
                        this.SendNames(connection);
                    }
                }
            }
        }
 public virtual bool CanJoin(IRCUserConnection usr)
 {
     // if (connection.Channels.Contains(this))
     //  return false;
     //	if (this.HasConnection(connection))
     //		return false;
     // if (this.max == this.client.count)
     //	return false;
     // if (this.modes.contain(EINGELADNE)
     //   if (connection.geteingeladen)
     //     return false;
     // else
     //  return false;
     return true;
 }