From 7156a585c036a5000d0a50f3f4860a462762fdfe Mon Sep 17 00:00:00 2001 From: jonz94 Date: Wed, 20 Nov 2024 04:06:29 +0800 Subject: [PATCH] feat(parser): add `LiveChatModeChangeMessage` node (#811) * feat(parser): add `LiveChatModeChangeMessage` node * chore: npm run build:parser-map * refactor: keep `timestamp_text` as Text Co-authored-by: absidue <48293849+absidue@users.noreply.github.com> * refactor: keep `timestamp_text` as Text --------- Co-authored-by: absidue <48293849+absidue@users.noreply.github.com> --- .../items/LiveChatModeChangeMessage.ts | 26 +++++++++++++++++++ src/parser/nodes.ts | 1 + 2 files changed, 27 insertions(+) create mode 100644 src/parser/classes/livechat/items/LiveChatModeChangeMessage.ts diff --git a/src/parser/classes/livechat/items/LiveChatModeChangeMessage.ts b/src/parser/classes/livechat/items/LiveChatModeChangeMessage.ts new file mode 100644 index 00000000..abe3985c --- /dev/null +++ b/src/parser/classes/livechat/items/LiveChatModeChangeMessage.ts @@ -0,0 +1,26 @@ +import { YTNode } from '../../../helpers.js'; +import type { RawNode } from '../../../index.js'; +import Text from '../../misc/Text.js'; + +export default class LiveChatModeChangeMessage extends YTNode { + static type = 'LiveChatModeChangeMessage'; + + id: string; + icon_type: string; + text: Text; + subtext: Text; + timestamp: number; + timestamp_usec: string; + timestamp_text: Text; + + constructor(data: RawNode) { + super(); + this.id = data.id; + this.icon_type = data.icon.iconType; + this.text = new Text(data.text); + this.subtext = new Text(data.subtext); + this.timestamp = Math.floor(parseInt(data.timestampUsec) / 1000); + this.timestamp_usec = data.timestampUsec; + this.timestamp_text = new Text(data.timestampText); + } +} diff --git a/src/parser/nodes.ts b/src/parser/nodes.ts index 08636da2..99a5a5c5 100644 --- a/src/parser/nodes.ts +++ b/src/parser/nodes.ts @@ -187,6 +187,7 @@ export { default as LiveChatBannerHeader } from './classes/livechat/items/LiveCh export { default as LiveChatBannerPoll } from './classes/livechat/items/LiveChatBannerPoll.js'; export { default as LiveChatBannerRedirect } from './classes/livechat/items/LiveChatBannerRedirect.js'; export { default as LiveChatMembershipItem } from './classes/livechat/items/LiveChatMembershipItem.js'; +export { default as LiveChatModeChangeMessage } from './classes/livechat/items/LiveChatModeChangeMessage.js'; export { default as LiveChatPaidMessage } from './classes/livechat/items/LiveChatPaidMessage.js'; export { default as LiveChatPaidSticker } from './classes/livechat/items/LiveChatPaidSticker.js'; export { default as LiveChatPlaceholderItem } from './classes/livechat/items/LiveChatPlaceholderItem.js';