diff options
author | Ben Harris <ben@tilde.team> | 2020-05-14 23:06:10 -0400 |
---|---|---|
committer | Ben Harris <ben@tilde.team> | 2020-05-14 23:17:47 -0400 |
commit | 21f1e95fb8e935134a969bc3d729964d8d2aadfa (patch) | |
tree | db2be27e9b5ac48e19f92b56cbad68ab59f7099e /IRCStates/Channel.cs | |
parent | 304df7805b9925c2edd992fd4177eef80197f807 (diff) |
rename Irc to IRC
Diffstat (limited to 'IRCStates/Channel.cs')
-rw-r--r-- | IRCStates/Channel.cs | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/IRCStates/Channel.cs b/IRCStates/Channel.cs new file mode 100644 index 0000000..60ca3fb --- /dev/null +++ b/IRCStates/Channel.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace IRCStates +{ + public class Channel + { + public Channel() + { + Users = new Dictionary<string, ChannelUser>(); + ListModes = new Dictionary<string, List<string>>(); + Modes = new Dictionary<string, string>(); + } + + public string Name { get; set; } + public string NameLower { get; set; } + public Dictionary<string, ChannelUser> Users { get; set; } + public string Topic { get; set; } + public string TopicSetter { get; set; } + public DateTime TopicTime { get; set; } + public DateTime Created { get; set; } + public Dictionary<string, List<string>> ListModes { get; set; } + public Dictionary<string, string> Modes { get; set; } + + public override string ToString() + { + return $"Channel(name={Name})"; + } + + public void SetName(string name, string nameLower) + { + Name = name; + NameLower = nameLower; + } + + public void AddMode(string ch, string param, bool listMode) + { + if (listMode) + { + if (!ListModes.ContainsKey(ch)) ListModes[ch] = new List<string>(); + + if (!ListModes[ch].Contains(param)) ListModes[ch].Add(param ?? string.Empty); + } + else + { + Modes[ch] = param; + } + } + + public void RemoveMode(string ch, string param) + { + if (ListModes.ContainsKey(ch)) + { + if (ListModes[ch].Contains(param)) + { + ListModes[ch].Remove(param); + if (!ListModes[ch].Any()) ListModes.Remove(ch); + } + } + else if (Modes.ContainsKey(ch)) + { + Modes.Remove(ch); + } + } + } +} |