Esempio n. 1
0
 // Unlike HashSet, Dictionary throws an exception if a key exists. This avoids the exception
 // and updates the UserMode if necessary.
 public void AddChannel(ChannelData d, UserMode? m = null)
 {
     if (channels.ContainsKey(d)) {
         if (m.HasValue) channels[d] = m.Value;
     } else {
         channels.Add(d, m.GetValueOrDefault(UserMode.None));
     }
 }
Esempio n. 2
0
 public void DropChannel(ChannelData c)
 {
     HashSet<UserData> single = new HashSet<UserData>();
     foreach (UserData u in c.users) {
         if (u.channels.Count == 1) single.Add(u);
         u.channels.Remove(c);
     }
     _users.RemoveWhere(u => single.Contains(u));
     _channels.Remove(c);
 }
Esempio n. 3
0
        internal Channel(ChannelData cd)
        {
            _name = cd.name;
            _key = cd.channel_key;
            _topic = cd.topic;
            _topicsetter = cd.topic_setter;
            _topicsettime = cd.topic_settime;
            _isIncomplete = cd.incomplete;

            _modes = new HashSet<char>();
            foreach (char mode in cd.modes) {
                _modes.Add(mode);
            }

            _users = new Dictionary<string, UserMode>();
            foreach (UserData u in cd.users) {
                _users.Add(u.nick, u.channels[cd]);
            }
        }
Esempio n. 4
0
        public void Join(ChannelData c, UserData u)
        {
            c.users.Add(u);
            u.AddChannel(c);

            _channels.Add(c);
            _users.Add(u);
        }
Esempio n. 5
0
 public void UnsetUserMode(ChannelData c, UserData u, UserMode um)
 {
     if (u.channels.ContainsKey(c)) {
         u.channels[c] &= ~um;
     }
 }
Esempio n. 6
0
        public void Unjoin(ChannelData c, UserData u)
        {
            c.users.Remove(u);
            u.channels.Remove(c);

            if (u.channels.Count == 0) _users.Remove(u);
        }