forked from elrebelde21/LoliBot-MD
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b548ab
commit f6c8db5
Showing
2 changed files
with
119 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,35 @@ | ||
//by https://github.com/elrebelde21 | ||
|
||
export async function before(m, { conn, isAdmin, isBotAdmin, isOwner, isROwner }) { | ||
const comandos = /piedra|papel|tijera|estado|verificar|creadora|bottemporal|grupos|instalarbot|términos|bots|deletebot|eliminarsesion|serbot|verify|register|registrar|reg|reg1|nombre|name|nombre2|name2|edad|age|edad2|age2|genero|género|gender|identidad|pasatiempo|hobby|identify|finalizar|pas2|pas3|pas4|pas5|registroc|deletesesion|registror|jadibot/i | ||
export async function before(m, {conn, isAdmin, isBotAdmin, isOwner, isROwner, usedPrefix, command }) { | ||
if (m.isBaileys && m.fromMe) return !0 | ||
if (m.isGroup) return !1 | ||
if (!m.message) return !0 | ||
if (m.text.includes('PIEDRA') || m.text.includes('PAPEL') || m.text.includes('TIJERA') || m.text.includes('menu') || m.text.includes('estado') || m.text.includes('bots') || m.text.includes('deletebot') || m.text.includes('eliminarsesion') || m.text.includes('deletesesion') || m.text.includes('serbot') || m.text.includes('jadibot')) return !0 | ||
let chat = global.db.data.chats[m.chat] | ||
let user = global.db.data.users[m.sender] | ||
let bot = global.db.data.settings[this.user.jid] || {} | ||
if (!m.message) return !0 | ||
const regex = new RegExp(`^${comandos.source}$`, 'i') | ||
if (regex.test(m.text.toLowerCase().trim())) return !0 | ||
|
||
let chat, user, bot, mensaje | ||
chat = global.db.data.chats[m.chat] | ||
user = global.db.data.users[m.sender] | ||
bot = global.db.data.settings[this.user.jid] || {} | ||
|
||
if (bot.antiPrivate && !isOwner && !isROwner) { | ||
await m.reply(`Hola *@${m.sender.split`@`[0]}*, Esta prohibido usar el bot el privado\n\n✴️solo si quiere hacerte un bot manda el comando .serbot\n\n🚫NO USAR LOS COMANDO DEL BOT AL PV🚫\n\nPara usar el bot unirte al grupo del oficial del el bot\n${nn}`, false, { mentions: [m.sender] }) | ||
await conn.groupParticipantsUpdate(m.chat, [m.sender], 'banchat') | ||
if (user.counterPrivate === 0) { | ||
mensaje = `Hola *@${m.sender.split`@`[0]}*, Esta prohibido usar el bot el privado\n\n✴️solo si quiere hacerte un bot manda el comando .serbot\n\n🚫NO USAR LOS COMANDO DEL BOT AL PV🚫\n\nPara usar el bot unirte al grupo del oficial del el bot\n${nn}\n\n⚠️ \`\`\`ADVERTENCIA 1/3\`\`\` ⚠️` | ||
await conn.reply(m.chat, mensaje, m, { mentions: [m.sender] }) | ||
|
||
} else if (user.counterPrivate === 1) { | ||
let grupos = [ nn, nnn, nnnt, nnntt, nnnttt ].getRandom() | ||
mensaje = `*Otra vez 🤨 ya que dije no escriba al privado 🫤*\n\n*Para usar el bot unirte al grupo oficial aqui 👇*\n${grupos}\n\n*SI VUELVE A ESCRIBIR SERÁ BLOQUEADO(A)* ‼️\n⚠️ \`\`\`ADVERTENCIA 2/3\`\`\` ⚠️` | ||
await conn.reply(m.chat, mensaje, m, { mentions: [m.sender] }) | ||
|
||
} else if (user.counterPrivate === 2) { | ||
mensaje = `*@${m.sender.split`@`[0]} 🤨, NO ENTIENDE QUE REPITE 3 VECES NO ESCRIBE AL PRIVADO, AHORA SERA BLOQUEADO.*\n\n⚠️ \`\`\`ADVERTENCIA 3/3 \`\`\` ⚠️` | ||
await conn.reply(m.chat, mensaje, m, { mentions: [m.sender] }) | ||
|
||
user.counterPrivate = -1 | ||
await this.updateBlockStatus(m.sender, 'block') | ||
} | ||
user.counterPrivate++ | ||
} | ||
return !1 | ||
}} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,102 @@ | ||
//CRÉDITOS: https://github.com/Abiguelreyes75 | ||
|
||
//let handler = m => m | ||
//handler.all = async function (m) { | ||
const userSpamData = {} | ||
let handler = m => m | ||
handler.before = async function (m, {conn, isAdmin} ) { | ||
if (m.isGroup && isAdmin) return null | ||
handler.before = async function (m, {conn, isAdmin, isBotAdmin, isOwner, isROwner, isPrems}) { | ||
const chat = global.db.data.chats[m.chat] | ||
if (!m.isGroup) return | ||
if (chat.modoadmin) return | ||
if (isOwner || isROwner || isAdmin || !isBotAdmin || isPrems) return | ||
|
||
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] | ||
const sender = m.sender | ||
const currentTime = new Date().getTime() | ||
const timeWindow = 5000 // tiempo límite | ||
const messageLimit = 6 // cantidad de mensajes en dicho tiempo | ||
|
||
let time, time2, time3, mensaje | ||
time = 60000 // 1 min | ||
time2 = 120000 // 2 min | ||
time3 = 360000 // 4 min | ||
|
||
if (bot.antiSpam) { | ||
this.spam = this.spam ? this.spam : {} | ||
if (!(m.sender in this.spam)) { | ||
let spaming = { | ||
jid: await m.sender, | ||
spam: 0, | ||
lastspam: 0 | ||
if (!(sender in userSpamData)) { | ||
userSpamData[sender] = { | ||
lastMessageTime: currentTime, | ||
messageCount: 1, | ||
antiBan: 0, | ||
message: 0, | ||
message2: 0, | ||
message3: 0, | ||
} | ||
this.spam[spaming.jid] = spaming | ||
|
||
} else try { | ||
this.spam[m.sender].spam += 1 | ||
|
||
if (new Date - this.spam[m.sender].lastspam > 4000) { | ||
if (this.spam[m.sender].spam > 6) { | ||
this.spam[m.sender].spam = 0 | ||
} else { | ||
const userData = userSpamData[sender] | ||
const timeDifference = currentTime - userData.lastMessageTime | ||
|
||
if (userData.antiBan === 1) { | ||
if (userData.message < 1) { | ||
userData.message++ | ||
mensaje = `*@${m.sender.split`@`[0]} NO PUEDE USAR COMANDOS DURANTE 1 MINUTOS*\n\n*MOTIVO: SPAM DE MENSAJES LEVE*` | ||
await conn.reply(m.chat, mensaje, m, { mentions: [m.sender] }) | ||
}} else if (userData.antiBan === 2) { | ||
if (userData.message2 < 1) { | ||
userData.message2++ | ||
mensaje = `*@${m.sender.split`@`[0]} NO PUEDE USAR COMMANDOS DURANTE 2 MINUTOS*\n\n*MOTIVO: SPAM DE MENSAJES MODERADO*` | ||
await conn.reply(m.chat, mensaje, m, { mentions: [m.sender] }) | ||
}} else if (userData.antiBan === 3) { | ||
if (userData.message3 < 1) { | ||
userData.message3++ | ||
mensaje = `*@${m.sender.split`@`[0]} NO PUEDE USAR COMMANDOS DURANTE 5 MINUTOS*\n\n*MOTIVO: SPAM DE MENSAJE ALARMANTE*` | ||
await conn.reply(m.chat, mensaje, m, { mentions: [m.sender] }) | ||
await conn.groupParticipantsUpdate(m.chat, [sender], 'remove') | ||
}} | ||
|
||
this.spam[m.sender].lastspam = new Date * 1 | ||
let tiempo = 60000 * 1 | ||
let time = user.antispam + tiempo * 1 | ||
let texto = `*@${m.sender.split("@")[0]} ${lenguajeGB['smsNoSpam']()}*` | ||
if (timeDifference <= timeWindow) { | ||
userData.messageCount += 1 | ||
|
||
if (new Date - user.antispam < tiempo * 1) return | ||
await conn.reply(m.chat, texto, m, { mentions: this.parseMention(texto) }) | ||
if (userData.messageCount >= messageLimit) { | ||
const mention = `@${sender.split("@")[0]}` | ||
const warningMessage = `*${mention} ESTA PROHIBIDO HACER SPAM DE MENSAJES!!*` | ||
if (userData.antiBan > 2) return | ||
await conn.reply(m.chat, warningMessage, m, { mentions: [m.sender] }) | ||
user.banned = true | ||
userData.antiBan++ | ||
userData.messageCount = 1 | ||
|
||
if (userData.antiBan === 1) { | ||
setTimeout(() => { | ||
if (userData.antiBan === 1) { | ||
userData.antiBan = 0 | ||
userData.message = 0 | ||
userData.message2 = 0 | ||
userData.message3 = 0 | ||
user.banned = false | ||
}}, time) | ||
|
||
await conn.sendMessage(m.chat, { delete: { remoteJid: m.chat, fromMe: false, id: bang, participant: delet }}) | ||
user.antispam = new Date * 1 | ||
|
||
} else if (userData.antiBan === 2) { | ||
setTimeout(() => { | ||
if (userData.antiBan === 2) { | ||
userData.antiBan = 0 | ||
userData.message = 0 | ||
userData.message2 = 0 | ||
userData.message3 = 0 | ||
user.banned = false | ||
}}, time2) | ||
|
||
} else if (userData.antiBan === 3) { | ||
setTimeout(() => { | ||
if (userData.antiBan === 3) { | ||
userData.antiBan = 0 | ||
userData.message = 0 | ||
userData.message2 = 0 | ||
userData.message3 = 0 | ||
user.banned = false | ||
}}, time3) | ||
|
||
}} | ||
} else { | ||
this.spam[m.sender].spam = 0 | ||
this.spam[m.sender].lastspam = new Date * 1 | ||
if (timeDifference >= 2000) { | ||
userData.messageCount = 1 | ||
}} | ||
userData.lastMessageTime = currentTime | ||
}} | ||
|
||
} catch (e) { | ||
console.log(e) | ||
m.reply(lenguajeGB.smsMalError()) | ||
}}} | ||
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 | ||
export default handler | ||
|
||
return minutes + " m y " + seconds + " s " | ||
} | ||
|