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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 ServerConfig()
  30. {
  31. SetDefaults();
  32. }
  33. public void SetDefaults()
  34. {
  35. Name = string.Empty;
  36. Nicknames = new List<string>();
  37. Realname = string.Empty;
  38. Username = string.Empty;
  39. Password = string.Empty;
  40. Email = string.Empty;
  41. AutoConnect = false;
  42. AutoRegister = false;
  43. CommandPrefix = string.Empty;
  44. JoinDelay = 0;
  45. MaxMessageLength = 400;
  46. MessageSendDelay = 0;
  47. ModuleLocation = string.Empty;
  48. Owners = new List<string>();
  49. ChannelBlacklist = new List<string>();
  50. NickBlacklist = new List<string>();
  51. Channels = new List<ChannelConfig>();
  52. Hosts = new List<HostConfig>();
  53. Database = new DatabaseConfig();
  54. }
  55. public void Copy(ServerConfig config)
  56. {
  57. Name = config.Name;
  58. Nicknames = new List<string>();
  59. for (int i = 0; i < config.Nicknames.Count; i++)
  60. {
  61. Nicknames.Add(config.Nicknames[i]);
  62. }
  63. Realname = config.Realname;
  64. Username = config.Username;
  65. Password = config.Password;
  66. Email = config.Email;
  67. AutoConnect = config.AutoConnect;
  68. AutoRegister = config.AutoRegister;
  69. CommandPrefix = config.CommandPrefix;
  70. JoinDelay = config.JoinDelay;
  71. MaxMessageLength = config.MaxMessageLength;
  72. MessageSendDelay = config.MessageSendDelay;
  73. ModuleLocation = config.ModuleLocation;
  74. Owners = new List<string>();
  75. for (int i = 0; i < config.Owners.Count; i++)
  76. {
  77. Owners.Add(config.Owners[i]);
  78. }
  79. ChannelBlacklist = new List<string>();
  80. for (int i = 0; i < config.ChannelBlacklist.Count; i++)
  81. {
  82. ChannelBlacklist.Add(config.ChannelBlacklist[i]);
  83. }
  84. NickBlacklist = new List<string>();
  85. for (int i = 0; i < config.NickBlacklist.Count; i++)
  86. {
  87. NickBlacklist.Add(config.NickBlacklist[i]);
  88. }
  89. Channels = new List<ChannelConfig>();
  90. for (int i = 0; i < config.Channels.Count; i++)
  91. {
  92. Channels.Add(config.Channels[i]);
  93. }
  94. Hosts = new List<HostConfig>();
  95. for (int i = 0; i < config.Hosts.Count; i++)
  96. {
  97. Hosts.Add(config.Hosts[i]);
  98. }
  99. Database = config.Database;
  100. }
  101. public void Save()
  102. {
  103. if (ModifyEvent != null)
  104. {
  105. ModifyEvent();
  106. }
  107. }
  108. public void Load()
  109. {
  110. if (LoadEvent != null)
  111. {
  112. LoadEvent();
  113. }
  114. }
  115. }
  116. }