mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
added support for sending viewOnceMessage and updated README (#596)
* add support to send viewOnceMessage * Update README.md * add support send viewOnceMessage and update README * remove something irrelevant from PR Co-authored-by: LoL-Human <>
This commit is contained in:
@@ -242,7 +242,8 @@ const sections = [{title: "Section 1", rows: rows}]
|
||||
const button = {
|
||||
buttonText: 'Click Me!',
|
||||
description: "Hello it's list message",
|
||||
sections: sections
|
||||
sections: sections,
|
||||
listType: 1
|
||||
}
|
||||
|
||||
const sendMsg = await conn.sendMessage(id, button, MessageType.listMessage)
|
||||
|
||||
@@ -178,6 +178,9 @@ export class WAConnection extends Base {
|
||||
if (mediaType === MessageType.sticker && options.caption) {
|
||||
throw new Error('cannot send a caption with a sticker')
|
||||
}
|
||||
if (!(mediaType === MessageType.image || mediaType === MessageType.video) && options.viewOnce) {
|
||||
throw new Error(`cannot send a ${mediaType} as a viewOnceMessage`)
|
||||
}
|
||||
if (!options.mimetype) {
|
||||
options.mimetype = MimetypeMap[mediaType]
|
||||
}
|
||||
@@ -267,7 +270,8 @@ export class WAConnection extends Base {
|
||||
fileName: options.filename || 'file',
|
||||
gifPlayback: isGIF || undefined,
|
||||
caption: options.caption,
|
||||
ptt: options.ptt
|
||||
ptt: options.ptt,
|
||||
viewOnce: options.viewOnce
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -277,6 +281,7 @@ export class WAConnection extends Base {
|
||||
prepareMessageFromContent(id: string, message: WAMessageContent, options: MessageOptions) {
|
||||
if (!options.timestamp) options.timestamp = new Date() // set timestamp to now
|
||||
if (typeof options.sendEphemeral === 'undefined') options.sendEphemeral = 'chat'
|
||||
if (options.viewOnce) message = { viewOnceMessage: { message } }
|
||||
// prevent an annoying bug (WA doesn't accept sending messages with '@c.us')
|
||||
id = whatsappID (id)
|
||||
|
||||
|
||||
@@ -402,6 +402,8 @@ export interface MessageOptions {
|
||||
filename?: string
|
||||
/** For audio messages, if set to true, will send as a `voice note` */
|
||||
ptt?: boolean
|
||||
/** For image or video messages, if set to true, will send as a `viewOnceMessage` */
|
||||
viewOnce?: boolean
|
||||
/** Optional agent for media uploads */
|
||||
uploadAgent?: Agent
|
||||
/** If set to true (default), automatically detects if you're sending a link & attaches the preview*/
|
||||
|
||||
Reference in New Issue
Block a user