-
Notifications
You must be signed in to change notification settings - Fork 105
/
index.js
88 lines (81 loc) · 3 KB
/
index.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
86
87
88
const { create } = require('@open-wa/wa-automate')
const msgHandler = require('./msgHandler')
const fs = require('fs-extra')
const config = JSON.parse(fs.readFileSync('./config.json'))
const serverOption = {
headless: true,
cacheEnabled: false,
useChrome: true,
chromiumArgs: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--aggressive-cache-discard',
'--disable-cache',
'--disable-application-cache',
'--disable-offline-load-stale-cache',
'--disk-cache-size=0'
]
}
const opsys = process.platform
if (opsys === 'win32' || opsys === 'win64') {
serverOption.executablePath = 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
} else if (opsys === 'linux') {
serverOption.browserRevision = '737027'
} else if (opsys === 'darwin') {
serverOption.executablePath = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
}
const startServer = async (client) => {
global.sclient = client
sendingSticker = []
queueSticker = []
botadmins = config.botadmins
prefix = config.prefix
botname = config.botname
global.sendingAnimatedSticker = []
global.queueAnimatedSticker = []
global.amdownloaden = []
global.queuemp3 = []
global.queuemp4 = []
spamarr = []
console.log('[SERVER] Server Started!')
// Force it to keep the current session
client.onStateChanged((state) => {
console.log('[Client State]', state)
if (state === 'CONFLICT') client.forceRefocus()
})
// listening on message
client.onMessage((message) => {
msgHandler(client, message)
})
client.onAddedToGroup((chat) => {
let totalMem = chat.groupMetadata.participants.length
if (totalMem < 30) {
client.sendText(chat.id, `This group only has ${totalMem} members, Its needs atleast 30 members to activate the services`).then(() => client.leaveGroup(chat.id))
client.deleteChat(chat.id)
} else {
client.sendText(chat.groupMetadata.id, `Thanks for adding me *${chat.contact.name}*. Use #help to see the usable commands`)
}
})
// listening on Incoming Call
client.onIncomingCall((call) => {
client.sendText(call.peerJid, '...')
client.contactBlock(call.peerJid)
ban.push(call.peerJid)
fs.writeFileSync('./lib/banned.json', JSON.stringify(ban))
})
}
create({"headless": true,
"cacheEnabled": false,
"useChrome": true,
"chromiumArgs": [
"--no-sandbox",
"--disable-setuid-sandbox",
"--aggressive-cache-discard",
"--disable-cache",
"--disable-application-cache",
"--disable-offline-load-stale-cache",
"--disk-cache-size=0"
]
})
.then(async (client) => startServer(client))
.catch((error) => console.log(error))