@@ -35,6 +35,8 @@ internal class YouTubeLiveMembership : MessageBase2, IYouTubeLiveMembership
35
35
public string Id { get ; set ; }
36
36
public IEnumerable < IMessagePart > NameItems { get ; set ; }
37
37
public IEnumerable < IMessagePart > CommentItems { get ; set ; }
38
+ public IEnumerable < IMessagePart > HeaderPrimaryTextItems { get ; set ; }
39
+ public IEnumerable < IMessagePart > HeaderSubTextItems { get ; set ; }
38
40
//public string UserName { get; set; }
39
41
public string UserId { get ; set ; }
40
42
public DateTime PostedAt { get ; set ; }
@@ -53,19 +55,15 @@ internal class YouTubeLiveMembership : MessageBase2, IYouTubeLiveMembership
53
55
// };
54
56
// PostedAt = SitePluginCommon.Utils.UnixtimeToDateTime(comment.TimestampUsec / (1000 * 1000));
55
57
//}
56
- public YouTubeLiveMembership ( MemberShip member ) : base ( "" )
58
+ public YouTubeLiveMembership ( MemberShip text ) : base ( "" )
57
59
{
58
- //UserId = member.UserId;
59
- //Id = member.Id;
60
- //CommentItems = member.MessageItems;
61
- //NameItems = member.NameItems;
62
- //UserIcon = new Common.MessageImage
63
- //{
64
- // Height = member.ThumbnailHeight,
65
- // Width = member.ThumbnailWidth,
66
- // Url = member.ThumbnailUrl,
67
- //};
68
- //PostedAt = SitePluginCommon.Utils.UnixtimeToDateTime(member.TimestampUsec / (1000 * 1000));
60
+ UserId = text . AuthorExternalChannelId ;
61
+ Id = text . Id ;
62
+ CommentItems = MessageBase . Convert ( text . MessageItems ) ;
63
+ NameItems = MessageBase . Convert ( text . AuthorName , text . AuthorBadges ) ;
64
+ UserIcon = MessageBase . Convert ( text . AuthorPhoto ) ;
65
+ PostedAt = MessageBase . Convert ( text . TimestampUsec ) ;
66
+
69
67
}
70
68
}
71
69
internal class YouTubeLiveSuperchat : MessageBase2 , IYouTubeLiveSuperchat
@@ -83,26 +81,12 @@ internal class YouTubeLiveSuperchat : MessageBase2, IYouTubeLiveSuperchat
83
81
84
82
public YouTubeLiveSuperchat ( SuperChat text ) : base ( "" )
85
83
{
86
- UserId = text . AuthorExternalChannelId ; //.UserId;
84
+ UserId = text . AuthorExternalChannelId ;
87
85
Id = text . Id ;
88
- CommentItems = text . MessageItems . Select ( a => MessageConverter . Parse ( a ) ) . ToList ( ) ;
89
- var nameItems = new List < IMessagePart > ( ) ;
90
- if ( text . AuthorName != null )
91
- {
92
- nameItems . Add ( Common . MessagePartFactory . CreateMessageText ( text . AuthorName ) ) ;
93
- }
94
- foreach ( var badge in text . AuthorBadges )
95
- {
96
-
97
- }
98
- NameItems = nameItems ;
99
- UserIcon = new Common . MessageImage
100
- {
101
- Height = text . AuthorPhoto . Height ,
102
- Width = text . AuthorPhoto . Width ,
103
- Url = text . AuthorPhoto . Url ,
104
- } ;
105
- PostedAt = SitePluginCommon . Utils . UnixtimeToDateTime ( text . TimestampUsec / ( 1000 * 1000 ) ) ;
86
+ CommentItems = MessageBase . Convert ( text . MessageItems ) ;
87
+ NameItems = MessageBase . Convert ( text . AuthorName , text . AuthorBadges ) ;
88
+ UserIcon = MessageBase . Convert ( text . AuthorPhoto ) ;
89
+ PostedAt = MessageBase . Convert ( text . TimestampUsec ) ;
106
90
PurchaseAmount = text . PurchaseAmount ;
107
91
}
108
92
}
@@ -121,32 +105,51 @@ internal class YouTubeLiveComment : MessageBase2, IYouTubeLiveComment
121
105
122
106
public YouTubeLiveComment ( TextMessage text ) : base ( "" )
123
107
{
124
- UserId = text . AuthorExternalChannelId ; //.UserId;
108
+ UserId = text . AuthorExternalChannelId ;
125
109
Id = text . Id ;
126
- CommentItems = text . MessageItems . Select ( a => MessageConverter . Parse ( a ) ) . ToList ( ) ;
110
+ CommentItems = MessageBase . Convert ( text . MessageItems ) ;
111
+ NameItems = MessageBase . Convert ( text . AuthorName , text . AuthorBadges ) ;
112
+ UserIcon = MessageBase . Convert ( text . AuthorPhoto ) ;
113
+ PostedAt = MessageBase . Convert ( text . TimestampUsec ) ;
114
+ }
115
+
116
+ }
117
+ static class MessageBase
118
+ {
119
+ public static DateTime Convert ( long timestampUsec )
120
+ {
121
+ return SitePluginCommon . Utils . UnixtimeToDateTime ( timestampUsec / ( 1000 * 1000 ) ) ;
122
+ }
123
+ public static IMessageImage Convert ( Thumbnail2 authorPhoto )
124
+ {
125
+ return new Common . MessageImage
126
+ {
127
+ Height = authorPhoto . Height ,
128
+ Width = authorPhoto . Width ,
129
+ Url = authorPhoto . Url ,
130
+ } ;
131
+ }
132
+ public static IEnumerable < IMessagePart > Convert ( IReadOnlyList < ryu_s . YouTubeLive . Message . IMessagePart > items )
133
+ {
134
+ return items . Select ( a => MessageConverter . Parse ( a ) ) . ToList ( ) ;
135
+ }
136
+ public static IEnumerable < IMessagePart > Convert ( string ? authorName , List < IAuthorBadge > authorBadges )
137
+ {
127
138
var nameItems = new List < IMessagePart > ( ) ;
128
- if ( text . AuthorName != null )
139
+ if ( authorName != null )
129
140
{
130
- nameItems . Add ( Common . MessagePartFactory . CreateMessageText ( text . AuthorName ) ) ;
141
+ nameItems . Add ( Common . MessagePartFactory . CreateMessageText ( authorName ) ) ;
131
142
}
132
143
var badges = new List < IMessagePart > ( ) ;
133
- foreach ( var badge in text . AuthorBadges )
144
+ foreach ( var badge in authorBadges )
134
145
{
135
146
var parsed = MessageConverter . Parse ( badge ) ;
136
147
if ( parsed == null ) continue ;
137
148
badges . Add ( parsed ) ;
138
149
}
139
150
nameItems . AddRange ( badges ) ;
140
- NameItems = nameItems ;
141
- UserIcon = new Common . MessageImage
142
- {
143
- Height = text . AuthorPhoto . Height ,
144
- Width = text . AuthorPhoto . Width ,
145
- Url = text . AuthorPhoto . Url ,
146
- } ;
147
- PostedAt = SitePluginCommon . Utils . UnixtimeToDateTime ( text . TimestampUsec / ( 1000 * 1000 ) ) ;
151
+ return nameItems ;
148
152
}
149
-
150
153
}
151
154
static class MessageConverter
152
155
{
0 commit comments