-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix sticker and cooldown only not premium
- Loading branch information
Showing
2 changed files
with
31 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/* eslint-disable no-mixed-operators */ | ||
const { MessageType } = require('@adiwajshing/baileys') | ||
const { exec } = require('child_process') | ||
const { getRandom } = require('../utils/functions') | ||
const ffmpeg = require('fluent-ffmpeg') | ||
|
@@ -7,57 +8,66 @@ const fs = require('fs') | |
module.exports = { | ||
name: 'sticker', | ||
aliases: ['s', 'st'], | ||
cooldown: 600, | ||
description: 'Untuk menyimpan note atau catatan di group\nPenggunaan: !notes <save/remove> <key> <value>', | ||
async execute (client, chat, pesan, args) { | ||
if (!client.isPmium && !client.isOwner) return client.reply(pesan.error.premium) | ||
const encmedia = client.isQuotedImage ? JSON.parse(JSON.stringify(chat).replace('quotedM', 'm')).message.extendedTextMessage.contextInfo : chat | ||
const media = await client.downloadAndSaveMediaMessage(encmedia) | ||
ranw = getRandom('.webp') | ||
ranp = getRandom('.png') | ||
if ((client.isMedia && !chat.message.videoMessage || client.isQuotedImage) && args.length == 0) { | ||
const encmedia = client.isQuotedImage ? JSON.parse(JSON.stringify(chat).replace('quotedM','m')).message.extendedTextMessage.contextInfo : chat | ||
const media = await client.downloadAndSaveMediaMessage(encmedia) | ||
ranw = getRandom('.webp') | ||
client.reply(pesan.tunggu) | ||
await ffmpeg(`./${media}`) | ||
.input(media) | ||
.on('start', function (cmd) { | ||
console.log(`Started : ${cmd}`) | ||
console.log(`[SERVER] Started : ${cmd}`) | ||
}) | ||
.on('error', function (err) { | ||
console.log(`Error : ${err}`) | ||
console.log(`[SERVER] Error : ${err}`) | ||
fs.unlinkSync(media) | ||
client.reply(mess.error.stick) | ||
client.reply('Error saat membuat sticker') | ||
}) | ||
.on('end', function () { | ||
console.log('Finish') | ||
client.sendMessage(client.from, fs.readFileSync(ranw), sticker, { quoted: chat }) | ||
console.log('[SERVER] Berhasil membuat sticker') | ||
client.sendMessage(client.from, fs.readFileSync(ranw), MessageType.sticker, { quoted: chat }) | ||
fs.unlinkSync(media) | ||
fs.unlinkSync(ranw) | ||
}) | ||
.addOutputOptions(['-vcodec', 'libwebp', '-vf', 'scale=\'min(320,iw)\':min\'(320,ih)\':force_original_aspect_ratio=decrease,fps=15, pad=320:320:-1:-1:[email protected], split [a][b]; [a] palettegen=reserve_transparent=on:transparency_color=ffffff [p]; [b][p] paletteuse']) | ||
.toFormat('webp') | ||
.save(ranw) | ||
} else if ((client.isMedia && chat.message.videoMessage.seconds < 11 || client.isQuotedVideo && chat.message.extendedTextMessage.contextInfo.quotedMessage.videoMessage.seconds < 11) && args.length == 0) { | ||
client.reply(mess.wait) | ||
if (!client.isPmium && !client.isOwner) return client.reply(pesan.error.premium) | ||
const encmedia = client.isQuotedVideo ? JSON.parse(JSON.stringify(chat).replace('quotedM','m')).message.extendedTextMessage.contextInfo : chat | ||
const media = await client.downloadAndSaveMediaMessage(encmedia) | ||
ranw = getRandom('.webp') | ||
client.reply(pesan.tunggu) | ||
await ffmpeg(`./${media}`) | ||
.inputFormat(media.split('.')[1]) | ||
.on('start', function (cmd) { | ||
console.log(`Started : ${cmd}`) | ||
console.log(`[SERVER] Started : ${cmd}`) | ||
}) | ||
.on('error', function (err) { | ||
console.log(`Error : ${err}`) | ||
console.log(`[SERVER] Error : ${err}`) | ||
fs.unlinkSync(media) | ||
tipe = media.endsWith('.mp4') ? 'video' : 'gif' | ||
client.reply(`❌ Gagal, pada saat mengkonversi ${tipe} ke stiker`) | ||
}) | ||
.on('end', function () { | ||
console.log('Finish') | ||
client.sendMessage(client.from, fs.readFileSync(ranw), sticker, { quoted: chat }) | ||
console.log('[SERVER] Berhasil membuat sticker') | ||
client.sendMessage(client.from, fs.readFileSync(ranw), MessageType.sticker, { quoted: chat }) | ||
fs.unlinkSync(media) | ||
fs.unlinkSync(ranw) | ||
}) | ||
.addOutputOptions(['-vcodec', 'libwebp', '-vf', 'scale=\'min(320,iw)\':min\'(320,ih)\':force_original_aspect_ratio=decrease,fps=15, pad=320:320:-1:-1:[email protected], split [a][b]; [a] palettegen=reserve_transparent=on:transparency_color=ffffff [p]; [b][p] paletteuse']) | ||
.toFormat('webp') | ||
.save(ranw) | ||
} else if ((client.isMedia || client.isQuotedImage) && args[0] == 'nobg') { | ||
client.reply(mess.wait) | ||
if (!client.isPmium && !client.isOwner) return client.reply(pesan.error.premium) | ||
const encmedia = client.isQuotedImage ? JSON.parse(JSON.stringify(chat).replace('quotedM','m')).message.extendedTextMessage.contextInfo : chat | ||
const media = await client.downloadAndSaveMediaMessage(encmedia) | ||
ranw = getRandom('.webp') | ||
ranp = getRandom('.png') | ||
client.reply(pesan.tunggu) | ||
keyrmbg = process.env.KEY_REMOVEBG | ||
await removeBackgroundclient.fromImageFile({ path: media, apiKey: keyrmbg.result, size: 'auto', type: 'auto', ranp }).then(res => { | ||
fs.unlinkSync(media) | ||
|
@@ -67,8 +77,8 @@ module.exports = { | |
}) | ||
exec(`ffmpeg -i ${ranp} -vcodec libwebp -filter:v fps=fps=20 -lossless 1 -loop 0 -preset default -an -vsync 0 -s 512:512 ${ranw}`, (err) => { | ||
fs.unlinkSync(ranp) | ||
if (err) return client.reply(mess.error.stick) | ||
client.sendMessage(client.from, fs.readFileSync(ranw), sticker, { quoted: chat }) | ||
if (err) return client.reply('Error saat membuat sticker') | ||
client.sendMessage(client.from, fs.readFileSync(ranw), MessageType.sticker, { quoted: chat }) | ||
}) | ||
}) | ||
/* } else if ((client.isMedia || client.isQuotedImage) && colors.includes(args[0])) { | ||
|
@@ -83,7 +93,7 @@ module.exports = { | |
.on('end', function () { | ||
console.log('Finish') | ||
fs.unlinkSync(media) | ||
client.sendMessage(client.from, fs.readFileSync(ran), sticker, {quoted: chat}) | ||
client.sendMessage(client.from, fs.readFileSync(ran), MessageType.sticker, {quoted: chat}) | ||
fs.unlinkSync(ran) | ||
}) | ||
.addOutputOptions([`-vcodec`,`libwebp`,`-vf`,`scale='min(320,iw)':min'(320,ih)':force_original_aspect_ratio=decrease,fps=15, pad=320:320:-1:-1:color=${args[0]}@0.0, split [a][b]; [a] palettegen=reserve_transparent=off; [b][p] paletteuse`]) | ||
|
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