コード例 #1
0
        static void Main(string[] args)
        {
            string key = string.Empty;

            Console.WriteLine("input key");
            while (key == string.Empty)
            {
                key = Console.ReadLine().Trim();
            }
            var api = OsuApiClient.ClientUsingKey(key);
            //var beatmap = api.GetBeatmapsAsync(1441454).Result;

            //var recent = api.GetRecentlyAsync(6659067, Mode.Standard, 15).Result;
            //recent = api.GetRecentlyAsync("bleatingsheep", Mode.Standard, 17).Result;

            var best = api.GetBestPerformancesAsync(6659067, Mode.Taiko, 15).Result;

            //foreach (var item in best)
            //{
            //    double d = item.DoubleAccuracy;
            //    decimal m = item.Accuracy;
            //    Console.WriteLine(Math.Pow(d, 1024));
            //    Console.WriteLine(Math.Pow((double)m, 1024));
            //    for (int i = 0; i < 10; i++)
            //    {
            //        d *= d;
            //        m *= m;
            //    }
            //    Console.WriteLine(d);
            //    Console.WriteLine(m);
            //}
            best = api.GetBestPerformancesAsync("bleatingsheep", Mode.Mania, 17).Result;
        }
コード例 #2
0
        public static Message GetMusicMessage(OsuApiClient osuApi, BloodcatBeatmapSet set)
        {
            int    setId = set.Id;
            string info  = string.Empty;

            info += set.Beatmaps.Max(b => b.TotalLength) + "s, ";
            if (set.Beatmaps.Length > 1)
            {
                info += $"{set.Beatmaps.Min(b => b.Stars):0.##}* - {set.Beatmaps.Max(b => b.Stars):0.##}*";
            }
            else
            {
                info += $"{set.Beatmaps.Single()?.Stars:0.##}*";
            }

            // Creator and BPM
            info += "\r\n" + $"by {set.Creator}";
            var bpms = set.Beatmaps.Select(b => b.Bpm).Distinct().ToList();

            if (bpms.Count == 1)
            {
                info += $" ♩{bpms.First():#.##}";
            }

            if (!string.IsNullOrEmpty(set.Source))
            {
                info += "\r\n" + $"From {set.Source}";
            }
            Message message = SendingMessage.MusicCustom(osuApi.PageOfSetOld(setId), osuApi.PreviewAudioOf(setId), $"{set.Title}/{set.Artist}", info, osuApi.ThumbOf(setId));

            return(message);
        }
コード例 #3
0
        public static async Task <UserInfo> EnsureGetUserInfo(this OsuApiClient osuApi, string name, Bleatingsheep.Osu.Mode mode)
        {
            var(success, result) = await osuApi.GetUserInfoAsync(name, mode);

            ExecutingException.Ensure(success, "网络错误。");
            ExecutingException.Ensure(result != null, "无此用户!");
            return(result);
        }
コード例 #4
0
 public PerformancePlusUser(
     INewbieDatabase database,
     ILegacyDataProvider dataProvider,
     OsuApiClient osuApi,
     ILogger <PerformancePlusUser> logger)
 {
     Database     = database;
     DataProvider = dataProvider;
     OsuApi       = osuApi;
     _logger      = logger;
 }
コード例 #5
0
        public static async Task <(bool, UserInfo)> GetCachedUserInfo(this OsuApiClient osuApi, int id, Bleatingsheep.Osu.Mode mode)
        {
            var hasCache = s_cache.TryGetValue <UserInfo>((id, mode), out var cachedInfo);

            if (hasCache)
            {
                return(true, cachedInfo);
            }
            var(success, userInfo) = await osuApi.GetUserInfoAsync(id, mode);

            if (success)
            {
                s_cache.Set((id, mode), userInfo, CacheAvailable);
                return(true, userInfo);
            }
            else
            {
                // fail
                return(default);
コード例 #6
0
        public OsuQqBot(IQqBot qqBot)
        {
            qq        = qqBot;
            QqApi     = qq;
            CurrentQq = qq.GetLoginQq();
            Config config = JsonConvert.DeserializeObject <Config>(File.ReadAllText(Paths.JsonConfigPath));

            id_Kamisama          = config.Kamisama;
            IdWhoLovesInt100Best = id_Kamisama;
            GroupId = config.MainGroup;
            foreach (var item in config.ValidGroups)
            {
                ValidGroups.Add(item);
            }

            try
            {
                var ignoreLines = File.ReadAllLines(Paths.IgnoreListPath);
                if (ignoreLines.Length == 2)
                {
                    ignoreList   = JsonConvert.DeserializeObject <HashSet <long> >(ignoreLines[0]);
                    ignorePPList = JsonConvert.DeserializeObject <HashSet <long> >(ignoreLines[1]);
                }
            }
            catch (FileNotFoundException)
            { }
            if (ignoreList == null)
            {
                ignoreList = new HashSet <long>();
            }
            if (ignorePPList == null)
            {
                ignorePPList = new HashSet <long>();
            }

            osuApiKey = config.ApiKey;
            apiClient = new OsuApiClient(config.ApiKey);

            qq.GroupAdminChange += OnGroupAdminChanged;

            qq.GroupMemberIncrease += OnGroupMemberIncreased;
        }
コード例 #7
0
        public static void SetApiKey(string apiKey)
        {
            OsuApi = OsuApiClient.ClientUsingKey(apiKey);

            s_osuApiFactory = OsuApiClientFactory.CreateFactory(apiKey);
        }
コード例 #8
0
 public Highlight(OsuApiClient osuApi, IDbContextFactory <NewbieContext> dbContextFactory)
 {
     OsuApi            = osuApi;
     _dbContextFactory = dbContextFactory;
 }
コード例 #9
0
 public NewlyRankedBeatmapNotify(OsuApiClient osuApi)
 {
     OsuApi = osuApi;
 }