예제 #1
0
        public async Task Subscribe(WebSubHandler webSubHandler)
        {
            string externalAddress = await webAccessConfig.GetExternalWebSubAddress();

            externalURL = $"{externalAddress}/TASagentBotAPI/WebSub/Stream";
            subURL      = $"https://api.twitch.tv/helix/streams?user_id={botConfig.BroadcasterId}";

            bool success = await helixHelper.WebhookSubscribe(
                callback : externalURL,
                mode : "subscribe",
                topic : subURL,
                lease : 48 * 60 * 60,
                secret : webSubHandler.CreateSecretForRoute("/TASagentBotAPI/WebSub/Stream"));

            if (!success)
            {
                communication.SendErrorMessage("Failed to subscribe to Stream Changes. Aborting.");

                externalURL = null;
                subURL      = null;

                return;
            }

            TwitchStreams streamData = await helixHelper.GetStreams(userIDs : new List <string>()
            {
                botConfig.BroadcasterId
            });

            if (streamData.Data is null || streamData.Data.Count == 0)
            {
                currentStreamData = null;
            }
        public async Task Subscribe(WebSubHandler webSubHandler)
        {
            string externalAddress = await webAccessConfig.GetExternalWebSubAddress();

            externalURL = $"{externalAddress}/TASagentBotAPI/WebSub/Followers";

            subURL = $"https://api.twitch.tv/helix/users/follows?first=1&to_id={botConfig.BroadcasterId}";

            bool success = await helixHelper.WebhookSubscribe(
                callback : externalURL,
                mode : "subscribe",
                topic : subURL,
                lease : 48 * 60 * 60,
                secret : webSubHandler.CreateSecretForRoute("/TASagentBotAPI/WebSub/Followers"));

            if (!success)
            {
                communication.SendErrorMessage("Failed to subscribe to Follows. Aborting.");

                externalURL = null;
                subURL      = null;
            }
        }