예제 #1
0
        public override async Task <JObject> GetProcessedItem(UserViewModel user, IEnumerable <string> arguments, Dictionary <string, string> extraSpecialIdentifiers, StreamingPlatformTypeEnum platform)
        {
            List <OverlayLeaderboardItem> items = new List <OverlayLeaderboardItem>();

            if (this.LeaderboardType == OverlayLeaderboardListItemTypeEnum.CurrencyRank)
            {
                if (ChannelSession.Settings.Currency.ContainsKey(this.CurrencyID))
                {
                    CurrencyModel currency = ChannelSession.Settings.Currency[this.CurrencyID];
                    IEnumerable <UserDataModel> userDataList = SpecialIdentifierStringBuilder.GetUserOrderedCurrencyList(currency);
                    for (int i = 0; i < userDataList.Count() && items.Count < this.TotalToShow; i++)
                    {
                        UserDataModel userData = userDataList.ElementAt(i);
                        if (!userData.IsCurrencyRankExempt)
                        {
                            items.Add(new OverlayLeaderboardItem(new UserViewModel(userData), currency.GetAmount(userData).ToString()));
                        }
                    }
                }
            }
            else if (this.LeaderboardType == OverlayLeaderboardListItemTypeEnum.Bits && this.lastQuery.TotalMinutesFromNow() > 1)
            {
                BitsLeaderboardModel bitsLeaderboard = null;
                switch (this.BitsLeaderboardDateRange)
                {
                case BitsLeaderboardPeriodEnum.Day:
                    bitsLeaderboard = await ChannelSession.TwitchUserConnection.GetBitsLeaderboard(BitsLeaderboardPeriodEnum.Day, this.TotalToShow);

                    break;

                case BitsLeaderboardPeriodEnum.Week:
                    bitsLeaderboard = await ChannelSession.TwitchUserConnection.GetBitsLeaderboard(BitsLeaderboardPeriodEnum.Week, this.TotalToShow);

                    break;

                case BitsLeaderboardPeriodEnum.Month:
                    bitsLeaderboard = await ChannelSession.TwitchUserConnection.GetBitsLeaderboard(BitsLeaderboardPeriodEnum.Month, this.TotalToShow);

                    break;

                case BitsLeaderboardPeriodEnum.Year:
                    bitsLeaderboard = await ChannelSession.TwitchUserConnection.GetBitsLeaderboard(BitsLeaderboardPeriodEnum.Year, this.TotalToShow);

                    break;

                case BitsLeaderboardPeriodEnum.All:
                    bitsLeaderboard = await ChannelSession.TwitchUserConnection.GetBitsLeaderboard(BitsLeaderboardPeriodEnum.All, this.TotalToShow);

                    break;
                }
                this.lastQuery = DateTimeOffset.Now;

                if (bitsLeaderboard != null && bitsLeaderboard.users != null)
                {
                    foreach (BitsLeaderboardUserModel bitsUser in bitsLeaderboard.users.OrderBy(u => u.rank).Take(this.TotalToShow))
                    {
                        items.Add(new OverlayLeaderboardItem(bitsUser.user_name, bitsUser.score.ToString()));
                    }
                }
            }

            if (items.Count > 0)
            {
                await this.ProcessLeaderboardItems(items);
            }

            return(await base.GetProcessedItem(user, arguments, extraSpecialIdentifiers, platform));
        }