mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-19 04:21:35 +00:00
feat(parser): Update LiveChatPaidMessage (#846)
* Add `author_name_text_color` property * Add `context_menu_accessibility_label` property * Add `timestamp_usec` property * Mark `timestamp_text` property as optional * Add `timestamp_color` property * Add `text_input_background_color` property * Add `creator_heart_button` property * Add `is_v2_style` property * Add `reply_button` property
This commit is contained in:
40
src/parser/classes/livechat/items/CreatorHeartView.ts
Normal file
40
src/parser/classes/livechat/items/CreatorHeartView.ts
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
19
src/parser/classes/livechat/items/PdgReplyButtonView.ts
Normal file
19
src/parser/classes/livechat/items/PdgReplyButtonView.ts
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user