blob: 1850e51632aad9f220ea88ac12baad5b1423c036 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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<string, User> 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);
}
}
}
}
|