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.

ServerConfig.cs 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Combot.Configurations
  4. {
  5. public class ServerConfig
  6. {
  7. public event Action ModifyEvent;
  8. public event Action LoadEvent;
  9. public string Name { get; set; }
  10. public List<string> Nicknames { get; set; }
  11. public string Realname { get; set; }
  12. public string Username { get; set; }
  13. public string Password { get; set; }
  14. public string Email { get; set; }
  15. public List<string> Owners { get; set; }
  16. public List<string> ChannelBlacklist { get; set; }
  17. public List<string> NickBlacklist { get; set; }
  18. public List<HostConfig> Hosts { get; set; }
  19. public List<ChannelConfig> Channels { get; set; }
  20. public DatabaseConfig Database { get; set; }
  21. public string ModuleLocation { get; set; }
  22. public bool AutoConnect { get; set; }
  23. public bool Reconnect { get; set; }
  24. public bool AutoRegister { get; set; }
  25. public string CommandPrefix { get; set; }
  26. public int JoinDelay { get; set; }
  27. public int MaxMessageLength { get; set; }
  28. public int MessageSendDelay { get; set; }
  29. public SpamSourceType SpamSourceType { get; set; }
  30. public int SpamCountMax { get; set; }
  31. public TimeSpan SpamSessionTime { get; set; }
  32. public ServerConfig()
  33. {
  34. SetDefaults();
  35. }
  36. public void SetDefaults()
  37. {
  38. Name = string.Empty;
  39. Nicknames = new List<string>();
  40. Realname = string.Empty;
  41. Username = string.Empty;
  42. Password = string.Empty;
  43. Email = string.Empty;
  44. AutoConnect = false;
  45. AutoRegister = false;
  46. CommandPrefix = string.Empty;
  47. JoinDelay = 0;
  48. MaxMessageLength = 400;
  49. MessageSendDelay = 0;
  50. SpamSourceType = SpamSourceType.Nick;
  51. SpamCountMax = 5;
  52. SpamSessionTime = new TimeSpan(0, 0, 1);
  53. ModuleLocation = string.Empty;
  54. Owners = new List<string>();
  55. ChannelBlacklist = new List<string>();
  56. NickBlacklist = new List<string>();
  57. Channels = new List<ChannelConfig>();
  58. Hosts = new List<HostConfig>();
  59. Database = new DatabaseConfig();
  60. }
  61. public void Copy(ServerConfig config)
  62. {
  63. Name = config.Name;
  64. Nicknames = new List<string>();
  65. for (int i = 0; i < config.Nicknames.Count; i++)
  66. {
  67. Nicknames.Add(config.Nicknames[i]);
  68. }
  69. Realname = config.Realname;
  70. Username = config.Username;
  71. Password = config.Password;
  72. Email = config.Email;
  73. AutoConnect = config.AutoConnect;
  74. AutoRegister = config.AutoRegister;
  75. CommandPrefix = config.CommandPrefix;
  76. JoinDelay = config.JoinDelay;
  77. MaxMessageLength = config.MaxMessageLength;
  78. MessageSendDelay = config.MessageSendDelay;
  79. SpamSourceType = config.SpamSourceType;
  80. SpamCountMax = config.SpamCountMax;
  81. SpamSessionTime = config.SpamSessionTime;
  82. ModuleLocation = config.ModuleLocation;
  83. Owners = new List<string>();
  84. for (int i = 0; i < config.Owners.Count; i++)
  85. {
  86. Owners.Add(config.Owners[i]);
  87. }
  88. ChannelBlacklist = new List<string>();
  89. for (int i = 0; i < config.ChannelBlacklist.Count; i++)
  90. {
  91. ChannelBlacklist.Add(config.ChannelBlacklist[i]);
  92. }
  93. NickBlacklist = new List<string>();
  94. for (int i = 0; i < config.NickBlacklist.Count; i++)
  95. {
  96. NickBlacklist.Add(config.NickBlacklist[i]);
  97. }
  98. Channels = new List<ChannelConfig>();
  99. for (int i = 0; i < config.Channels.Count; i++)
  100. {
  101. Channels.Add(config.Channels[i]);
  102. }
  103. Hosts = new List<HostConfig>();
  104. for (int i = 0; i < config.Hosts.Count; i++)
  105. {
  106. Hosts.Add(config.Hosts[i]);
  107. }
  108. Database = config.Database;
  109. }
  110. public void Save()
  111. {
  112. if (ModifyEvent != null)
  113. {
  114. ModifyEvent();
  115. }
  116. }
  117. public void Load()
  118. {
  119. if (LoadEvent != null)
  120. {
  121. LoadEvent();
  122. }
  123. }
  124. }
  125. }