public async Task GetCurrentSubscriptions(IEnumerable <string> channelIds)
        {
            var subscriptionEntries = await _twitchHttpClient.GetSubscriptionData(channelIds);

            foreach (var entry in subscriptionEntries)
            {
                var user = TwitchUsers.FirstOrDefault(x => string.Equals(entry.Key, x.Id));
                if (user != null)
                {
                    user.IsStreamSubscribed = (entry.Value & TwitchSubscriptionStatus.StreamSubscription) == TwitchSubscriptionStatus.StreamSubscription;
                    user.IsFollowSubscribed = (entry.Value & TwitchSubscriptionStatus.FollowerSubscription) == TwitchSubscriptionStatus.FollowerSubscription;
                }
            }
        }
        public async Task <List <string> > GetBannedList(List <string> channels)
        {
            if (channels.Count == 0)
            {
                return(null);
            }

            // Call Twitch and get the list of banned us
            foreach (var channel in channels)
            {
                await LoadChannelData(channel);

                var user = TwitchUsers.FirstOrDefault(result =>
                                                      string.Equals(result.LoginName, channel, StringComparison.CurrentCultureIgnoreCase));
                var response = await _twitchHttpClient.GetBannedUsers(user.Id);
            }

            return(null);
        }
Beispiel #3
0
        private async Task UpdateStreamChangeSubscription(List <string> channels, bool isSubscribed)
        {
            foreach (var channel in channels)
            {
                var selected = TwitchUsers.FirstOrDefault(user => string.Equals(channel, user.LoginName, StringComparison.InvariantCultureIgnoreCase));
                // TODO: Inject callback url into UpdateSubscription methods

                var request = new TwitchWebhookRequest
                {
                    Callback = $"https://twitchchatbotfx20200511150805.azurewebsites.net/api/subscription/streams/{channel}",
                    Mode     = isSubscribed ? "subscribe" : "unsubscribe",
                    Topic    = $"https://api.twitch.tv/helix/streams?user_id={selected.Id}",
                    Lease    = 864000
                };

                var url      = new Uri(Constants.TWITCH_WEBHOOKS_SUBSCRIPTION_URL);
                var response = await MakeHttpPostRequest(url, request, AccessToken);
            }
        }