public void DropChannel(ChannelData c) { foreach (UserData u in c.users) { u.channels.Remove(c); } _channels.Remove(c); }
// 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)); } }
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]); } }
public void UnsetUserMode(ChannelData c, UserData u, UserMode um) { if (u.channels.ContainsKey(c)) { u.channels[c] &= ~um; } }
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); }
public void Join(ChannelData c, UserData u) { c.users.Add(u); u.AddChannel(c); _channels.Add(c); _users.Add(u); }