-
Notifications
You must be signed in to change notification settings - Fork 202
/
Copy pathmeme.js
85 lines (73 loc) · 3.05 KB
/
meme.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
const Aqua = require('../events');
const {MessageType, Mimetype} = require('@adiwajshing/baileys');
const memeMaker = require('meme-maker')
const fs = require('fs')
const Config = require('../config');
const Language = require('../language');
const Lang = Language.getString('memes');
if (Config.WORKTYPE == 'private') {
Aqua.addCommand({pattern: 'meme ?(.*)', fromMe: true, desc: Lang.MEMES_DESC }, (async (message, match) => {
if (message.reply_message === false) return await message.client.sendMessage(message.jid,Lang.NEED_REPLY, MessageType.text);
var topText, bottomText;
if (match[1].includes(';')) {
var split = match[1].split(';');
topText = split[0];
bottomText = split[1];
}
else {
topText = match[1];
bottomText = '';
}
var info = await message.reply(Lang.DOWNLOADING);
var location = await message.client.downloadAndSaveMediaMessage({
key: {
remoteJid: message.reply_message.jid,
id: message.reply_message.id
},
message: message.reply_message.data.quotedMessage
});
memeMaker({
image: location,
outfile: 'aqua-meme.png',
topText: topText,
bottomText: bottomText,
}, async function(err) {
if(err) throw new Error(err)
await message.client.sendMessage(message.jid, fs.readFileSync('aqua-meme.png'), MessageType.image, { filename: 'aqua-meme.png', mimetype: Mimetype.png, caption: Config.CAPTION, quoted: message.data});
await info.delete();
});
}));
}
else if (Config.WORKTYPE == 'public') {
Aqua.addCommand({pattern: 'meme ?(.*)', fromMe: false, desc: Lang.MEMES_DESC}, (async (message, match) => {
if (message.reply_message === false) return await message.client.sendMessage(message.jid,Lang.NEED_REPLY, MessageType.text);
var topText, bottomText;
if (match[1].includes(';')) {
var split = match[1].split(';');
topText = split[0];
bottomText = split[1];
}
else {
topText = match[1];
bottomText = '';
}
var info = await message.reply(Lang.DOWNLOADING);
var location = await message.client.downloadAndSaveMediaMessage({
key: {
remoteJid: message.reply_message.jid,
id: message.reply_message.id
},
message: message.reply_message.data.quotedMessage
});
memeMaker({
image: location,
outfile: 'aqua-meme.png',
topText: topText,
bottomText: bottomText,
}, async function(err) {
if(err) throw new Error(err)
await message.client.sendMessage(message.jid, fs.readFileSync('aqua-meme.png'), MessageType.image, { filename: 'aqua-meme.png', mimetype: Mimetype.png, caption: Config.CAPTION, quoted: message.data });
await info.delete();
});
}));
}