The easy to use and full featured Irc Bot everyone is talking about!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Channel.cs 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace Combot.IRCServices
  7. {
  8. public class Channel
  9. {
  10. public string Name { get; set; }
  11. public string Topic { get; set; }
  12. public string Key { get; set; }
  13. public bool AutoJoin { get; set; }
  14. public bool Joined { get; set; }
  15. public DateTime Registration { get; set; }
  16. public List<string> Bans { get; set; }
  17. public List<ChannelMode> Modes { get; set; }
  18. public List<Nick> Nicks { get; set; }
  19. public Channel()
  20. {
  21. Name = string.Empty;
  22. Topic = string.Empty;
  23. Key = string.Empty;
  24. AutoJoin = false;
  25. Joined = false;
  26. Registration = DateTime.Now;
  27. Bans = new List<string>();
  28. Modes = new List<ChannelMode>();
  29. Nicks = new List<Nick>();
  30. }
  31. public void AddNick(Nick nick)
  32. {
  33. Nicks.Add(nick);
  34. }
  35. public void AddNicks(List<Nick> nicks)
  36. {
  37. Nicks.AddRange(nicks);
  38. }
  39. public void RemoveNick(Nick nick)
  40. {
  41. if (Nicks.Contains(nick))
  42. {
  43. Nicks.Remove(nick);
  44. }
  45. }
  46. public void RemoveNick(string nickname)
  47. {
  48. if (Nicks.Exists(nick => nick.Nickname == nickname))
  49. {
  50. Nicks.Remove(Nicks.Find(nick => nick.Nickname == nickname));
  51. }
  52. }
  53. public void RemoveNicks(List<Nick> nicks)
  54. {
  55. foreach (Nick nick in nicks)
  56. {
  57. RemoveNick(nick);
  58. }
  59. }
  60. public void RemoveNicks(List<string> nicks)
  61. {
  62. foreach (string nick in nicks)
  63. {
  64. RemoveNick(nick);
  65. }
  66. }
  67. public Nick GetNick(string nickname)
  68. {
  69. Nick foundNick = Nicks.Find(nick => nick.Nickname == nickname);
  70. return foundNick;
  71. }
  72. public List<Nick> GetNicks(List<string> nicknames)
  73. {
  74. List<Nick> foundNicks = new List<Nick>();
  75. foreach (string nickname in nicknames)
  76. {
  77. Nick foundNick = GetNick(nickname);
  78. if (foundNick != null)
  79. {
  80. foundNicks.Add(foundNick);
  81. }
  82. }
  83. return foundNicks;
  84. }
  85. public void AddMode(ChannelMode mode)
  86. {
  87. if (!Modes.Contains(mode))
  88. {
  89. Modes.Add(mode);
  90. }
  91. }
  92. public void AddModes(List<ChannelMode> modes)
  93. {
  94. foreach (ChannelMode mode in modes)
  95. {
  96. AddMode(mode);
  97. }
  98. }
  99. public void RemoveMode(ChannelMode mode)
  100. {
  101. if (Modes.Contains(mode))
  102. {
  103. Modes.Remove(mode);
  104. }
  105. }
  106. public void RemoveModes(List<ChannelMode> modes)
  107. {
  108. foreach (ChannelMode mode in modes)
  109. {
  110. RemoveMode(mode);
  111. }
  112. }
  113. public void AddBan(string mask)
  114. {
  115. if (!Bans.Contains(mask))
  116. {
  117. Bans.Add(mask);
  118. }
  119. }
  120. public void RemoveBan(string mask)
  121. {
  122. Bans.Remove(mask);
  123. }
  124. }
  125. }