-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoimg.js
39 lines (34 loc) · 1.04 KB
/
toimg.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const { spawn } = require('child_process')
const util = require('util')
const { MessageType } = require('@adiwajshing/baileys')
let handler = async (m, { conn }) => {
if (!m.quoted) return conn.reply(m.chat, 'Tag stikernya!', m)
let q = { message: { [m.quoted.mtype]: m.quoted }}
if (/sticker/.test(m.quoted.mtype)) {
let sticker = await conn.downloadM(q)
if (!sticker) throw sticker
let bufs = []
let im = spawn('convert', ['webp:-', 'jpeg:-'])
im.on('error',e => conn.reply(m.chat, util.format(e), m))
im.stdout.on('data', chunk => bufs.push(chunk))
im.stdin.write(sticker)
im.stdin.end()
im.on('exit', () => {
conn.sendMessage(m.chat, Buffer.concat(bufs), MessageType.image, {
quoted: m
})
})
}
}
handler.help = ['toimg (reply)']
handler.tags = ['sticker']
handler.command = /^toimg$/i
handler.owner = false
handler.mods = false
handler.premium = false
handler.group = false
handler.private = false
handler.admin = false
handler.botAdmin = false
handler.fail = null
module.exports = handler