Example #1
0
 public User(string nick, string channel, UserRank rank)
 {
     Console.WriteLine($"User created with channel: {nick} {channel} {rank}");
     Nick = nick;
     if (!ranks.ContainsKey(channel))
         ranks.TryAdd(channel, new List<UserRank>());
     ranks[channel].Add(rank);
 }
Example #2
0
 public User(string nick, string channel, UserRank rank)
 {
     Console.WriteLine($"User created with channel: {nick} {channel} {rank}");
     Nick = nick;
     if (!ranks.ContainsKey(channel))
     {
         ranks.TryAdd(channel, new List <UserRank>());
     }
     ranks[channel].Add(rank);
 }
Example #3
0
        /// <summary>
        /// Returns the user whose nickname is equal to the value specified.
        /// </summary>
        public User UserFromNick(string nick)
        {
            //Remove rank from nick
            var rank = UserRank.FromPrefix(nick[0]);

            if (rank != UserRank.None)
            {
                nick = nick.Substring(1);
            }
            return(Users.FirstOrDefault(u => u.Nick.Equals(nick, StringComparison.OrdinalIgnoreCase)));
        }
Example #4
0
 public void RemoveRank(Client client, string channel, UserRank rank)
 {
     if (ranks.ContainsKey(channel) && ranks[channel].Contains(rank))
     {
         ranks[channel].Remove(rank);
         if (!ranks[channel].Contains(UserRank.None))
         {
             ranks[channel].Add(UserRank.None);
         }
         client.OnRankChange(this, channel, ranks[channel].Min());
     }
 }
Example #5
0
 public void AddRank(Client client, string channel, UserRank rank)
 {
     Console.WriteLine($"Rank of {this} for {channel} on {client.Host} added: {rank}");
     if (!ranks.ContainsKey(channel))
     {
         ranks.TryAdd(channel, new List <UserRank>());
     }
     if (!ranks[channel].Contains(rank))
     {
         if (!ranks[channel].Contains(UserRank.None))
         {
             ranks[channel].Add(UserRank.None);
         }
         ranks[channel].Add(rank);
         client.OnRankChange(this, channel, ranks[channel].Min());
     }
 }
Example #6
0
 internal void OnRankChange(User user, string channel, UserRank rank) => RankChange?.Invoke(user, channel, rank);
Example #7
0
 public void RemoveRank(Client client, string channel, UserRank rank)
 {
     if (ranks.ContainsKey(channel) && ranks[channel].Contains(rank))
     {
         ranks[channel].Remove(rank);
         if (!ranks[channel].Contains(UserRank.None))
             ranks[channel].Add(UserRank.None);
         client.OnRankChange(this, channel, ranks[channel].Min());
     }
 }
Example #8
0
 public void AddRank(Client client, string channel, UserRank rank)
 {
     Console.WriteLine($"Rank of {this} for {channel} on {client.Host} added: {rank}");
     if (!ranks.ContainsKey(channel))
         ranks.TryAdd(channel, new List<UserRank>());
     if (!ranks[channel].Contains(rank))
     {
         if (!ranks[channel].Contains(UserRank.None))
             ranks[channel].Add(UserRank.None);
         ranks[channel].Add(rank);
         client.OnRankChange(this, channel, ranks[channel].Min());
     }
 }
Example #9
0
 internal void OnRankChange(User user, string channel, UserRank rank) => RankChange?.Invoke(user, channel, rank);