Beispiel #1
0
        private YouTubeLiveMessageContext CreateMessageContext2(InternalSuperChat superChat, bool isInitialComment)
        {
            IYouTubeLiveMessage        message;
            IEnumerable <IMessagePart> commentItems;
            IEnumerable <IMessagePart> nameItems;

            var a = new YouTubeLiveSuperchat(superChat);

            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));
        }
Beispiel #2
0
 public YouTubeLiveSuperchat(Next.InternalSuperChat comment) : base("")
 {
     UserId       = comment.UserId;
     Id           = comment.Id;
     CommentItems = comment.MessageItems;
     NameItems    = comment.NameItems;
     UserIcon     = new Common.MessageImage
     {
         Height = comment.ThumbnailHeight,
         Width  = comment.ThumbnailWidth,
         Url    = comment.ThumbnailUrl,
     };
     PostedAt       = SitePluginCommon.Utils.UnixtimeToDateTime(comment.TimestampUsec / (1000 * 1000));
     PurchaseAmount = comment.PurchaseAmount;
 }
Beispiel #3
0
        public static InternalSuperChat ParseLiveChatPaidMessageRenderer(dynamic ren)
        {
            var ahh = new InternalSuperChat
            {
                UserId        = (string)ren.authorExternalChannelId,
                TimestampUsec = long.Parse((string)ren.timestampUsec),
                Id            = (string)ren.id
            };

            //authorPhoto
            (ahh.ThumbnailUrl, ahh.ThumbnailWidth, ahh.ThumbnailHeight) = (ValueTuple <string, int, int>)GetThumbnail(ren.authorPhoto);
            //message
            ahh.MessageItems = (List <IMessagePart>)GetMessageParts(ren);
            //name
            ahh.NameItems = (List <IMessagePart>)GetNameParts(ren);
            //purchaseAmount
            ahh.PurchaseAmount = (string)ren.purchaseAmountText.simpleText;

            return(ahh);
        }