Create Quote Stickers with Quotly Bot - WhatsApp Bot Command
const { sticker } = require('../lib/sticker.js');
const axios = require('axios');
const handler = async (m, { conn, args, usedPrefix, command }) => {
let text;
if (args.length >= 1) {
text = args.slice(0).join(' ');
} else if (m.quoted && m.quoted.text) {
text = m.quoted.text;
} else throw '*Example*: .qc how to make bots';
if (!text) return m.reply('enter text');
if (text.length > 10000) return m.reply('🐱 Max 50 Texts!');
conn.sendMessage(m.chat, { react: { text: '🪄', key: m.key }});
try {
let pp = await conn.profilePictureUrl(m.sender, 'image').catch(_ => 'https://i.ibb.co/3Fh9V6p/avatar-contact.png');
const obj = {
'type': 'quote',
'format': 'png',
'backgroundColor': '#FFFFFF',
'width': 512,
'height': 768,
'scale': 2,
'messages': [{
'entities': [],
'avatar': true,
'from': {
'id': 1,
'name': m.name,
'photo': {
'url': pp
}
},
'text': text,
'replyMessage': {}
}]
};
const json = await axios.post('https://bot.lyo.su/quote/generate', obj, {
headers: {
'Content-Type': 'application/json'
}
});
const buffer = Buffer.from(json.data.result.image, 'base64');
let stiker = await sticker(buffer, false, global.packname, global.author);
if (stiker) return conn.sendFile(m.chat, stiker, 'Quotly.webp', '', m);
} catch (error) {
console.log(error);
m.reply('🐱 It looks like something went wrong');
}
};
handler.help = ['qc'];
handler.tags = ['tools'];
handler.command = /^(qc|quotely)$/i;
module.exports = handler;
This WhatsApp bot command allows you to create quote stickers using the Quotly API. Simply enter your text or quote a message, and the bot will generate a stylish sticker for you. The bot will use your profile picture as the avatar in the quote. If you don't have a profile picture, it will use a default avatar. The bot supports a maximum of 50 texts for each sticker generation.
To use the command:
-
Save the code above as a JavaScript file (e.g.,
quotely.js). -
Place the file in your WhatsApp bot's code directory.
-
Add the following command to your bot's command handler:
handler.command = /^(qc|quotely)$/i;
How to use the command:
.qc [your text]- Creates a quote sticker with the given text..qc- Creates a quote sticker from the text of the last message..quotely [your text]- Same as.qc [your text]..quotely- Same as.qc.
原文地址: https://www.cveoy.top/t/topic/bEk9 著作权归作者所有。请勿转载和采集!