Exemple #1
0
        public static void Initialize()
        {
            UserGameMonitor config = new UserGameMonitor();

            config.LoadConfiguration();
            BotConfiguration.AddConfigurable(config);

            if (enabled)
            {
                userGames = SerializationIO.LoadObjectFromFile <Dictionary <ulong, List <string> > > (Program.dataPath + fileName + Program.gitHubIgnoreType);
                if (userGames == null)
                {
                    userGames = new Dictionary <ulong, List <string> > ();
                }

                Program.discordClient.UserUpdated += (before, after) => {
                    try {
                        if (!UserConfiguration.GetSetting <bool> (after.Id, "AllowSnooping"))
                        {
                            return(Task.CompletedTask);
                        }

                        string gameName = after.Game.HasValue ? after.Game.Value.Name.ToString().ToUpper() : null;
                        AddGame(after, gameName);
                    } catch (Exception e) {
                        Logging.Log(Logging.LogType.EXCEPTION, e.Message + " - " + e.StackTrace);
                    }
                    return(Task.CompletedTask);
                };
            }
        }
Exemple #2
0
 private static void Load()
 {
     strikes = SerializationIO.LoadObjectFromFile <Dictionary <ulong, Strike> > (Program.dataPath + strikeDataPath + Program.gitHubIgnoreType);
     if (strikes == null)
     {
         strikes = new Dictionary <ulong, Strike> ();
     }
 }
Exemple #3
0
 private static void LoadData()
 {
     autocEvents = SerializationIO.LoadObjectFromFile <Dictionary <Event, AutocEvent> > (saveDataPath);
     if (autocEvents == null)
     {
         autocEvents = new Dictionary <Event, AutocEvent> ();
     }
 }
Exemple #4
0
 public static void LoadEvents()
 {
     upcomingEvents = SerializationIO.LoadObjectFromFile <List <Event> > (Program.dataPath + eventFileName + Program.gitHubIgnoreType);
     if (upcomingEvents == null)
     {
         upcomingEvents = new List <Event> ();
     }
 }
Exemple #5
0
 public static void LoadData()
 {
     allPermissions = SerializationIO.LoadObjectFromFile <Dictionary <ulong, PermissionSet> > (filePath);
     if (allPermissions == null)
     {
         allPermissions = new Dictionary <ulong, PermissionSet> ();
         SaveData();
     }
 }
Exemple #6
0
 public override void Initialize()
 {
     base.Initialize();
     quotes = SerializationIO.LoadObjectFromFile <List <string> > (Program.dataPath + "quotes" + Program.gitHubIgnoreType);
     if (quotes == null)
     {
         quotes = new List <string> ();
     }
 }
 public async Task Initialize(DateTime time)
 {
     LoadConfiguration();
     BotConfiguration.AddConfigurable(this);
     userActivity = SerializationIO.LoadObjectFromFile <Dictionary <ulong, DateTime> > (Program.dataPath + activityFileName + Program.gitHubIgnoreType);
     if (userActivity == null)
     {
         userActivity = new Dictionary <ulong, DateTime> ();
     }
     await Booted();
 }
Exemple #8
0
        public static void Initialize()
        {
            userSettings = SerializationIO.LoadObjectFromFile <Dictionary <ulong, List <Setting> > > (Program.dataPath + settingsFileName + Program.gitHubIgnoreType);
            if (userSettings == null)
            {
                userSettings = new Dictionary <ulong, List <Setting> > ();
            }

            UserConfiguration config = new UserConfiguration();

            config.LoadConfiguration();
        }
Exemple #9
0
        public static PlayerGroups Load()
        {
            PlayerGroups groups = SerializationIO.LoadObjectFromFile <PlayerGroups> (Program.dataPath + "groups" + Program.gitHubIgnoreType);

            if (groups != null)
            {
                return(groups);
            }
            else
            {
                return(new PlayerGroups());
            }
        }
Exemple #10
0
        public static Dictionary <string, int> Load()
        {
            Dictionary <string, int> collection = SerializationIO.LoadObjectFromFile <Dictionary <string, int> > (Program.dataPath + "scores" + Program.gitHubIgnoreType);

            if (collection == null)
            {
                return(new Dictionary <string, int> ());
            }
            else
            {
                return(collection);
            }
        }
        public static AliasCollection Load()
        {
            AliasCollection collection = SerializationIO.LoadObjectFromFile <AliasCollection> (Program.dataPath + "aliasses.dat");

            if (collection == null)
            {
                return(new AliasCollection());
            }
            else
            {
                return(collection);
            }
        }
Exemple #12
0
        public static void LoadData()
        {
            data = SerializationIO.LoadObjectFromFile <Data> (Program.dataPath + dataFileName + Program.gitHubIgnoreType);
            if (data == null)
            {
                data = new Data();
            }

            foreach (CustomCommand cmd in data.customCommands)
            {
                CustomCommandSet.customSet.AddProceduralCommands(cmd);
            }
        }
Exemple #13
0
        public Karma()
        {
            LoadConfiguration();
            BotConfiguration.AddConfigurable(this);
            data = SerializationIO.LoadObjectFromFile <Data> (Program.dataPath + karmaFileName + Program.gitHubIgnoreType);
            if (data == null)
            {
                data = new Data();
            }

            Program.discordClient.ReactionAdded += async(message, channel, reaction) => {
                IMessage iMessage = await channel.GetMessageAsync(message.Id);

                if (reaction.Emote.Name == upvote)
                {
                    ChangeKarma(iMessage, reaction.UserId, 1);
                }
                else if (reaction.Emote.Name == downvote)
                {
                    ChangeKarma(iMessage, reaction.UserId, -1);
                }
            };

            Program.discordClient.ReactionRemoved += async(message, channel, reaction) => {
                IMessage iMessage = await channel.GetMessageAsync(message.Id);

                if (reaction.Emote.Name == upvote)
                {
                    ChangeKarma(iMessage, reaction.UserId, -1);
                }
                else if (reaction.Emote.Name == downvote)
                {
                    ChangeKarma(iMessage, reaction.UserId, 1);
                }
            };
        }
Exemple #14
0
        public async Task Initialize(DateTime time)
        {
            LoadConfiguration();
            BotConfiguration.AddConfigurable(this);
            Data loadedData = SerializationIO.LoadObjectFromFile <Data> (Program.dataPath + dataFileName + Program.gitHubIgnoreType);

            votes           = loadedData.votes;
            games           = loadedData.games;
            votingMessageID = loadedData.votingMessageID;
            joinMessageID   = loadedData.joinMessageID;
            allGames        = loadedData.allGames;
            status          = loadedData.status;
            weekIndex       = loadedData.weekIndex;

            if (allGames == null)
            {
                allGames = new List <Game> ();
            }

            while (Utility.GetServer() == null)
            {
                await Task.Delay(1000);
            }

            if (status == WeeklyEventStatus.Waiting && (int)DateTime.Now.DayOfWeek < (int)voteEndDay)
            {
                BeginNewVote();
            }

            Program.discordClient.ReactionAdded += async(message, channel, reaction) => {
                OnReactionChanged(message, channel, reaction, true);
            };
            Program.discordClient.ReactionRemoved += async(message, channel, reaction) => {
                OnReactionChanged(message, channel, reaction, false);
            };
        }
Exemple #15
0
 public static void LoadSettings()
 {
     settings = SerializationIO.LoadObjectFromFile <Dictionary <string, object> > (Program.dataPath + settingsFileName + Program.gitHubIgnoreType);
 }
Exemple #16
0
 public static void LoadData()
 {
     joinDate = SerializationIO.LoadObjectFromFile <Dictionary <ulong, Youngling> > (Program.dataPath + "younglings" + Program.gitHubIgnoreType);
 }
Exemple #17
0
 private static void LoadData()
 {
     acceptedLegalJunk = SerializationIO.LoadObjectFromFile <Dictionary <ulong, bool> > (Program.dataPath + fileName + Program.gitHubIgnoreType);
 }