Skip to content

Commit

Permalink
fixed bug with stickers
Browse files Browse the repository at this point in the history
  • Loading branch information
adiwajshing committed Aug 31, 2020
1 parent cadd34b commit 420c707
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Example/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async function example() {
console.log(`${sender} sent live location for duration: ${m.duration/60}`)
}
} else {
// if it is a media (audio, image, video) message
// if it is a media (audio, image, video, sticker) message
// decode, decrypt & save the media.
// The extension to the is applied automatically based on the media type
try {
Expand Down Expand Up @@ -112,7 +112,7 @@ async function example() {
type = MessageType.video
}
const response = await conn.sendMessage(m.key.remoteJid, content, type, options)
console.log("sent message with ID '" + response.key.id + "' successfully: " + (response.status === 200))
console.log("sent message with ID '" + response.key.id + "' successfully")
}, 3 * 1000)
})

Expand Down
Binary file added Media/octopus.webp
Binary file not shown.
7 changes: 7 additions & 0 deletions src/Tests/Tests.Messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ WAConnectionTest('Messages', conn => {
await conn.downloadMediaMessage(message)
//const message2 = await sendAndRetreiveMessage (conn, 'this is a quote', MessageType.extendedText)
})
it('should send a sticker', async () => {
const content = await fs.readFile('./Media/octopus.webp')
const message = await sendAndRetreiveMessage(conn, content, MessageType.sticker)

await conn.downloadMediaMessage(message)
//const message2 = await sendAndRetreiveMessage (conn, 'this is a quote', MessageType.extendedText)
})
it('should send an image & quote', async () => {
const {messages} = await conn.loadMessages(testJid, 1)
const content = await fs.readFile('./Media/meme.jpeg')
Expand Down
2 changes: 1 addition & 1 deletion src/WAConnection/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export async function generateThumbnail(buffer: Buffer, mediaType: MessageType,
if (mediaType === MessageType.audio) {
throw new Error('audio messages cannot have thumbnails')
}
} else if (mediaType === MessageType.image || mediaType === MessageType.sticker) {
} else if (mediaType === MessageType.image) {
const buff = await compressImage (buffer)
info.thumbnail = buff.toString('base64')
} else if (mediaType === MessageType.video) {
Expand Down

0 comments on commit 420c707

Please sign in to comment.