Skip to content

Commit faa44a8

Browse files
committed
support sticker payload
1 parent 4d74e26 commit faa44a8

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

src/services/transformer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ export const toBaileysMessageContent = (payload: any, customMessageCharactersFun
464464
case 'audio':
465465
case 'document':
466466
case 'video':
467+
case 'sticker':
467468
const link = payload[type].link
468469
if (link) {
469470
let mimetype: string = getMimetype(payload)

src/utils/sticker_convert.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import sharp from 'sharp'
2+
3+
type StickerConvertOptions = {
4+
animated?: boolean
5+
}
6+
7+
export const MAX_STICKER_BYTES = 8 * 1024 * 1024
8+
9+
export const convertToWebpSticker = async (input: Buffer, opts: StickerConvertOptions = {}) => {
10+
const image = sharp(input, { animated: !!opts.animated })
11+
return image
12+
.resize(512, 512, { fit: 'inside', withoutEnlargement: true })
13+
.webp({ lossless: !opts.animated, quality: 80, effort: 4 })
14+
.toBuffer()
15+
}

0 commit comments

Comments
 (0)