Exemplo n.º 1
0
        public Mask GetMatch(IrcUser user)
        {
            var match = Masks.FirstOrDefault(m => user.Match(m.Value));

            if (match == null)
            {
                throw new KeyNotFoundException("No mask matches the specified user.");
            }
            return(match);
        }
Exemplo n.º 2
0
        public PrivateMessage(IrcMessage message, ServerInfo serverInfo)
        {
            Source  = message.Parameters[0];
            Message = message.Parameters[1];

            User = new IrcUser(message.Prefix);
            //if (serverInfo.ChannelTypes.Any(c => Source.StartsWith(c.ToString())))
            IsChannelMessage = true;
            //else
            //    Source = User.Nick;
        }
Exemplo n.º 3
0
 internal ExtendedWho()
 {
     QueryType = -1;
     Channel   = "*";
     User      = new IrcUser();
     IP        = string.Empty;
     Server    = string.Empty;
     Flags     = string.Empty;
     Hops      = -1;
     TimeIdle  = -1;
     OpLevel   = "n/a";
 }
Exemplo n.º 4
0
        public PrivateMessage(IrcMessage message)
        {
            Source  = message.Parameters[0];
            Message = message.Parameters[1];

            User = new IrcUser(message.Prefix);
            if (Source.StartsWith("#"))
            {
                IsChannelMessage = true;
            }
            else
            {
                Source = User.Nick;
            }
        }
Exemplo n.º 5
0
        public IrcClient(string serverAddress, IrcUser user)
        {
            if (serverAddress == null)
            {
                throw new ArgumentNullException("serverAddress");
            }
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            User          = user;
            ServerAddress = serverAddress;
            Encoding      = Encoding.UTF8;
            Channels      = new ChannelCollection(this);
            Settings      = new ClientSettings();
            Handlers      = new Dictionary <string, MessageHandler>();
            MessageHandlers.RegisterDefaultHandlers(this);
            RequestManager = new RequestManager();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a new IRC client, but will not connect until ConnectAsync is called.
        /// </summary>
        /// <param name="serverAddress">Server address including port in the form of "hostname:port".</param>
        /// <param name="user">The IRC user to connect as.</param>
        /// <param name="useSSL">Connect with SSL if true.</param>
        public IrcClient(string serverAddress, IrcUser user, bool useSSL = false)
        {
            if (serverAddress == null)
            {
                throw new ArgumentNullException("serverAddress");
            }
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            user.Client   = this;
            User          = user;
            ServerAddress = serverAddress;
            Encoding      = Encoding.UTF8;
            Settings      = new ClientSettings();
            Handlers      = new Dictionary <string, MessageHandler>();
            MessageHandlers.RegisterDefaultHandlers(this);
            RequestManager = new RequestManager();
            UseSSL         = useSSL;
            WriteQueue     = new ConcurrentQueue <string>();
            ServerInfo     = new ServerInfo();
            PrivmsgPrefix  = "";
            Channels       = User.Channels = new ChannelCollection(this);
            Users          = new UserPool(this);
            Users.Add(User); // Add self to user pool
            Capabilities = new CapabilityPool();

            // List of supported capabilities
            Capabilities.AddRange(new string[] {
                "server-time", "multi-prefix", "cap-notify", "znc.in/server-time", "znc.in/server-time-iso",
                "account-notify", "chghost", "userhost-in-names", "sasl"
            });

            IsNegotiatingCapabilities = false;
            IsAuthenticatingSasl      = false;

            RandomNumber = new Random();
        }
Exemplo n.º 7
0
        public IrcClient(string serverAddress, IrcUser user, bool useSSL = false)
        {
            if (serverAddress == null)
            {
                throw new ArgumentNullException("serverAddress");
            }
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            User          = user;
            PartMessage   = "";
            ServerAddress = serverAddress;
            Encoding      = Encoding.UTF8;
            Channels      = new ChannelCollection(this);
            Settings      = new ClientSettings();
            Handlers      = new Dictionary <string, MessageHandler>();
            MessageHandlers.RegisterDefaultHandlers(this);
            RequestManager = new RequestManager();
            UseSSL         = useSSL;
            WriteQueue     = new ConcurrentQueue <string>();
        }
Exemplo n.º 8
0
 public bool ContainsMatch(IrcUser user)
 {
     return(Masks.Any(m => user.Match(m.Value)));
 }
Exemplo n.º 9
0
 public Mask(string value, IrcUser creator, DateTime creationTime)
 {
     Value        = value;
     Creator      = creator;
     CreationTime = creationTime;
 }
Exemplo n.º 10
0
 internal WhoIs()
 {
     User        = new IrcUser();
     SecondsIdle = -1;
     Channels    = new string[0];
 }