Exemplo n.º 1
0
        private void button20_Click(object sender, EventArgs e)
        {
            List <TwitchLib.TwitchAPIClasses.TwitchFollower> followers = TwitchApi.GetTwitchFollowers(textBox24.Text).Result;

            foreach (TwitchLib.TwitchAPIClasses.TwitchFollower follower in 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
        private async void button20_Click(object sender, EventArgs e)
        {
            TwitchLib.TwitchAPIClasses.FollowersResponse response = await TwitchApi.GetTwitchFollowers(textBox24.Text);

            MessageBox.Show($"Cursor: {response.Cursor}\nFollower Count: {response.TotalFollowerCount}");
            foreach (TwitchLib.TwitchAPIClasses.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.º 3
0
        /// <summary>Downloads recent followers from Twitch, starts service, fires OnServiceStarted event.</summary>
        public async void StartService()
        {
            TwitchAPIClasses.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.º 4
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
                    });
                }
            }
        }
Exemplo n.º 5
0
        private async void _followerServiceTimerElapsed(object sender, ElapsedEventArgs e)
        {
            TwitchAPIClasses.FollowersResponse response = await TwitchApi.GetTwitchFollowers(Channel, QueryCount);

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

            if (ActiveCache == null)
            {
                ActiveCache  = mostRecentFollowers;
                newFollowers = ActiveCache;
            }
            else
            {
                if (ActiveCache[0].User.Name != mostRecentFollowers[0].User.Name)
                {
                    for (int i = 0; i < mostRecentFollowers.Count; i++)
                    {
                        if (mostRecentFollowers[i].User.Name != ActiveCache[0].User.Name)
                        {
                            newFollowers.Add(mostRecentFollowers[i]);
                        }
                        else
                        {
                            break;
                        }
                    }
                    ActiveCache = mostRecentFollowers;
                }
            }
            if (newFollowers.Count > 0)
            {
                OnNewFollowersDetected?.Invoke(this,
                                               new OnNewFollowersDetectedArgs {
                    Channel = Channel, CheckIntervalSeconds = CheckIntervalSeconds, QueryCount = QueryCount, NewFollowers = newFollowers
                });
            }
        }