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.2KB

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