예제 #1
0
 public void DropChannel(ChannelData c)
 {
     foreach (UserData u in c.users) {
         u.channels.Remove(c);
     }
     _channels.Remove(c);
 }
예제 #2
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));
     }
 }
예제 #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]);
            }
        }
예제 #4
0
 public void UnsetUserMode(ChannelData c, UserData u, UserMode um)
 {
     if (u.channels.ContainsKey(c)) {
         u.channels[c] &= ~um;
     }
 }
예제 #5
0
        public void Unjoin(ChannelData c, UserData u)
        {
            c.users.Remove(u);
            u.channels.Remove(c);

            if (c.users.Count == 0) _channels.Remove(c);
            if (u.channels.Count == 0) _users.Remove(u);
        }
예제 #6
0
        public void Join(ChannelData c, UserData u)
        {
            c.users.Add(u);
            u.AddChannel(c);

            _channels.Add(c);
            _users.Add(u);
        }