The easy to use and full featured Irc Bot everyone is talking about!
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ServerConfig.cs 4.7KB

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