public static async Task <OsuUserRecent> DownloadUserRecent(ulong userID, OsuGameModes gameMode, SocketUserMessage logger = null, bool tolerateNull = false, int maxAttempts = 1) => (await DownloadObjects <OsuUserRecent>( $"{api}get_user_recent?" + $"k={Keys.API_KEYS["Osu"]}&" + $"m={OsuGameModesConverter.ToOfficialNumeration(gameMode)}&" + $"u={userID}&" + $"type=id&" + $"limit=1", maxAttempts, logger, tolerateNull: tolerateNull, additional: gameMode))[0];
public static async Task <OsuScore[]> DownloadBeatmapBest(OsuBeatmap beatmap, OsuGameModes gameMode, ulong?user = null, int?scoreCount = null, bool tolerateNull = false, SocketUserMessage logger = null, int maxAttempts = 1) => await DownloadObjects <OsuScore>( $"{api}get_scores?" + $"k={Keys.API_KEYS["Osu"]}&" + $"b={beatmap.BeatmapID}" + string.Format("&limit={0}", scoreCount.HasValue ? $"{scoreCount.Value}" : "1") + $"&m={OsuGameModesConverter.ToOfficialNumeration(gameMode)}" + string.Format("{0}", user.HasValue ? $"&u={user.Value}" : string.Empty), maxAttempts, logger, tolerateNull : tolerateNull, additional : gameMode);
private void Network_DiscordMessageReceived(object sender, EventArgModels.DiscordMessageReceivedEventArgs e) { bool newDesign = false; //Detect singular beatmaps { Match match = Regex.Match(e.Message.Content, @"osu.ppy.sh\/b\/\d+(&m=\d)?"); if (!match.Success) { match = Regex.Match(e.Message.Content, @"osu.ppy.sh\/p\/beatmap\?b=\d+(&m=\d)?"); } if (!match.Success) { match = Regex.Match(e.Message.Content, @"osu.ppy.sh\/beatmapsets\/\d+#(osu|taiko|fruits|mania)\/\d+"); newDesign = true; } if (match.Success) { MatchCollection parameters = Regex.Matches(e.Message.Content, @"\d+"); string ID = newDesign ? parameters[1].Value : parameters[0].Value; string gameMode = newDesign ? " " + OsuGameModesConverter.ToOfficialNumeration(OsuGameModesConverter.FromOfficialName(Regex.Match(e.Message.Content, @"#(osu|taiko|fruits|mania)").Value.Remove(0, 1), false)).ToString() : (parameters.Count == 2 ? " " + parameters[1].Value : string.Empty); Console.WriteLine($"Beatmap detected, ID:{ID}"); discord.cService.ExecuteAsync("Beatmap", ID + gameMode, e.Message, internally: true); return; } } //Detect beatmap packs { Match match = Regex.Match(e.Message.Content, @"osu.ppy.sh\/s\/\d+"); if (!match.Success) { match = Regex.Match(e.Message.Content, @"osu.ppy.sh\/beatmapsets\/\d+"); } if (match.Success) { MatchCollection parameters = Regex.Matches(e.Message.Content, @"\d+"); string ID = parameters[0].Value; Console.WriteLine($"Beatmap pack detected, ID:{ID}"); discord.cService.ExecuteAsync("BeatmapPack", ID, e.Message, internally: true); return; } } }
private static async Task <OsuUser> DownloadUserMain(object user, OsuGameModes gameMode, SocketUserMessage logger, bool tolerateNull, int maxAttempts) => (await DownloadObjects <OsuUser>( $"{api}get_user?" + $"k={Keys.API_KEYS["Osu"]}&" + $"u={user}&m={OsuGameModesConverter.ToOfficialNumeration(gameMode)}", maxAttempts, logger, tolerateNull: tolerateNull, additional: gameMode))[0];
public static async Task <OsuBeatmap> DownloadBeatmap(int ID, OsuGameModes gameMode, SocketUserMessage logger = null, bool tolerateNull = false, int maxAttempts = 2) => (await DownloadObjects <OsuBeatmap>( $"{api}get_beatmaps?" + $"k={Keys.API_KEYS["Osu"]}&" + $"b={ID}" + string.Format("{0}", gameMode != OsuGameModes.None ? $"&a=1&m={OsuGameModesConverter.ToOfficialNumeration(gameMode)}" : string.Empty), maxAttempts, logger, tolerateNull: tolerateNull))[0];