public CensusEventService(DiscordSocketClient client, XIVAPIService XIVAPI, DbService db) { _client = client; _db = db; _XIVAPI = XIVAPI; _cemUnverifiedMembers = new List <ulong>(); }
public static async Task Main() { var http = new HttpClient(); var xivapi = new XIVAPIService(http); var exceptions = 0; for (var i = 0; i < 20; i++) { Console.WriteLine("Request {0}/{1}...", i + 1, 20); try { await xivapi.SearchCharacter("Coeurl", "Karashiir Akhabila"); } catch (XIVAPICharacterNotFoundException) { exceptions++; } await Task.Delay(5000); } Console.WriteLine("{0} exceptions caught", exceptions); }
public static async Task <long> GetCharacterLastActivityTime(GameDataService gameData, XIVAPIService xivapi, JObject fullCharacter) { long lastActivityTime = -1; if (fullCharacter["AchievementsPublic"].ToObject <bool>()) { foreach (AchievementEntry achievement in fullCharacter["Achievements"]["List"].ToObject <IList <AchievementEntry> >()) { if (achievement.Date * 1000 > lastActivityTime) { lastActivityTime = achievement.Date * 1000; } } } /*foreach (MinionMountEntry minion in fullCharacter["Minions"].Children().ToList() as IList<MinionMountEntry>) * { * // Check against minions by patch * } * * foreach (MinionMountEntry mount in fullCharacter["Mounts"].Children().ToList() as IList<MinionMountEntry>) * { * // Check against mounts by patch * }*/ // Check gear release times List <GearItem> gearItems = new List <GearItem>(); var gearItemsRaw = fullCharacter["Character"]["GearSet"]["Gear"]; foreach (string piece in _gearPieces) { if (gearItemsRaw.SelectToken(piece) == null) { continue; } gearItems.Add(gearItemsRaw[piece].ToObject <GearItem>()); } var releaseDates = await xivapi.GetItemsReleaseDates(gearItems .Where(item => item.ID != null) .Select(item => (ushort)item.ID)); foreach (KeyValuePair <ushort, long> result in releaseDates) { if (result.Value > lastActivityTime) { lastActivityTime = result.Value; } } return(await Task.FromResult(lastActivityTime)); }
public static async Task <long> GetCharacterLastActivityTime(GameDataService gameData, XIVAPIService xivapi, ulong id) => await GetCharacterLastActivityTime(gameData, xivapi, await xivapi.GetCharacter(id));