public static void ChangeKarma(IMessage message, ulong giver, int change) { if (giver == message.Author.Id) { return; } if (!data.karmaCollection.ContainsKey(message.Author.Id)) { data.karmaCollection.Add(message.Author.Id, 0); } data.karmaCollection [message.Author.Id] += change; if (!data.trackedMessages.ContainsKey(message.Id)) { data.trackedMessages.Add(message.Id, 0); } data.trackedMessages [message.Id] += change; if (data.trackedMessages [message.Id] >= upvotesToQuote && upvotesToQuote > 0) { CQuote.AddQuoteFromMessage(message); } if (data.trackedMessages [message.Id] <= downvotesToDelete && downvotesToDelete < 0) // Could be in an else-if, but it felt wrong for some reason. { DeleteMessage(message); } SerializationIO.SaveObjectToFile(Program.dataPath + karmaFileName + Program.gitHubIgnoreType, data); }
public static void Initialize() { LoadSettings(); if (settings == null) { settings = new Dictionary <string, object> (); } else { SerializationIO.SaveObjectToFile(Program.dataPath + settingsFileName + "_BACKUP" + Program.gitHubIgnoreType, settings, true, false); } }
public Task OnDayPassed(DateTime time) { SocketRole activeRole = Utility.GetServer().GetRole(activeUserRole); SocketRole presentRole = Utility.GetServer().GetRole(presentUserRole); SocketRole inactiveRole = Utility.GetServer().GetRole(inactiveUserRole); foreach (ulong id in userActivity.Keys) { UpdateUser(id, activeRole, presentRole, inactiveRole); } SerializationIO.SaveObjectToFile(Program.dataPath + activityFileName + Program.gitHubIgnoreType, userActivity); return(Task.CompletedTask); }
public static string AddGame(SocketUser user, string gameName) { string result = ""; if (gameName != null && gameName != "") { gameName = gameName.ToUpper(); bool doSave = false; if (userGames.ContainsKey(user.Id)) { if (!userGames[user.Id].Contains(gameName)) { userGames[user.Id].Add(gameName); Logging.Log(Logging.LogType.BOT, "Added game " + gameName + " to gamelist of " + user.Username); result = "Succesfully added game **" + gameName + "** to your gamelist."; doSave = true; } else { result = "Failed to add game **" + gameName + "** - It's already there."; } } else { userGames.Add(user.Id, new List <string> ()); userGames[user.Id].Add(gameName); Logging.Log(Logging.LogType.BOT, "Constructed a new gamelist for " + user.Username); result = "Succesfully added game **" + gameName + "** to your gamelist."; doSave = true; } ChangeGameRole(user, gameName, true); if (doSave) { SerializationIO.SaveObjectToFile(Program.dataPath + fileName + Program.gitHubIgnoreType, userGames); } } return(result); }
public static void RecordActivity(ulong userID, DateTime time, bool single) { if (userActivity.ContainsKey(userID)) { userActivity[userID] = time; } else { userActivity.Add(userID, time); } // Well that got ugly. SocketRole activeRole = Utility.GetServer().GetRole(activeUserRole); SocketRole presentRole = Utility.GetServer().GetRole(presentUserRole); SocketRole inactiveRole = Utility.GetServer().GetRole(inactiveUserRole); UpdateUser(userID, activeRole, presentRole, inactiveRole); if (single) { SerializationIO.SaveObjectToFile(Program.dataPath + activityFileName + Program.gitHubIgnoreType, userActivity); } }
private static void Save() { SerializationIO.SaveObjectToFile(Program.dataPath + strikeDataPath + Program.gitHubIgnoreType, strikes); }
public static void SaveData() { SerializationIO.SaveObjectToFile(filePath, allPermissions, true, false); }
public static void SaveData() { SerializationIO.SaveObjectToFile(Program.dataPath + "quotes" + Program.gitHubIgnoreType, quotes, true, false); }
public static void SaveSettings() { SerializationIO.SaveObjectToFile(Program.dataPath + settingsFileName + Program.gitHubIgnoreType, settings, true, false); }
public void Save() { SerializationIO.SaveObjectToFile(Program.dataPath + "groups" + Program.gitHubIgnoreType, this); }
public static void SaveData() { SerializationIO.SaveObjectToFile(Program.dataPath + dataFileName + Program.gitHubIgnoreType, data, true, false); }
public static void SaveData() { SerializationIO.SaveObjectToFile(Program.dataPath + dataFileName + Program.gitHubIgnoreType, new Data(games, votes, votingMessageID, joinMessageID, allGames, status, weekIndex)); }
// Totally didn't copy paste this part from AliasCollection.cs. // Might be good to create a generalized version of load instead. public void Save() { SerializationIO.SaveObjectToFile(Program.dataPath + "scores.dat", scores); }
private static void SaveData() { SerializationIO.SaveObjectToFile(saveDataPath, autocEvents, true, false); }
public static void SaveEvents() { SerializationIO.SaveObjectToFile(Program.dataPath + eventFileName + Program.gitHubIgnoreType, upcomingEvents); }
public void Save() { SerializationIO.SaveObjectToFile(Program.dataPath + "aliasses.dat", this); }
public static void SaveData() { SerializationIO.SaveObjectToFile(Program.dataPath + "younglings" + Program.gitHubIgnoreType, joinDate, true, false); }
private static void SaveData() { SerializationIO.SaveObjectToFile(Program.dataPath + fileName + Program.gitHubIgnoreType, acceptedLegalJunk); }