/// <summary>
        /// Adds a new moderator for the chat.
        /// Documentation https://developers.google.com/youtube/v3/reference/liveChatModerators/insert
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Youtube service.</param>
        /// <param name="part">The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response returns. Set the parameter value to snippet.</param>
        /// <param name="body">A valid Youtube v3 body.</param>
        /// <returns>LiveChatModeratorResponse</returns>
        public static LiveChatModerator Insert(YoutubeService service, string part, LiveChatModerator body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (part == null)
                {
                    throw new ArgumentNullException(part);
                }

                // Make the request.
                return(service.LiveChatModerators.Insert(body, part).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request LiveChatModerators.Insert failed.", ex);
            }
        }
Example #2
0
 /// <summary>
 /// Removes moderator privileges from the specified user.
 /// </summary>
 /// <param name="moderator">The user to unmode</param>
 /// <returns>An awaitable Task</returns>
 public async Task UnmodUser(LiveChatModerator moderator)
 {
     Validator.ValidateVariable(moderator, "moderator");
     await this.YouTubeServiceWrapper <object>(async() =>
     {
         LiveChatModeratorsResource.DeleteRequest request = this.connection.GoogleYouTubeService.LiveChatModerators.Delete(moderator.Id);
         await request.ExecuteAsync();
         return(null);
     });
 }
Example #3
0
        /// <summary>
        /// Makes the specified user a moderator.
        /// </summary>
        /// <param name="broadcast">The broadcast of the live chat</param>
        /// <param name="user">The user to mod</param>
        /// <returns>Information about the modded user</returns>
        public async Task <LiveChatModerator> ModUser(LiveBroadcast broadcast, Channel user)
        {
            Validator.ValidateVariable(broadcast, "broadcast");
            Validator.ValidateVariable(user, "user");
            return(await this.YouTubeServiceWrapper(async() =>
            {
                LiveChatModerator moderator = new LiveChatModerator();
                moderator.Snippet = new LiveChatModeratorSnippet();
                moderator.Snippet.LiveChatId = broadcast.Snippet.LiveChatId;
                moderator.Snippet.ModeratorDetails = new ChannelProfileDetails();
                moderator.Snippet.ModeratorDetails.ChannelId = user.Id;

                LiveChatModeratorsResource.InsertRequest request = this.connection.GoogleYouTubeService.LiveChatModerators.Insert(moderator, "snippet");
                return await request.ExecuteAsync();
            }));
        }
Example #4
0
        public async Task <bool> addModerator(string chatID, ChannelUser channelUser)
        {
            LiveChatModerator     liveChatModerator     = new LiveChatModerator();
            ChannelProfileDetails channelProfileDetails = new ChannelProfileDetails()
            {
                ChannelId       = channelUser.ChannelID,
                ChannelUrl      = channelUser.ChannelURL,
                DisplayName     = channelUser.DisplayName,
                ProfileImageUrl = channelUser.ProfileImageURL
            };

            liveChatModerator.Snippet = new LiveChatModeratorSnippet()
            {
                LiveChatId       = chatID,
                ModeratorDetails = channelProfileDetails
            };
            var response = await youTubeService.LiveChatModerators.Insert(liveChatModerator, "snippet").ExecuteAsync();

            return(response != null);
        }
Example #5
0
 /// <summary>
 /// Removes moderator privileges from the specified user.
 /// </summary>
 /// <param name="moderator">The user to unmode</param>
 /// <returns>An awaitable Task</returns>
 public async Task UnmodUser(LiveChatModerator moderator)
 {
     await this.connection.LiveChat.UnmodUser(moderator);
 }