fix(sendMessage): Handle RunAttestationCommand in response actions (#859)

* fix(sendMessage): Handle `RunAttestationCommand` in response actions

Handle the case when `RunAttestationCommand` is included in the
`sendMessage()` response actions.

* style: trim trailing whitespace
This commit is contained in:
jonz94
2024-12-27 13:41:30 +08:00
committed by GitHub
parent 913dcc74ea
commit 826a9541a4

View File

@@ -5,6 +5,7 @@ import { InnertubeError, Platform, u8ToBase64 } from '../../utils/Utils.js';
import { LiveChatContinuation, Parser } from '../index.js';
import SmoothedQueue from './SmoothedQueue.js';
import RunAttestationCommand from '../classes/commands/RunAttestationCommand.js';
import AddChatItemAction from '../classes/livechat/AddChatItemAction.js';
import UpdateDateTextAction from '../classes/livechat/UpdateDateTextAction.js';
import UpdateDescriptionAction from '../classes/livechat/UpdateDescriptionAction.js';
@@ -251,7 +252,7 @@ export default class LiveChat extends EventEmitter {
* Sends a message.
* @param text - Text to send.
*/
async sendMessage(text: string): Promise<ObservedArray<AddChatItemAction>> {
async sendMessage(text: string): Promise<ObservedArray<AddChatItemAction | RunAttestationCommand>> {
const writer = LiveMessageParams.encode({
params: {
ids: {
@@ -259,7 +260,7 @@ export default class LiveChat extends EventEmitter {
channelId: this.#channel_id
}
},
number0: 1,
number0: 1,
number1: 4
});
@@ -276,7 +277,7 @@ export default class LiveChat extends EventEmitter {
if (!response.actions)
throw new InnertubeError('Unexpected response from send_message', response);
return response.actions.array().as(AddChatItemAction);
return response.actions.array().as(AddChatItemAction, RunAttestationCommand);
}
/**