示例#1
0
        private YouTubeLiveMessageContext CreateMessageContext(CommentData commentData, bool isInitialComment)
        {
            var message  = CreateMessage(commentData);
            var metadata = CreateMetadata(message, isInitialComment);
            var methods  = new YouTubeLiveMessageMethods();

            if (_siteOptions.IsAutoSetNickname)
            {
                var user        = metadata.User;
                var messageText = Common.MessagePartsTools.ToText(message.CommentItems);
                var nick        = SitePluginCommon.Utils.ExtractNickname(messageText);
                if (!string.IsNullOrEmpty(nick))
                {
                    user.Nickname = nick;
                }
            }
            return(new YouTubeLiveMessageContext(message, metadata, methods));
        }
示例#2
0
        private YouTubeLiveMessageContext CreateMessageContext(CommentData commentData, bool isInitialComment)
        {
            IYouTubeLiveMessage        message;
            IEnumerable <IMessagePart> commentItems;
            IEnumerable <IMessagePart> nameItems;

            if (commentData.IsPaidMessage)
            {
                var superchat = new YouTubeLiveSuperchat(commentData);
                message      = superchat;
                nameItems    = superchat.NameItems;
                commentItems = superchat.CommentItems;
            }
            else
            {
                var comment = new YouTubeLiveComment(commentData);
                message      = comment;
                nameItems    = comment.NameItems;
                commentItems = comment.CommentItems;
            }
            var metadata = CreateMetadata(message, isInitialComment);
            var methods  = new YouTubeLiveMessageMethods();

            if (_siteOptions.IsAutoSetNickname)
            {
                var user        = metadata.User;
                var messageText = Common.MessagePartsTools.ToText(commentItems);
                var nick        = SitePluginCommon.Utils.ExtractNickname(messageText);
                if (!string.IsNullOrEmpty(nick))
                {
                    user.Nickname = nick;
                }
            }
            metadata.User.Name = nameItems;
            return(new YouTubeLiveMessageContext(message, metadata, methods));
        }