Esempio n. 1
0
        public OsuCommands(ILogger<OsuCommands> logger,
                           DiscordClient client,
                           OsuUtils utils,
                           BanchoApi api,
                           GatariApi gapi,
                           OsuEmoji emoji,
                           WAVMembersProvider wavMembers)
        {
            ModuleName = "Osu commands";

            this.logger = logger;
            this.wavScoresChannel = client.GetChannelAsync(829466881353711647).Result;
            this.webClient = new WebClient();
            this.wavMembers = wavMembers;

            this.guild = client.GetGuildAsync(WAV_UID).Result;
            this.utils = utils;
            this.api = api;
            this.gapi = gapi;
            this.emoji = emoji;

            logger.LogInformation("OsuCommands loaded");

            client.MessageCreated += Client_MessageCreated;
        }
        public RecognizerService(DiscordClient client,
                                 Settings settings,
                                 ILogger <RecognizerService> logger,
                                 OsuEmoji emoji,
                                 OsuUtils utils,
                                 ShedulerService sheduler)
        {
            this.client   = client;
            this.logger   = logger;
            this.utils    = utils;
            this.sheduler = sheduler;

            this.emoji = emoji;

            recognizer = new Recognizer();
            webClient  = new WebClient();

            ignoreList = new Dictionary <int, DateTime>();

            api  = new BanchoApi(settings.ClientId, settings.Secret);
            gapi = new GatariApi();

            queue = new BackgroundQueue();

            logger.LogInformation("Osu service started");
            ConfigureFilesInterceptor(client);
        }
Esempio n. 3
0
        public OsuSlashCommands(BanchoApi api, GatariApi gapi, OsuUtils utils, ILogger <OsuSlashCommands> logger)
        {
            this.api   = api;
            this.gapi  = gapi;
            this.utils = utils;

            this.logger = logger;

            logger.LogInformation("OsuSlashCommands loaded");
        }
Esempio n. 4
0
        public TrackCommands(ITrackService trackService, BanchoApi bapi, GatariApi gapi, ILogger <TrackCommands> logger)
        {
            ModuleName = "Tracking";

            tracking    = trackService;
            this.logger = logger;
            this.gapi   = gapi;
            this.bapi   = bapi;

            logger.LogInformation("TrackCommands loaded");
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            Recognizer rec = new Recognizer();

            Settings settings;

            using (StreamReader sr = new StreamReader("credentials.json"))
                settings = JsonConvert.DeserializeObject <Settings>(sr.ReadToEnd());

            BanchoApi api = new BanchoApi(settings.ClientId, settings.Secret);

            Console.WriteLine(api.ReloadToken());

            string[] dirFiles = Directory.GetFiles(@"./testImages/");

            foreach (string path in dirFiles)
            {
                Image img = rec.LoadFromFile(path);

                string[]          recedText = rec.RecognizeTopText(img).Split('\n');
                List <Beatmapset> bms       = api.Search(recedText.First(), WAV_Osu_NetApi.Bancho.QuerryParams.MapType.Any);

                foreach (string s in recedText)
                {
                    Console.WriteLine(s);
                }

                Beatmapset bm = bms?.First();

                if (bm is null)
                {
                    Console.WriteLine("No beatmap found");
                }
                else
                {
                    Console.WriteLine($"{bm.artist} - {bm.title}\n{bm.creator}");
                }
            }
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            Settings settings;

            using (StreamReader sr = new StreamReader("credentials.json"))
                settings = JsonConvert.DeserializeObject <Settings>(sr.ReadToEnd());

            BanchoApi api = new BanchoApi(settings.ClientId, settings.Secret);

            Console.WriteLine(api.ReloadToken());

            List <Score> scores = api.GetUserRecentScores(6885792, false, 0, 5);

            //while (true)
            //{
            //    Console.Write("Напишите название сервера, с которого нужно получать скоры (bancho, gatari) -> ");
            //    string input = Console.ReadLine();

            //    switch (input)
            //    {
            //        case "bancho":
            //            BanchoApi api = new BanchoApi(settings.ClientId, settings.Secret);
            //            Console.WriteLine(api.ReloadToken());

            //            while (true)
            //            {
            //                Console.Write("Введите ID пользователя -> ");
            //                int user = 0;

            //                if (int.TryParse(Console.ReadLine(), out user))
            //                {
            //                    var scores = api.GetUserBestScores(user, 5);
            //                    double avg_pp = 0;

            //                    Console.WriteLine();

            //                    if (scores is null)
            //                    {
            //                        Console.WriteLine("Не удалось получить скоры. Проверьте ID");
            //                        continue;
            //                    }

            //                    foreach (var score in scores)
            //                    {
            //                        Console.WriteLine($"{score.pp} pp : {score.beatmapset.artist} - {score.beatmapset.title}");
            //                        avg_pp += score.pp ?? 0;
            //                    }

            //                    Console.WriteLine(new string('=', 20));
            //                    Console.WriteLine($"{avg_pp / 5} pp\n");
            //                }
            //            }
            //            break;
            //        case "gatari":
            //            GatariApi gapi = new GatariApi();

            //            while (true)
            //            {
            //                Console.Write("Введите ID пользователя -> ");
            //                int user = 0;

            //                if (int.TryParse(Console.ReadLine(), out user))
            //                {
            //                    var scores = gapi.GetUserBestScores(user, 5);
            //                    double avg_pp = 0;

            //                    Console.WriteLine();

            //                    if (scores is null)
            //                    {
            //                        Console.WriteLine("Не удалось получить скоры. Проверьте ID");
            //                        continue;
            //                    }

            //                    foreach (var score in scores)
            //                    {
            //                        Console.WriteLine($"{score.pp} pp : {score.beatmap.song_name}");
            //                        avg_pp += score.pp ?? 0;
            //                    }

            //                    Console.WriteLine(new string('=', 20));
            //                    Console.WriteLine($"{avg_pp / 5} pp\n");
            //                }
            //            }
            //            break;

            //        default:
            //            Console.WriteLine("Не удалось распознать сервер");
            //            break;
            //    }

            //}

            //User users = null;
            //var bm = api.GetBeatmap(2201460);
            //api.GetUserRecentScores(6885792, true, 3, 10);
            //Console.WriteLine(users);

            #region Get best scores
            //List<Score> scores = api.GetUserBestScores(9604150, 100);

            ///Console.WriteLine($"Scores count: {scores.Count}");

            //string scores_s = JsonConvert.SerializeObject(scores);
            //using (StreamWriter sw = new StreamWriter("best_scores_mindblock.json"))
            //    sw.Write(scores_s);

            //Console.ReadKey();
            #endregion

            #region Bancho tracker
            //DateTime last_score = DateTime.Now;
            //while (true)
            //{
            //    List<WAV_Osu_NetApi.Models.Bancho.Score> new_scores = new List<WAV_Osu_NetApi.Models.Bancho.Score>();
            //    List<WAV_Osu_NetApi.Models.Bancho.Score> available_scores = api.GetUserRecentScores("6885792", true, 10);

            //    DateTime latest_score = last_score;
            //    foreach (var score in available_scores)
            //        if (score.created_at > last_score)
            //        {
            //            new_scores.Add(score);
            //            if (latest_score < score.created_at)
            //                latest_score = score.created_at;
            //        }

            //    if (new_scores.Count != 0)
            //    {
            //        Console.WriteLine();
            //        foreach (var score in new_scores)
            //        {
            //            Console.WriteLine($"Title: {score.beatmapset.title} [{score.beatmap.version}]");
            //            Console.WriteLine($"Artist: {score.beatmapset.artist}");
            //            Console.WriteLine($"{score.rank}, {score.accuracy}%, {score.pp}, {score.statistics.count_300}, {score.statistics.count_100}, {score.statistics.count_50}, {score.statistics.count_miss}");
            //            Console.WriteLine();
            //        }

            //        last_score = latest_score;
            //    }
            //    else
            //    {
            //        Console.Write(".");
            //    }

            //    Thread.Sleep(10000);
            //}
            #endregion

            #region Gatari tracker

            /*
             * DateTime last_score = DateTime.Now - TimeSpan.FromDays(3);
             * while (true)
             * {
             *  List<WAV_Osu_NetApi.Models.Gatari.Score> new_scores = new List<WAV_Osu_NetApi.Models.Gatari.Score>();
             *  List<WAV_Osu_NetApi.Models.Gatari.Score> available_scores = api.GetUserRecentScores(21129, true, 3);
             *
             *  //Console.WriteLine(available_scores.Last().time);
             *
             *  DateTime latest_score = last_score;
             *  foreach (var score in available_scores)
             *      if (score.time > last_score)
             *      {
             *          new_scores.Add(score);
             *          if (latest_score < score.time)
             *              latest_score = score.time;
             *      }
             *
             *  if (new_scores.Count != 0)
             *  {
             *      Console.WriteLine();
             *      foreach (var score in new_scores)
             *      {
             *          Console.WriteLine($"Title: {score.beatmap.song_name}");
             *          Console.WriteLine($"{score.ranking}, {score.accuracy}%, {score.pp}, {score.count_300}, {score.count_100}, {score.count_50}, {score.count_miss}");
             *          Console.WriteLine();
             *      }
             *
             *      last_score = latest_score;
             *  }
             *  else
             *  {
             *      Console.Write(".");
             *  }
             *
             *  Thread.Sleep(10000);
             * }
             */
            #endregion

            #region Bancho search

            //var bms = api.Search("Oznei Haman wa Mou Iranai [jump training]", WAV_Osu_NetApi.Bancho.QuerryParams.MapType.Any);
            //foreach (var bm in bms)
            //    Console.WriteLine($"{bm.title}\n{bm.artist}");

            #endregion

            #region Bancho TryGetUsr

            //User validUser = null, invalidUser;

            //api.TryGetUser(9604150, ref validUser);
            //api.TryGetUser(687687654, out invalidUser);

            //Console.WriteLine(validUser);
            //Console.WriteLine(invalidUser);

            #endregion

            #region Bancho Get Beatmapset

            //Beatmapset bm = api.GetBeatmapset(372510);


            #endregion

            //api.TryRetrieveBeatmap(1114721);
        }