Ejemplo n.º 1
0
        public override async Task Enable()
        {
            if (this.LeaderboardType == OverlayLeaderboardListItemTypeEnum.Subscribers)
            {
                this.userSubDates.Clear();
                IEnumerable <UserSubscriptionModel> subscribers = await ChannelSession.TwitchUserConnection.GetSubscribersV5(ChannelSession.TwitchChannelV5, int.MaxValue);

                foreach (UserSubscriptionModel subscriber in subscribers)
                {
                    UserViewModel user = await UserViewModel.Create(subscriber.user);

                    DateTimeOffset?subDate = TwitchPlatformService.GetTwitchDateTime(subscriber.created_at);
                    if (subDate.HasValue && this.ShouldIncludeUser(user))
                    {
                        this.userSubDates[user.ID] = subDate.GetValueOrDefault();
                    }
                }

                await this.UpdateSubscribers();

                GlobalEvents.OnSubscribeOccurred          += GlobalEvents_OnSubscribeOccurred;
                GlobalEvents.OnResubscribeOccurred        += GlobalEvents_OnResubscribeOccurred;
                GlobalEvents.OnSubscriptionGiftedOccurred += GlobalEvents_OnSubscriptionGiftedOccurred;
            }
            else if (this.LeaderboardType == OverlayLeaderboardListItemTypeEnum.Donations)
            {
                GlobalEvents.OnDonationOccurred += GlobalEvents_OnDonationOccurred;
            }

            await base.Enable();
        }
Ejemplo n.º 2
0
        private async Task RefreshTwitchUserAccountDate()
        {
            TwitchV5API.Users.UserModel twitchV5User = await ChannelSession.TwitchUserConnection.GetV5APIUserByLogin(this.TwitchUsername);

            if (twitchV5User != null && !string.IsNullOrEmpty(twitchV5User.created_at))
            {
                this.AccountDate = TwitchPlatformService.GetTwitchDateTime(twitchV5User.created_at);
            }
        }
        public static Task <DateTimeOffset> GetStartTime()
        {
            DateTimeOffset startTime = DateTimeOffset.MinValue;

            if (ChannelSession.TwitchStreamNewAPI != null)
            {
                startTime = TwitchPlatformService.GetTwitchDateTime(ChannelSession.TwitchStreamNewAPI.started_at).GetValueOrDefault();
            }
            return(Task.FromResult(startTime));
        }
Ejemplo n.º 4
0
        private async Task RefreshTwitchUserFollowDate()
        {
            UserFollowModel follow = await ChannelSession.TwitchUserConnection.CheckIfFollowsNewAPI(ChannelSession.TwitchUserNewAPI, this.GetTwitchNewAPIUserModel());

            if (follow != null && !string.IsNullOrEmpty(follow.followed_at))
            {
                this.FollowDate = TwitchPlatformService.GetTwitchDateTime(follow.followed_at);
            }
            else
            {
                this.FollowDate = null;
            }
        }
Ejemplo n.º 5
0
        private async Task RefreshTwitchUserSubscribeDate()
        {
            if (ChannelSession.TwitchUserNewAPI.IsAffiliate() || ChannelSession.TwitchUserNewAPI.IsPartner())
            {
                TwitchV5API.Users.UserSubscriptionModel subscription = await ChannelSession.TwitchUserConnection.CheckIfSubscribedV5(ChannelSession.TwitchChannelV5, this.GetTwitchV5APIUserModel());

                if (subscription != null && !string.IsNullOrEmpty(subscription.created_at))
                {
                    this.SubscribeDate             = TwitchPlatformService.GetTwitchDateTime(subscription.created_at);
                    this.Data.TwitchSubscriberTier = TwitchEventService.GetSubTierNumberFromText(subscription.sub_plan);
                }
                else
                {
                    this.SubscribeDate             = null;
                    this.Data.TwitchSubscriberTier = 0;
                }
            }
        }