mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-07-03 09:35:05 +00:00
feat(parser): Update LiveChatTextMessage (#864)
Update `LiveChatTextMessage` to extend `YTNode` rather than `LiveChatMessageBase` to better align with the latest data provided by Innertube. - Add `timestamp_usec` property - Add `timestamp_text` property - Add `context_menu_accessibility_label` property - Add `before_content_buttons` property
This commit is contained in:
@@ -2,35 +2,36 @@ import { type ObservedArray, YTNode } from '../../../helpers.js';
|
||||
import type { RawNode } from '../../../index.js';
|
||||
import { Parser } from '../../../index.js';
|
||||
import Button from '../../Button.js';
|
||||
import ButtonView from '../../ButtonView.js';
|
||||
import NavigationEndpoint from '../../NavigationEndpoint.js';
|
||||
import Author from '../../misc/Author.js';
|
||||
import Text from '../../misc/Text.js';
|
||||
|
||||
export class LiveChatMessageBase extends YTNode {
|
||||
static type = 'LiveChatMessageBase';
|
||||
export default class LiveChatTextMessage extends YTNode {
|
||||
static type = 'LiveChatTextMessage';
|
||||
|
||||
id: string;
|
||||
message: Text;
|
||||
inline_action_buttons: ObservedArray<Button>;
|
||||
timestamp: number;
|
||||
id: string;
|
||||
timestamp_usec: number;
|
||||
timestamp_text?: string;
|
||||
author: Author;
|
||||
menu_endpoint: NavigationEndpoint;
|
||||
context_menu_accessibility_label: string;
|
||||
before_content_buttons: ObservedArray<ButtonView>;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.id = data.id;
|
||||
this.message = new Text(data.message);
|
||||
this.inline_action_buttons = Parser.parseArray(data.inlineActionButtons, Button);
|
||||
this.timestamp = Math.floor(parseInt(data.timestampUsec) / 1000);
|
||||
this.id = data.id;
|
||||
}
|
||||
}
|
||||
this.timestamp_usec = data.timestampUsec;
|
||||
|
||||
export default class LiveChatTextMessage extends LiveChatMessageBase {
|
||||
static type = 'LiveChatTextMessage';
|
||||
|
||||
author: Author;
|
||||
menu_endpoint: NavigationEndpoint;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super(data);
|
||||
if (Reflect.has(data, 'timestampText')) {
|
||||
this.timestamp_text = new Text(data.timestampText).toString();
|
||||
}
|
||||
|
||||
this.author = new Author(
|
||||
data.authorName,
|
||||
@@ -40,5 +41,7 @@ export default class LiveChatTextMessage extends LiveChatMessageBase {
|
||||
);
|
||||
|
||||
this.menu_endpoint = new NavigationEndpoint(data.contextMenuEndpoint);
|
||||
this.context_menu_accessibility_label = data.contextMenuAccessibility.accessibilityData.label;
|
||||
this.before_content_buttons = Parser.parseArray(data.beforeContentButtons, ButtonView);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user