private YouTubeLiveMessageContext CreateMessageContext2(SuperChat text, bool isInitialComment) { IYouTubeLiveMessage message; IEnumerable <SitePlugin.IMessagePart> commentItems; IEnumerable <SitePlugin.IMessagePart> nameItems; var a = new YouTubeLiveSuperchat(text); message = a; nameItems = a.NameItems; commentItems = a.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)); }
private IYouTubeLiveMessage CreateMessage(CommentData data) { IYouTubeLiveMessage message; if (data.IsPaidMessage) { message = new YouTubeLiveSuperchat(data); } else { message = new YouTubeLiveComment(data); } return(message); }
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)); }