-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathjadibot.js
43 lines (38 loc) · 1.29 KB
/
jadibot.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
let { WAConnection, MessageType, Mimetype} = require('@adiwajshing/baileys')
let qrcode = require('qrcode')
const fs = require('fs')
listjadibot = [];
const jadibot = async(reply,client,id) => {
conn = new WAConnection()
conn.logger.level = 'warn'
conn.version = [2, 2143, 3]
conn.browserDescription = [ 'Dreaded by Mokaya', '', '3.0' ]
conn.on('qr', async qr => {
let bot = await qrcode.toDataURL(qr, { scale: 8 })
let buffer = new Buffer.from(bot.replace('data:image/png;base64,', ''), 'base64')
bot = await client.sendMessage(id,buffer,MessageType.image,{caption:'Scan QR to become a bot\n*Rules:*\nQR will be changed every 30 seconds'})
setTimeout(() => {
client.deleteMessage(id, bot.key)
},30000)
})
conn.on('connecting', () => {
})
conn.on('open', () => {
reply(`Success Being BOT\n\n*Device*:\n\n ${JSON.stringify(conn.user,null,2)}`)
})
await conn.connect({timeoutMs: 30 * 1000})
listjadibot.push(conn.user)
conn.on('chat-update', async (message) => {
require('../index.js')(conn, message)
})
}
const stopjadibot = (reply) => {
conn = new WAConnection();
conn.close()
reply('Success stop being bot')
}
module.exports = {
jadibot,
stopjadibot,
listjadibot
}