forked from mhmmdrizki13/mrizkibot-starting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_antispam.js
29 lines (27 loc) · 1000 Bytes
/
_antispam.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
let handler = m => m
handler.all = async function (m) {
if (!db.data.settings[this.user.jid].antispam) return // antispam aktif?
if (m.isBaileys && m.fromMe) return
if (!m.message) return
if (!m.isCommand) return
if (db.data.users[m.sender].banned) return
if (db.data.chats[m.chat].isBanned) return
this.spam = this.spam ? this.spam : {}
if (m.sender in this.spam) {
this.spam[m.sender].count++
if (m.messageTimestamp.toNumber() - this.spam[m.sender].lastspam > 10) {
if (this.spam[m.sender].count > 10) {
db.data.users[m.sender].banned = true
await this.sendButton(m.chat, 'kamu dibanned!', '© M Rizki BOT', 'Pemilik Bot', ',owner')
}
this.spam[m.sender].count = 0
this.spam[m.sender].lastspam = m.messageTimestamp.toNumber()
}
}
else this.spam[m.sender] = {
jid: m.sender,
count: 0,
lastspam: 0
}
}
module.exports = handler