-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathstart.js
48 lines (42 loc) · 1.47 KB
/
start.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
/*[-- require --]*/
const {
WAConnection,
MessageType
} = require('@adiwajshing/baileys')
const fs = require('fs')
const { image } = MessageType
const msgHdlr = require('./msghdlr')
const welcome = require('./lib/welcome')
const { banner } = require('./lib/functions')
const { color } = require('./lib/color')
const moment = require("moment-timezone")
const client = new WAConnection()
const time = moment.tz('Asia/Jakarta').format("HH:mm:ss")
/*[-- first auth --]*/
async function auth() {
client.logger.level = 'warn'
console.log(banner.string)
client.on('qr', qr => {
console.log(color(time,"white"),color('[','white'),color('∆','red'),color(']','white'),color('qr already scan.subscribe','white'),color('YOU','red'),color('TUBE','white'),color('ampibi gaming','yellow'))
})
fs.existsSync('./session.json') && client.loadAuthInfo('./session.json')
client.on('connecting', () => {
console.log(color(time,"white"),color("[STATUS]","green"), "Connecting...")
})
client.on('open', () => {
console.log(color(time,"white"),color("[STATUS]", "green"), "Connected")
})
await client.connect({timeoutMs: 30*1000})
fs.writeFileSync('./session.json', JSON.stringify(client.base64EncodedAuthInfo(), null, '\t'))
}
/*[-- function --]*/
async function start(){
client.on('group-participants-update', async (mem) => {
await welcome(client, mem , image)
})
client.on('chat-update', async (mek) => {
await msgHdlr(client , mek)
})
}
auth()
start()