mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-26 16:18:51 +00:00
feat(parser): Update LiveChatViewerEngagementMessage (#856)
Update `LiveChatViewerEngagementMessage` to extend `YTNode` rather than `LiveChatMessageBase` to better align with the latest data provided by Innertube.
This commit is contained in:
@@ -1,19 +1,47 @@
|
||||
import { Parser } from '../../../index.js';
|
||||
import { LiveChatMessageBase } from './LiveChatTextMessage.js';
|
||||
import type { RawNode } from '../../../index.js';
|
||||
import type { YTNode } from '../../../helpers.js';
|
||||
import { YTNode } from '../../../helpers.js';
|
||||
import NavigationEndpoint from '../../NavigationEndpoint.js';
|
||||
import Text from '../../misc/Text.js';
|
||||
|
||||
export default class LiveChatViewerEngagementMessage extends LiveChatMessageBase {
|
||||
export default class LiveChatViewerEngagementMessage extends YTNode {
|
||||
static type = 'LiveChatViewerEngagementMessage';
|
||||
|
||||
id: string;
|
||||
timestamp?: number;
|
||||
timestamp_usec?: string;
|
||||
icon_type?: string;
|
||||
action_button: YTNode;
|
||||
message: Text;
|
||||
action_button: YTNode | null;
|
||||
menu_endpoint?: NavigationEndpoint;
|
||||
context_menu_accessibility_label?: string;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super(data);
|
||||
super();
|
||||
this.id = data.id;
|
||||
|
||||
if (Reflect.has(data, 'timestampUsec')) {
|
||||
this.timestamp = Math.floor(parseInt(data.timestampUsec) / 1000);
|
||||
this.timestamp_usec = data.timestampUsec;
|
||||
}
|
||||
|
||||
if (Reflect.has(data, 'icon') && Reflect.has(data.icon, 'iconType')) {
|
||||
this.icon_type = data.icon.iconType;
|
||||
}
|
||||
|
||||
this.message = new Text(data.message);
|
||||
this.action_button = Parser.parseItem(data.actionButton);
|
||||
|
||||
if (Reflect.has(data, 'contextMenuEndpoint')) {
|
||||
this.menu_endpoint = new NavigationEndpoint(data.contextMenuEndpoint);
|
||||
}
|
||||
|
||||
if (
|
||||
Reflect.has(data, 'contextMenuAccessibility') &&
|
||||
Reflect.has(data.contextMenuAccessibility, 'accessibilityData') &&
|
||||
Reflect.has(data.contextMenuAccessibility.accessibilityData, 'label')
|
||||
) {
|
||||
this.context_menu_accessibility_label = data.contextMenuAccessibility.accessibilityData.label;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user