-
-
Notifications
You must be signed in to change notification settings - Fork 514
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Delete nodemon module * Update sticker.js
- Loading branch information
1 parent
e85b8a8
commit 0136fbf
Showing
5 changed files
with
43 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,44 @@ | ||
const { MessageType } = require('@adiwajshing/baileys') | ||
const { sticker } = require('../lib/sticker') | ||
let handler = async (m, { conn, args }) => { | ||
const uploadFile = require('../lib/uploadFile') | ||
const uploadImage = require('../lib/uploadImage') | ||
let { webp2png } = require('../lib/webp2mp4') | ||
let handler = async (m, { conn, args, usedPrefix, command }) => { | ||
let stiker = false | ||
try { | ||
let q = m.quoted ? m.quoted : m | ||
let mime = (q.msg || q).mimetype || '' | ||
if (/image|video/.test(mime)) { | ||
if (/webp|image|video/g.test(mime)) { | ||
if (/video/g.test(mime)) if ((q.msg || q).seconds > 11) return m.reply('Maksimal 10 detik!') | ||
let img = await q.download() | ||
if (!img) throw 'Foto/Video tidak ditemukan' | ||
stiker = await sticker(img, false, global.packname, global.author) | ||
} else if (args[0]) stiker = await sticker(false, args[0], global.packname, global.author) | ||
if (!img) throw `balas gambar/video/stiker dengan perintah ${usedPrefix + command}` | ||
let out | ||
try { | ||
if (/webp/g.test(mime)) out = await webp2png(img) | ||
else if (/image/g.test(mime)) out = await uploadImage(img) | ||
else if (/video/g.test(mime)) out = await uploadFile(img) | ||
stiker = await sticker(false, out, global.packname, global.author) | ||
} catch (e) { | ||
console.error(e) | ||
stiker = await sticker(img, false, global.packname, global.author) | ||
} | ||
} else if (args[0]) { | ||
if (isUrl(args[0])) stiker = await sticker(false, args[0], global.packname, global.author) | ||
else return m.reply('URL tidak valid!') | ||
} | ||
} finally { | ||
if (stiker) conn.sendMessage(m.chat, stiker, MessageType.sticker, { | ||
if (stiker) await conn.sendMessage(m.chat, stiker, MessageType.sticker, { | ||
quoted: m | ||
}) | ||
else throw 'Conversion failed' | ||
else throw `Gagal${m.isGroup ? ', balas gambarnya!' : ''}` | ||
} | ||
} | ||
handler.help = ['stiker (caption|reply media)', 'stiker <url>', 'stikergif (caption|reply media)', 'stikergif <url>'] | ||
handler.help = ['stiker ', 'stiker <url>'] | ||
handler.tags = ['sticker'] | ||
handler.command = /^s(tic?ker)?(gif)?(wm)?$/i | ||
|
||
module.exports = handler | ||
|
||
const isUrl = (text) => { | ||
return text.match(new RegExp(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)(jpe?g|gif|png)/, 'gi')) | ||
} |