forked from Shizu-Hub/Shizu-Bot-MD
-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy path_antispam.cjs
61 lines (48 loc) Β· 1.92 KB
/
_antispam.cjs
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
/* CRΓDITOS: https://github.com/Abiguelreyes75 */
let handler = m => m
handler.all = async function (m) {
let chat = global.db.data.chats[m.chat]
let delet = m.key.participant
let bang = m.key.id
let bot = global.db.data.settings[this.user.jid] || {}
let user = global.db.data.users[m.sender]
this.spam = this.spam ? this.spam : {}
if (!(m.sender in this.spam)) {
let spaming = {
jid: await m.sender,
spam: 0,
lastspam: 0
}
this.spam[spaming.jid] = spaming
} else try {
this.spam[m.sender].spam += 1
if (new Date - this.spam[m.sender].lastspam > 1000) {
if (this.spam[m.sender].spam > 3) {
this.spam[m.sender].spam = 0
this.spam[m.sender].lastspam = new Date * 1
let tiempo = 60000 * 1
let time = user.antispam + tiempo * 1
let texto = `*[β] @${m.sender.split("@")[0]} π½πΎ π·π°πΆπ°π ππΏπ°πΌ!, π½πΎ πΏπΎπ³ππ°π πππ°π π° ${global.author} πΏπΎπ ${tiempo / 1000 - 59} πΌπΈπ½πππΎ*`
if (new Date - user.antispam < tiempo * 1) return
await conn.reply(m.chat, texto, m, { mentions: this.parseMention(texto) })
user.banned = true
//await conn.sendMessage(m.chat, { delete: { remoteJid: m.chat, fromMe: false, id: bang, participant: delet }})
user.antispam = new Date * 1
} else {
this.spam[m.sender].spam = 0
this.spam[m.sender].lastspam = new Date * 1
}}
} catch {
await m.reply(`*[βπππ
πβ] πΎπ²ππππΈπΎ ππ½ π΄πππΎπ πΈπ½π΄ππΏπ΄ππ°π³πΎ*`)
}}
export default handler
function msToTime(duration) {
var milliseconds = parseInt((duration % 1000) / 100),
seconds = Math.floor((duration / 1000) % 60),
minutes = Math.floor((duration / (1000 * 60)) % 60),
hours = Math.floor((duration / (1000 * 60 * 60)) % 24)
hours = (hours < 10) ? "0" + hours : hours
minutes = (minutes < 10) ? "0" + minutes : minutes
seconds = (seconds < 10) ? "0" + seconds : seconds
return minutes + " m y " + seconds + " s "
}