diff --git a/src/parser/classes/livechat/items/CreatorHeartView.ts b/src/parser/classes/livechat/items/CreatorHeartView.ts new file mode 100644 index 000000000..7a4342c9a --- /dev/null +++ b/src/parser/classes/livechat/items/CreatorHeartView.ts @@ -0,0 +1,40 @@ +import { YTNode } from '../../../helpers.js'; +import type { RawNode } from '../../../index.js'; +import Thumbnail from '../../misc/Thumbnail.js'; + +export default class CreatorHeartView extends YTNode { + static type = 'CreatorHeartView'; + + creator_thumbnail: Thumbnail[]; + hearted_icon_name: string; + unhearted_icon_name: string; + unhearted_icon_processor: { + border_image_processor: { + image_tint: { + color: number + } + } + }; + hearted_hover_text: string; + hearted_accessibility_label: string; + unhearted_accessibility_label: string; + engagement_state_key: string; + + constructor(data: RawNode) { + super(); + this.creator_thumbnail = Thumbnail.fromResponse(data.creatorThumbnail); + this.hearted_icon_name = data.heartedIcon.sources[0].clientResource.imageName; + this.unhearted_icon_name = data.unheartedIcon.sources[0].clientResource.imageName; + this.unhearted_icon_processor = { + border_image_processor: { + image_tint: { + color: data.unheartedIcon.processor.borderImageProcessor.imageTint.color + } + } + }; + this.hearted_hover_text = data.heartedHoverText; + this.hearted_accessibility_label = data.heartedAccessibilityLabel; + this.unhearted_accessibility_label = data.unheartedAccessibilityLabel; + this.engagement_state_key = data.engagementStateKey; + } +} \ No newline at end of file diff --git a/src/parser/classes/livechat/items/LiveChatPaidMessage.ts b/src/parser/classes/livechat/items/LiveChatPaidMessage.ts index f5729a951..37be364e8 100644 --- a/src/parser/classes/livechat/items/LiveChatPaidMessage.ts +++ b/src/parser/classes/livechat/items/LiveChatPaidMessage.ts @@ -1,26 +1,37 @@ import { YTNode } from '../../../helpers.js'; -import type { RawNode } from '../../../index.js'; +import { Parser, type RawNode } from '../../../index.js'; import NavigationEndpoint from '../../NavigationEndpoint.js'; import Author from '../../misc/Author.js'; import Text from '../../misc/Text.js'; +import CreatorHeartView from './CreatorHeartView.js'; +import PdgReplyButtonView from './PdgReplyButtonView.js'; export default class LiveChatPaidMessage extends YTNode { static type = 'LiveChatPaidMessage'; + id: string; message: Text; author: Author; + author_name_text_color: number; header_background_color: number; header_text_color: number; body_background_color: number; body_text_color: number; purchase_amount: string; menu_endpoint: NavigationEndpoint; + context_menu_accessibility_label: string; timestamp: number; - timestamp_text: string; - id: string; + timestamp_usec: string; + timestamp_text?: string; + timestamp_color: number; + text_input_background_color: number; + creator_heart_button: CreatorHeartView | null; + is_v2_style: boolean; + reply_button: PdgReplyButtonView | null; constructor(data: RawNode) { super(); + this.id = data.id; this.message = new Text(data.message); this.author = new Author( @@ -30,14 +41,25 @@ export default class LiveChatPaidMessage extends YTNode { data.authorExternalChannelId ); + this.author_name_text_color = data.authorNameTextColor; this.header_background_color = data.headerBackgroundColor; this.header_text_color = data.headerTextColor; this.body_background_color = data.bodyBackgroundColor; this.body_text_color = data.bodyTextColor; this.purchase_amount = new Text(data.purchaseAmountText).toString(); this.menu_endpoint = new NavigationEndpoint(data.contextMenuEndpoint); + this.context_menu_accessibility_label = data.contextMenuAccessibility.accessibilityData.label; this.timestamp = Math.floor(parseInt(data.timestampUsec) / 1000); - this.timestamp_text = new Text(data.timestampText).toString(); - this.id = data.id; + this.timestamp_usec = data.timestampUsec; + + if (Reflect.has(data, 'timestampText')) { + this.timestamp_text = new Text(data.timestampText).toString(); + } + + this.timestamp_color = data.timestampColor; + this.text_input_background_color = data.textInputBackgroundColor; + this.creator_heart_button = Parser.parseItem(data.creatorHeartButton, CreatorHeartView); + this.is_v2_style = data.isV2Style; + this.reply_button = Parser.parseItem(data.replyButton, PdgReplyButtonView); } } \ No newline at end of file diff --git a/src/parser/classes/livechat/items/PdgReplyButtonView.ts b/src/parser/classes/livechat/items/PdgReplyButtonView.ts new file mode 100644 index 000000000..4af06339e --- /dev/null +++ b/src/parser/classes/livechat/items/PdgReplyButtonView.ts @@ -0,0 +1,19 @@ +import { YTNode } from '../../../helpers.js'; +import { Parser, type RawNode } from '../../../index.js'; +import ButtonView from '../../ButtonView.js'; +import Text from '../../misc/Text.js'; + +export default class PdgReplyButtonView extends YTNode { + static type = 'PdgReplyButtonView'; + + reply_button: ButtonView | null; + reply_count_entity_key: string; + reply_count_placeholder: Text; + + constructor(data: RawNode) { + super(); + this.reply_button = Parser.parseItem(data.replyButton, ButtonView); + this.reply_count_entity_key = data.replyCountEntityKey; + this.reply_count_placeholder = Text.fromAttributed(data.replyCountPlaceholder); + } +} \ No newline at end of file diff --git a/src/parser/nodes.ts b/src/parser/nodes.ts index 85cb66aa6..a827067bb 100644 --- a/src/parser/nodes.ts +++ b/src/parser/nodes.ts @@ -220,6 +220,7 @@ export { default as AddBannerToLiveChatCommand } from './classes/livechat/AddBan export { default as AddChatItemAction } from './classes/livechat/AddChatItemAction.js'; export { default as AddLiveChatTickerItemAction } from './classes/livechat/AddLiveChatTickerItemAction.js'; export { default as DimChatItemAction } from './classes/livechat/DimChatItemAction.js'; +export { default as CreatorHeartView } from './classes/livechat/items/CreatorHeartView.js'; export { default as LiveChatAutoModMessage } from './classes/livechat/items/LiveChatAutoModMessage.js'; export { default as LiveChatBanner } from './classes/livechat/items/LiveChatBanner.js'; export { default as LiveChatBannerChatSummary } from './classes/livechat/items/LiveChatBannerChatSummary.js'; @@ -241,6 +242,7 @@ export { default as LiveChatTickerPaidMessageItem } from './classes/livechat/ite export { default as LiveChatTickerPaidStickerItem } from './classes/livechat/items/LiveChatTickerPaidStickerItem.js'; export { default as LiveChatTickerSponsorItem } from './classes/livechat/items/LiveChatTickerSponsorItem.js'; export { default as LiveChatViewerEngagementMessage } from './classes/livechat/items/LiveChatViewerEngagementMessage.js'; +export { default as PdgReplyButtonView } from './classes/livechat/items/PdgReplyButtonView.js'; export { default as PollHeader } from './classes/livechat/items/PollHeader.js'; export { default as LiveChatActionPanel } from './classes/livechat/LiveChatActionPanel.js'; export { default as MarkChatItemAsDeletedAction } from './classes/livechat/MarkChatItemAsDeletedAction.js';