Exemplo n.º 1
0
        public void CheckAction(Account user, DateTime lastCheck)
        {
            TwitchAPI api = _twitchService.GetApi(user);

            if (api == null)
            {
                return;
            }
            var game = api.Helix.Games.GetGamesAsync(null, new List <string>()
            {
                "Super Smash Bros. Ultimate"
            }).GetAwaiter().GetResult();

            if (game.Games.Length > 0)
            {
                var clips = api.Helix.Clips.GetClipAsync(null, game.Games[0].Id).GetAwaiter().GetResult();
                for (int i = 0; i < clips.Clips.Length; i++)
                {
                    if (Convert.ToDateTime(clips.Clips[i].CreatedAt) > lastCheck)
                    {
                        _newClips.Add(clips.Clips[i]);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public bool Execute(Account user, object result, string args)
        {
            TwitchAPI   api   = _twitchService.GetApi(user);
            List <User> users = result as List <User>;

            Console.WriteLine("Executing FollowUsers Twitch Reaction");
            if (users == null || api == null)
            {
                return(false);
            }
            for (int i = 0; i < users.Count; i++)
            {
                Console.WriteLine("Following " + users[i].DisplayName);
                api.V5.Users.FollowChannelAsync(users[i].Id, users[i].Id);
            }
            return(true);
        }
Exemplo n.º 3
0
        public void CheckAction(Account user, DateTime lastCheck)
        {
            Console.WriteLine("Checking NewSubTwitchAction");
            TwitchAPI api         = _twitchService.GetApi(user);
            var       currentUser = api.Helix.Users.GetUsersAsync().Result;

            if (currentUser.Users.Length <= 0)
            {
                Console.WriteLine("Current user id not found");
                return;
            }
            GetUsersFollowsResponse userFollows = api.Helix.Users.GetUsersFollowsAsync("", "", 20, "", currentUser.Users[0].Id).Result;
            List <string>           followerIds = new List <string>();

            if (userFollows.Follows.Length <= 0)
            {
                Console.WriteLine("No followers for user " + currentUser.Users[0].DisplayName);
            }
            for (int i = 0; i < userFollows.Follows.Length; i++)
            {
                Console.WriteLine("Follower : " + userFollows.Follows[i].ToUserId);
                if (userFollows.Follows[i].FollowedAt > lastCheck)
                {
                    if (_lastTriggerDate == null)
                    {
                        _lastTriggerDate = userFollows.Follows[i].FollowedAt;
                    }
                    else if (_lastTriggerDate < userFollows.Follows[i].FollowedAt)
                    {
                        _lastTriggerDate = userFollows.Follows[i].FollowedAt;
                    }
                    Console.WriteLine("New !");
                    followerIds.Add(userFollows.Follows[i].FromUserId);
                }
                else
                {
                    Console.WriteLine("Not new");
                }
            }
            if (followerIds.Count > 0)
            {
                _newFollowers = api.Helix.Users.GetUsersAsync(followerIds).Result.Users.ToList();
            }
        }