Пример #1
0
        public static async void scores(Message mess)
        {
            try
            {
                osuApi osuapi     = new osuApi(BotMain.osuToken);
                string beatmap_id = "";
                for (int i = mess.Text.Length - 1; i >= 0; i--)
                {
                    if (mess.Text[i] != '/')
                    {
                        beatmap_id = beatmap_id.Insert(0, mess.Text[i].ToString());
                    }
                    else
                    {
                        break;
                    }
                }
                string  name   = string.Join(" ", mess.Text.Split(" ").Skip(1).SkipLast(1));
                Score[] scores = await osuapi.GetScoresOnMapByName(name, long.Parse(beatmap_id));

                string text = "";
                foreach (var item in scores)
                {
                    Mods    mods     = (Mods)osuapi.CalculateModsMods(int.Parse(item.enabled_mods));
                    double  accuracy = (50 * double.Parse(item.count50) + 100 * double.Parse(item.count100) + 300 * double.Parse(item.count300)) / (300 * (double.Parse(item.countmiss) + double.Parse(item.count50) + double.Parse(item.count100) + double.Parse(item.count300))) * 100;
                    Beatmap beatmap  = await osuapi.GetBeatmapByBeatmapIdAsync(int.Parse(beatmap_id));

                    double curpp  = Other.ppCalc(beatmap, accuracy, mods, int.Parse(item.countmiss), int.Parse(item.maxcombo));
                    double IfFCpp = Other.ppCalc(beatmap, accuracy, mods, 0, int.Parse(beatmap.max_combo));
                    text += $"<b>({item.rank})</b> <a href=\"https://osu.ppy.sh/beatmaps/{item.beatmap_id}\">{beatmap.title} [{beatmap.version}]</a> <b>({beatmap.GetApproved()})</b>\n" +
                            $"{item.count300}-{item.count100}-{item.count50}-{item.countmiss}❌ - <b><i>{accuracy:N2}</i></b>%\n" +
                            $"<b>{mods}</b> <i>{item.maxcombo}/{beatmap.max_combo}</i> <b><u>{curpp:N0}pp</u></b> (<b><u>~{IfFCpp:N0}pp</u></b> if FC)\n({DateTimeOffset.Parse(item.date).AddHours(5):dd.MM.yyyy HH:mm})\n\n";
                }
                await BotMain.bot.SendTextMessageAsync(mess.Chat.Id, text, ParseMode.Html);
            }
            catch (Exception e)
            {
                Other.OnReceivedError(e, mess, "Нет скоров");
            }
        }
Пример #2
0
        public static async void rs(Message mess)
        {
            try
            {
                string text   = "";
                osuApi osuApi = new osuApi(BotMain.osuToken);
                string name   = string.Join(' ', mess.Text.Split(' ').Skip(1));
                if (name == "")
                {
                    await BotMain.bot.SendTextMessageAsync(mess.Chat.Id, "а ты кто?\n!rs [name]");

                    return;
                }
                Score recentScore = (await osuApi.GetRecentScoresByNameAsync(name))[0];
                if (recentScore == default)
                {
                    throw new FormatException();
                }
                Beatmap beatmap = await osuApi.GetBeatmapByBeatmapIdAsync(long.Parse(recentScore.beatmap_id));

                Mods   mods     = (Mods)osuApi.CalculateModsMods(int.Parse(recentScore.enabled_mods));
                double accuracy = (50 * double.Parse(recentScore.count50) + 100 * double.Parse(recentScore.count100) + 300 * double.Parse(recentScore.count300)) / (300 * (double.Parse(recentScore.countmiss) + double.Parse(recentScore.count50) + double.Parse(recentScore.count100) + double.Parse(recentScore.count300))) * 100;
                double curpp    = Other.ppCalc(beatmap, accuracy, mods, int.Parse(recentScore.countmiss), int.Parse(recentScore.maxcombo));
                double ppIFfc   = Other.ppCalc(beatmap, accuracy, mods, 0, int.Parse(beatmap.max_combo));
                text += $"<b>({recentScore.rank})</b> <a href=\"https://osu.ppy.sh/beatmaps/{beatmap.beatmap_id}\">{beatmap.title} [{beatmap.version}]</a> <b>({beatmap.GetApproved()})</b>\n" +
                        $"{recentScore.count300}-{recentScore.count100}-{recentScore.count50}-{recentScore.countmiss}❌ - <b><i>{accuracy:N2}</i></b>%\n" +
                        $"<b>{mods}</b> <i>{recentScore.maxcombo}/{beatmap.max_combo}</i> <b><u>{curpp:N0}pp</u></b> (<b><u>~{ppIFfc:N0}pp</u></b> if FC)\n({DateTimeOffset.Parse(recentScore.date).AddHours(5):dd.MM.yyyy HH:mm})\n\n";
                await BotMain.bot.SendTextMessageAsync(mess.Chat.Id, text, ParseMode.Html);
            }
            catch (FormatException e)
            {
                Other.OnReceivedError(e, mess, "Он ничего не играл последние 24 часа.");
            }
            catch (Exception e)
            {
                Other.OnReceivedError(e, mess, "Чет не получилось :(");
            }
        }