예제 #1
0
        public static List<Server> GetServers()
        {
            List<Server> newList = new List<Server>();
            Server s = new Server();
            s.Name = "WiNA";
            s.Address = "wina.ugent.be";
            s.Ident = "TangBot";
            s.MyNick = "YellingBird";
            s.MyDescription = "I'm AWESOME";
            s.Port = 6667;
            s.Channels = new List<Channel>();

            Channel c = new Channel();
            c.CName = "zeus";
            c.CFullName = "#zeus";
            c.CServer = s;
               // s.Channels.Add(c);

            c = new Channel();
            c.CName = "YellingBird";
            c.CFullName = "#YellingBird";
            c.CServer = s;
            s.Channels.Add( c );

            newList.Add( s );
            return newList;
        }
예제 #2
0
 private void KickUser( string message , User us , Channel chan )
 {
     Message msg = new Message();
     msg.Line = message;
     msg.MChannel = chan;
     msg.MType = MessageType.Kick;
     msg.MUser = us;
     msg.MServer = LastMessage.MServer;
     Reply( msg );
 }
예제 #3
0
        public bool Send( Message msg )
        {
            if ( msg.MServer == null || msg.MChannel == null )
            {
                string builtMessage = msg.Line;
                msg.MServer = new Server();
                //return ConnManager.Instance.Send( msg.MServer , builtMessage );
                return false;
            }
            else if ( msg.MType == MessageType.Message )
            {
                string builtMessage = "PRIVMSG " + msg.MChannel.CFullName + " :" + msg.Line;
                return ConnManager.Instance.Send( msg.MServer , builtMessage );
            }
            else if ( msg.MType == MessageType.Action )
            {
                string builtMessage = "PRIVMSG " + msg.MChannel.CFullName + " :" + "\u0001" + "ACTION " + msg.Line + "\u0001";
                return ConnManager.Instance.Send( msg.MServer , builtMessage );
            }
            else if ( msg.MType == MessageType.Join )
            {
                string builtMessage = "JOIN " + msg.Line;
                Channel c = new Channel();
                c.CFullName = msg.Line;
                c.CName = msg.Line.Replace( "#" , "" );
                c.CServer = msg.MServer;
                msg.MServer.Channels.Add( c );
                return ConnManager.Instance.Send( msg.MServer , builtMessage );
            }
            else if ( msg.MType == MessageType.Part )
            {
                string builtMessage = "PART " + msg.MChannel.CFullName;
                msg.MServer.Channels.Remove( msg.MChannel );
                return ConnManager.Instance.Send( msg.MServer , builtMessage );
            }
            else if ( msg.MType == MessageType.Quit )
            {
                string builtMessage = "QUIT :" + msg.Line;
                //ConnManager.Instance.Sockets.Remove( msg.MServer );
                return ConnManager.Instance.Send( msg.MServer , builtMessage );

            }
            else if ( msg.MType == MessageType.Kick )
            {
                string builtMessage = "KICK " + msg.MChannel.CFullName + " " + msg.MUser.Nick + " :" + msg.Line;
                return ConnManager.Instance.Send( msg.MServer , builtMessage );
            }
            else return false;
        }
예제 #4
0
 public UnknownChannelException( Server server , Channel channel )
     : base()
 {
     this.server = server;
     this.channel = channel;
 }
예제 #5
0
 private void BuildUserList( string right , Server server , Channel channel )
 {
     string[] rightparts = right.Split( new char[] { ' ' } );
     foreach ( string nick in rightparts )
     {
         string n = nick;
         n = n.Replace( "@" , "" );
         n = n.Replace( "+" , "" );
         n = n.Replace( "&" , "" );
         User result = ( from User y in server.AllUsers where y.Nick.Equals( n ) select y ).FirstOrDefault();
         if ( result == null )
         {
             result = new User();
             result.Nick = n;
             result.UServer = server;
             server.AllUsers.Add( result );
         }
         if ( !channel.CUsers.Contains( result ) )
         {
             channel.CUsers.Add( result );
         }
         if ( result.Ident == null )
         {
             ConnManager.Instance.Send( server , "WHOIS " + n );
         }
     }
 }