示例#1
0
 public override void loadPersistentData()
 {
     try
     {
         Dictionary <string, string> data = JsonConvert.DeserializeObject <Dictionary <string, string> >(System.IO.File.ReadAllText(this.GetType().Name + ".json"));
         message        = data["motd"];
         postCount      = int.Parse(data["count"]);
         postCountLimit = int.Parse(data["PostLimit"]);
     }
     catch
     {
         postCount      = 0;
         postCountLimit = DefaultPostCountLimit();
         motdPost       = null;
     }
 }
示例#2
0
        public MotdModule(VBot bot, Dictionary <string, Dictionary <string, object> > Jsconfig) : base(bot, Jsconfig)
        {
            // loading config
            int updateInterval = int.Parse(config["updateInterval"].ToString());

            // loading saved data
            loadPersistentData();

            // loading commands
            commands.Add(new GetMOTD(bot, this));
            commands.Add(new CurrentMotdTick(bot, this));
            commands.Add(new GetMotdSetter(bot, this));
            adminCommands.Add(new SetMotd(bot, this));
            adminCommands.Add(new RemoveMotd(bot, this));
            adminCommands.Add(new SetExtendedMotd(bot, this));
            adminCommands.Add(new EmulateMotd(bot, this));

            motdPost = new BaseTask(updateInterval, new System.Timers.ElapsedEventHandler(MotdPost));
        }
        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;
        }
示例#4
0
 public MOTDITEM(int updateinterval, ElapsedEventHandler PostMethod)
 {
     Task = new BaseTask(updateinterval, new System.Timers.ElapsedEventHandler(PostMethod));
 }