Exemplo n.º 1
0
        private async void button20_Click(object sender, EventArgs e)
        {
            FollowersResponse response = await TwitchApi.GetTwitchFollowers(textBox24.Text);

            MessageBox.Show($"Cursor: {response.Cursor}\nFollower Count: {response.TotalFollowerCount}");
            foreach (Follower follower in response.Followers)
            {
                MessageBox.Show(string.Format("notifications: {0}\ncreated at:{1}\n[user] name: {2}\n[user] display name: {3}\n[user] bio: {4}\n [user] logo: {5}\n[user] created at: {6}\n[user] updated at: {7}", follower.Notifications, follower.CreatedAt, follower.User.Name, follower.User.DisplayName, follower.User.Bio, follower.User.Logo, follower.User.CreatedAt, follower.User.UpdatedAt));
            }
        }
Exemplo n.º 2
0
        /// <summary>Downloads recent followers from Twitch, starts service, fires OnServiceStarted event.</summary>
        public async void StartService()
        {
            FollowersResponse response = await TwitchApi.GetTwitchFollowers(Channel, QueryCount);

            ActiveCache = response.Followers;
            _followerServiceTimer.Start();
            OnServiceStarted?.Invoke(this,
                                     new OnServiceStartedArgs {
                Channel = Channel, CheckIntervalSeconds = CheckIntervalSeconds, QueryCount = QueryCount
            });
        }
Exemplo n.º 3
0
        private async void _followerServiceTimerElapsed(object sender, ElapsedEventArgs e)
        {
            FollowersResponse response = await TwitchApi.GetTwitchFollowers(Channel, QueryCount);

            List <Follower> mostRecentFollowers = response.Followers;
            List <Follower> newFollowers        = new List <Follower>();

            if (ActiveCache == null)
            {
                ActiveCache  = mostRecentFollowers;
                newFollowers = ActiveCache;
            }
            else
            {
                foreach (Follower recentFollower in mostRecentFollowers)
                {
                    bool found = false;
                    foreach (Follower cachedFollower in ActiveCache)
                    {
                        if (recentFollower.User.Name.ToLower() == cachedFollower.User.Name.ToLower())
                        {
                            found = true;
                        }
                    }
                    if (!found)
                    {
                        newFollowers.Add(recentFollower);
                    }
                }

                // Check for new followers
                if (newFollowers.Count > 0)
                {
                    // add new followers to active cache
                    ActiveCache.AddRange(newFollowers);

                    // prune cache so we don't use too much space unnecessarily
                    if (ActiveCache.Count > CacheSize)
                    {
                        ActiveCache = ActiveCache.GetRange(ActiveCache.Count - (CacheSize + 1), CacheSize);
                    }

                    // Invoke new followers event
                    OnNewFollowersDetected?.Invoke(this,
                                                   new OnNewFollowersDetectedArgs {
                        Channel = Channel, CheckIntervalSeconds = CheckIntervalSeconds, QueryCount = QueryCount, NewFollowers = newFollowers
                    });
                }
            }
        }