From 933a4f85604e21445c9bac8272d64cf3e6f65e00 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Wed, 22 Apr 2020 16:28:51 -0400 Subject: rename to IrcSharp also tidy up formatting with vs tools --- IrcStates/Channel.cs | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 IrcStates/Channel.cs (limited to 'IrcStates/Channel.cs') diff --git a/IrcStates/Channel.cs b/IrcStates/Channel.cs new file mode 100644 index 0000000..1850e51 --- /dev/null +++ b/IrcStates/Channel.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace IrcStates +{ + public class Channel + { + public string Name { get; set; } + public string NameLower { get; set; } + public Dictionary 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> ListModes { get; set; } + public Dictionary 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(); + } + + 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); + } + } + } +} -- cgit 1.4.1