mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
audio tests
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 56 KiB |
BIN
Media/sonata.mp3
Normal file
BIN
Media/sonata.mp3
Normal file
Binary file not shown.
@@ -186,6 +186,10 @@ conn.sendMessage(id, {displayname: "Jeff", vcard: vcard}, MessageType.contact)
|
||||
const buffer = fs.readFileSync("Media/ma_gif.mp4") // load some gif
|
||||
const options: MessageOptions = {mimetype: Mimetype.gif, caption: "hello!"} // some metadata & caption
|
||||
conn.sendMessage(id, buffer, MessageType.video, options)
|
||||
// send an audio file
|
||||
const buffer = fs.readFileSync("Media/audio.mp3") // can send mp3, mp4, & ogg -- but for mp3 files the mimetype must be set to ogg
|
||||
const options: MessageOptions = {mimetype: Mimetype.ogg} // some metadata (can't have caption in audio)
|
||||
conn.sendMessage(id, buffer, MessageType.audio, options)
|
||||
```
|
||||
|
||||
To note:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { MessageType, Mimetype, delay, promiseTimeout, WAMessage, WA_MESSAGE_STATUS_TYPE, WAMessageStatusUpdate, MessageLogLevel } from '../WAConnection/WAConnection'
|
||||
import { MessageType, Mimetype, delay, promiseTimeout, WA_MESSAGE_STATUS_TYPE, WAMessageStatusUpdate } from '../WAConnection/WAConnection'
|
||||
import {promises as fs} from 'fs'
|
||||
import * as assert from 'assert'
|
||||
import { WAConnectionTest, testJid, sendAndRetreiveMessage } from './Common'
|
||||
@@ -44,6 +44,12 @@ WAConnectionTest('Messages', conn => {
|
||||
|
||||
await conn.downloadAndSaveMediaMessage(message,'./Media/received_vid')
|
||||
})
|
||||
it('should send an audio', async () => {
|
||||
const content = await fs.readFile('./Media/sonata.mp3')
|
||||
const message = await sendAndRetreiveMessage(conn, content, MessageType.audio, { mimetype: Mimetype.ogg })
|
||||
|
||||
await conn.downloadAndSaveMediaMessage(message,'./Media/received_aud')
|
||||
})
|
||||
it('should send an image', async () => {
|
||||
const content = await fs.readFile('./Media/meme.jpeg')
|
||||
const message = await sendAndRetreiveMessage(conn, content, MessageType.image)
|
||||
|
||||
@@ -150,7 +150,7 @@ export class WAConnection extends Base {
|
||||
if (options.contextInfo) message[key].contextInfo = options.contextInfo
|
||||
|
||||
if (quoted) {
|
||||
const participant = quoted.key.fromMe ? this.user.jid : (quoted.key.participant || quoted.key.remoteJid)
|
||||
const participant = quoted.key.fromMe ? this.user.jid : (quoted.participant || quoted.key.participant || quoted.key.remoteJid)
|
||||
|
||||
message[key].contextInfo = message[key].contextInfo || { }
|
||||
message[key].contextInfo.participant = participant
|
||||
|
||||
@@ -265,6 +265,7 @@ export enum Mimetype {
|
||||
gif = 'video/gif',
|
||||
pdf = 'application/pdf',
|
||||
ogg = 'audio/ogg; codecs=opus',
|
||||
mp4Audio = 'audio/mp4',
|
||||
/** for stickers */
|
||||
webp = 'image/webp',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user