From 29e8d3015a3d17383a8be4e6f46b389d10f111f3 Mon Sep 17 00:00:00 2001 From: jonz94 Date: Sun, 15 Dec 2024 12:04:05 +0800 Subject: [PATCH] feat(parser): Update `LiveChatTickerPaidMessageItem` (#845) * Change `duration_sec` property type from `string` to `number` * Change `full_duration_sec` property type from `string` to `number` * Handle the scenario where the author's name is represented as `authUsername` * Mark `amount` property as optional * Add `start_background_color` property * Add `amount_text_color` property * Add `end_background_color` property * Add `animation_origin` property * Add `open_engagement_panel_command` property --- .../items/LiveChatTickerPaidMessageItem.ts | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/parser/classes/livechat/items/LiveChatTickerPaidMessageItem.ts b/src/parser/classes/livechat/items/LiveChatTickerPaidMessageItem.ts index 3d588a86..08ca94e9 100644 --- a/src/parser/classes/livechat/items/LiveChatTickerPaidMessageItem.ts +++ b/src/parser/classes/livechat/items/LiveChatTickerPaidMessageItem.ts @@ -9,28 +9,42 @@ import type { RawNode } from '../../../index.js'; export default class LiveChatTickerPaidMessageItem extends YTNode { static type = 'LiveChatTickerPaidMessageItem'; + id: string; author: Author; - amount: Text; - duration_sec: string; - full_duration_sec: string; + amount?: Text; + amount_text_color: number; + start_background_color: number; + end_background_color: number; + duration_sec: number; + full_duration_sec: number; show_item: YTNode; show_item_endpoint: NavigationEndpoint; - id: string; + animation_origin: string; + open_engagement_panel_command: NavigationEndpoint; constructor(data: RawNode) { super(); + this.id = data.id; + this.author = new Author( - data.authorName, + data.authorName || data.authorUsername, data.authorBadges, data.authorPhoto, data.authorExternalChannelId ); - this.amount = new Text(data.amount); + if (Reflect.has(data, 'amount')) { + this.amount = new Text(data.amount); + } + + this.amount_text_color = data.amountTextColor; + this.start_background_color = data.startBackgroundColor; + this.end_background_color = data.endBackgroundColor; this.duration_sec = data.durationSec; this.full_duration_sec = data.fullDurationSec; this.show_item = Parser.parseItem(data.showItemEndpoint?.showLiveChatItemEndpoint?.renderer); this.show_item_endpoint = new NavigationEndpoint(data.showItemEndpoint); - this.id = data.id; + this.animation_origin = data.animationOrigin; + this.open_engagement_panel_command = new NavigationEndpoint(data.openEngagementPanelCommand); } } \ No newline at end of file