Exemplo n.º 1
0
        public Task ModifyChannelInformationAsync(string broadcasterId, ModifyChannelInformationRequest request, string accessToken = null)
        {
            var getParams = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("broadcaster_id", broadcasterId)
            };

            return(TwitchPatchAsync("/channels", ApiVersion.Helix, JsonConvert.SerializeObject(request), getParams, accessToken));
        }
Exemplo n.º 2
0
        private async void HandleChangeTitleCmd(object sender, OnChatCommandReceivedArgs e)
        {
            if (!(sender is TwitchClient senderClient))
            {
                return;
            }

            if (!Extensions.IsHost(senderClient.TwitchUsername))
            {
                return;
            }

            string newTitle = e.Command.ArgumentsAsString;

            if (newTitle == null || newTitle.Length <= 0)
            {
                return;
            }

            GetUsersResponse resp = await LeTwitchBot.BotAPI.Helix.Users.GetUsersAsync(null, new List <string> {
                senderClient.TwitchUsername
            });

            if (resp.Users.Length <= 0)
            {
                return;
            }
            User user = resp.Users[0];

            if (!user.DisplayName.ToLower().Equals(LeTwitchBot.HostChannelName.ToLower()))
            {
                return;
            }

            GetChannelInformationResponse existingInfo = await LeTwitchBot.BotAPI.Helix.Channels.GetChannelInformationAsync(user.Id);

            if (existingInfo.Data.Length <= 0)
            {
                return;
            }
            ChannelInformation info = existingInfo.Data[0];


            ModifyChannelInformationRequest changeReq = new ModifyChannelInformationRequest();

            changeReq.BroadcasterLanguage = info.BroadcasterLanguage;
            changeReq.Title  = newTitle;
            changeReq.GameId = info.GameId;

            await LeTwitchBot.BotAPI.Helix.Channels.ModifyChannelInformationAsync(user.Id, changeReq, LeTwitchBot.Secrets.HostChannelUserToken);


            LeTwitchBot.TwitchClient.SendHostChannelMessage($"Broadcaster {user.DisplayName} has changed the title of the stream to '{newTitle}' CoolCat CoolCat CoolCat CoolCat");
        }
Exemplo n.º 3
0
        private async void HandleSetGame(object sender, OnChatCommandReceivedArgs e)
        {
            if (!(sender is TwitchClient senderClient))
            {
                return;
            }

            if (!Extensions.IsHost(senderClient.TwitchUsername))
            {
                return;
            }

            string newGame = e.Command.ArgumentsAsString;

            if (newGame == null || newGame.Length <= 0)
            {
                return;
            }

            GetUsersResponse resp = await LeTwitchBot.BotAPI.Helix.Users.GetUsersAsync(null, new List <string> {
                senderClient.TwitchUsername
            });

            if (resp.Users.Length <= 0)
            {
                return;
            }
            User user = resp.Users[0];

            if (!user.DisplayName.ToLower().Equals(LeTwitchBot.HostChannelName.ToLower()))
            {
                return;
            }

            GetChannelInformationResponse existingInfo = await LeTwitchBot.BotAPI.Helix.Channels.GetChannelInformationAsync(user.Id);

            if (existingInfo.Data.Length <= 0)
            {
                return;
            }
            ChannelInformation info = existingInfo.Data[0];

            GetGamesResponse gameResponse = await LeTwitchBot.BotAPI.Helix.Games.GetGamesAsync(null, new List <string> {
                newGame
            });

            if (gameResponse.Games.Length <= 0)
            {
                LeTwitchBot.TwitchClient.SendHostChannelMessage($"Couldn't locate {newGame} :( :( :( :( ");
                return;
            }

            Game tehGame = gameResponse.Games[0];


            ModifyChannelInformationRequest changeReq = new ModifyChannelInformationRequest();

            changeReq.BroadcasterLanguage = info.BroadcasterLanguage;
            changeReq.Title  = info.Title;
            changeReq.GameId = tehGame.Id;

            await LeTwitchBot.BotAPI.Helix.Channels.ModifyChannelInformationAsync(user.Id, changeReq, LeTwitchBot.Secrets.HostChannelUserToken);


            LeTwitchBot.TwitchClient.SendHostChannelMessage($"Broadcaster {user.DisplayName} will now be playin' {tehGame.Name} Kappa Kappa Kappa Kappa");
        }