diff --git a/package.json b/package.json index f8e0e1b04..931a9a88e 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "contributors": [ "Wykerd (https://github.com/wykerd/)", "MasterOfBob777 (https://github.com/MasterOfBob777)", - "patrickkfkan (https://github.com/patrickkfkan)" + "patrickkfkan (https://github.com/patrickkfkan)", + "akkadaska (https://github.com/akkadaska)" ], "directories": { "test": "./test", diff --git a/src/core/Actions.ts b/src/core/Actions.ts index 025ecb52b..11fcd2263 100644 --- a/src/core/Actions.ts +++ b/src/core/Actions.ts @@ -455,8 +455,7 @@ class Actions { }; break; case 'live_chat/get_item_context_menu': - // Note: this is currently broken due to a recent refactor - // TODO: this should be implemented + data.params = args.params; break; case 'live_chat/moderate': data.params = args.params; diff --git a/src/parser/classes/NavigationEndpoint.ts b/src/parser/classes/NavigationEndpoint.ts index 0fbea7c5a..a9635de7d 100644 --- a/src/parser/classes/NavigationEndpoint.ts +++ b/src/parser/classes/NavigationEndpoint.ts @@ -230,12 +230,6 @@ class NavigationEndpoint extends YTNode { params: data.sendLiveChatVoteEndpoint.params }; } - - if (data?.liveChatItemContextMenuEndpoint) { - this.live_chat_item_context_menu = { - params: data.liveChatItemContextMenuEndpoint.params - }; - } } /** @@ -249,6 +243,8 @@ class NavigationEndpoint extends YTNode { return '/player'; case 'watchPlaylistEndpoint': return '/next'; + case 'liveChatItemContextMenuEndpoint': + return 'live_chat/get_item_context_menu'; } } @@ -297,6 +293,15 @@ class NavigationEndpoint extends YTNode { const response = await actions.engage(this.metadata.api_url, { video_id: this.like.target.video_id, params: this.like.params }); return response; } + + if (this.live_chat_item_context_menu) { + if (!this.metadata.api_url) + throw new Error('Live Chat Item Context Menu endpoint requires an api_url, but was not parsed from the response.'); + const response = await actions.livechat(this.metadata.api_url, { + params: this.live_chat_item_context_menu.params + }); + return response; + } } async call(actions: Actions, client: string | undefined, parse: true) : Promise; @@ -307,7 +312,7 @@ class NavigationEndpoint extends YTNode { if (parse && result) return Parser.parseResponse(result.data); - return this.#call(actions, client); + return result; } } diff --git a/src/parser/classes/livechat/items/LiveChatAutoModMessage.ts b/src/parser/classes/livechat/items/LiveChatAutoModMessage.ts index 8518cff32..0861b8912 100644 --- a/src/parser/classes/livechat/items/LiveChatAutoModMessage.ts +++ b/src/parser/classes/livechat/items/LiveChatAutoModMessage.ts @@ -1,6 +1,8 @@ import Text from '../../misc/Text'; import Parser from '../../../index'; -import { YTNode } from '../../../helpers'; +import { ObservedArray, YTNode } from '../../../helpers'; +import NavigationEndpoint from '../../NavigationEndpoint'; +import Button from '../../Button'; class LiveChatAutoModMessage extends YTNode { static type = 'LiveChatAutoModMessage'; @@ -8,12 +10,16 @@ class LiveChatAutoModMessage extends YTNode { auto_moderated_item; header_text: Text; + menu_endpoint?: NavigationEndpoint; + moderation_buttons: ObservedArray