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.

Controller.cs 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Threading;
  5. using Combot.Configurations;
  6. namespace Combot
  7. {
  8. public class Controller
  9. {
  10. public static Controller Instance { get { return GetInstance(); } }
  11. public static Controller GetInstance() { return _controller ?? (_controller = new Controller()); }
  12. private static Controller _controller;
  13. private List<Bot> _bots;
  14. public List<Bot> Bots { get; private set; }
  15. public readonly Config Config = new Config();
  16. private Controller()
  17. {
  18. Load();
  19. }
  20. public void Load()
  21. {
  22. Config.LoadServers();
  23. Bots = new List<Bot>();
  24. foreach (ServerConfig server in Config.Servers)
  25. {
  26. Bot Combot = new Bot(server);
  27. Bots.Add(Combot);
  28. }
  29. }
  30. public void AutoConnect()
  31. {
  32. Bots.ForEach(bot =>
  33. {
  34. if (bot.ServerConfig.AutoConnect) { bot.Connect(); }
  35. });
  36. }
  37. public Bot GetBot(string server)
  38. {
  39. return Bots.Find(bot => bot.ServerConfig.Name == server);
  40. }
  41. }
  42. }