public ServerTrackingModule(ModuleHandler bot, IHTMLFileFromArrayPasser WebServer, Dictionary <string, Dictionary <string, object> > Jsconfig) : base(bot, Jsconfig)
        {
            this.WebServer = WebServer;
            Bot            = bot;
            List <TrackingServerInfo> ServersBeingTracked = new List <TrackingServerInfo>();

            int updateInterval = int.Parse(config["updateInterval"].ToString());

            Tuple <string, string, int>[] servers;

            if (File.Exists(ModuleSavedDataFilePath()))
            {
                ServersBeingTracked = JsonConvert.DeserializeObject <List <TrackingServerInfo> >(System.IO.File.ReadAllText(ModuleSavedDataFilePath()));
                for (int i = 0; i < ServersBeingTracked.Count; i++)
                {
                    commands.Add(new ServerStatus(bot, ServersBeingTracked[i], this));
                }
            }
            else
            {
                Console.WriteLine("No servers found in config file");
                servers = null;
            }

            TrackedServers = new TrackingServerList(this, ServersBeingTracked);

            commands.Add(new ActiveServers(bot, this));
            commands.Add(new SpecificServerStatus(bot, this));
            adminCommands.Add(new ServerAdd(bot, this));
            adminCommands.Add(new ServerRemove(bot, this));
            adminCommands.Add(new FullServerQuery(bot, this));

            serverUpdate = new BaseTask(updateInterval, new System.Timers.ElapsedEventHandler(SyncTrackingServerInfo));

            ServerMapChanged += bot.ServerUpdated;
            ServerMapChanged += ServerTrackingModule_ServerMapChanged;
        }
示例#2
0
 public TrackingServerList(ServerTrackingModule serverTrackingModule, TrackingServerList trackedServers)
 {
     ServerTrackingModule = serverTrackingModule;
     this.trackedServers  = trackedServers;
 }