mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Added method to send list message (#574)
* Added method to send list message * Added method to send list message
This commit is contained in:
@@ -35,6 +35,34 @@ export class WAConnection extends Base {
|
|||||||
await this.relayWAMessage (waMessage, { waitForAck: options.waitForAck !== false })
|
await this.relayWAMessage (waMessage, { waitForAck: options.waitForAck !== false })
|
||||||
return waMessage
|
return waMessage
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Send a list message
|
||||||
|
* @param id the id to send to
|
||||||
|
* @param button the optional button text, title and description button
|
||||||
|
* @param rows the rows of sections list message
|
||||||
|
*/
|
||||||
|
async sendListMessage(
|
||||||
|
id: string,
|
||||||
|
button: { buttonText?: string; description?: string; title?: string },
|
||||||
|
rows: any = [],
|
||||||
|
) {
|
||||||
|
let messageList = WAMessageProto.Message.fromObject({
|
||||||
|
listMessage: WAMessageProto.ListMessage.fromObject({
|
||||||
|
buttonText: button.buttonText,
|
||||||
|
description: button.description,
|
||||||
|
listType: 1,
|
||||||
|
sections: [
|
||||||
|
{
|
||||||
|
title: button.title,
|
||||||
|
rows: [ ...rows ]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
})
|
||||||
|
let waMessageList = await this.prepareMessageFromContent(id, messageList, {})
|
||||||
|
await this.relayWAMessage (waMessageList, { waitForAck: true })
|
||||||
|
return waMessageList
|
||||||
|
}
|
||||||
/** Prepares a message for sending via sendWAMessage () */
|
/** Prepares a message for sending via sendWAMessage () */
|
||||||
async prepareMessage(
|
async prepareMessage(
|
||||||
id: string,
|
id: string,
|
||||||
|
|||||||
Reference in New Issue
Block a user