-
-
Notifications
You must be signed in to change notification settings - Fork 579
/
Copy pathpropietario(a).js
370 lines (348 loc) · 15 KB
/
propietario(a).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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
import fs from 'fs'
import { execSync } from 'child_process'
import { spawn } from 'child_process'
import chalk from "chalk"
let linkRegex = /chat.whatsapp.com\/([0-9A-Za-z]{20,24})/i
let handler = async (m, { conn, command, usedPrefix, text, isAdmin, isOwner, isROwner, participants, groupMetadata }) => {
let fkontak, who, user, number, bot, bant, ownerNumber, aa, users, usr, q, mime, img
fkontak = { "key": { "participants":"[email protected]", "remoteJid": "status@broadcast", "fromMe": false, "id": "Halo" }, "message": { "contactMessage": { "vcard": `BEGIN:VCARD\nVERSION:3.0\nN:Sy;Bot;;;\nFN:y\nitem1.TEL;waid=${conn.user.jid.split('@')[0]}:${conn.user.jid.split('@')[0]}\nitem1.X-ABLabel:Ponsel\nEND:VCARD` }}, "participant": "[email protected]" }
const isCommand1 = /^(backup|respaldo|copia)$/i.test(command)
const isCommand2 = /^(ban(user|usuario|earuser|earusuario))$/i.test(command)
const isCommand3 = /^(seradmin|autoadmin|tenerpoder)$/i.test(command)
const isCommand4 = /^((set|cambiar|nueva|new)(bio|botbio|biobot))$/i.test(command)
const isCommand5 = /^((set|cambiar|nuev(a|o)?|new)(name|botname|namebot|nombre|nombrebot|botnombre))$/i.test(command)
const isCommand6 = /^((set|cambiar|nueva|new)(ppbot|botpp|fotobot|botfoto))$/i.test(command)
const isCommand7 = /^(update|actualizar|ups)$/i.test(command)
const isCommand8 = /^(banchat|banearchat)$/i.test(command)
const isCommand9 = /^(block|unblock|bloquear|desbloquear)$/i.test(command)
const isCommand10 = /^(restablecerdatos|borrardatos|deletedatauser)$/i.test(command)
const isCommand11 = /^(join|nuevogrupo|newgrupo|unete)$/i.test(command)
const isCommand12 = /^(bcbot|bcsubbot|bcsubot)$/i.test(command)
const isCommand13 = /^((broadcast|bc)(group|grup|gc))$/i.test(command)
const isCommand14 = /^(broadcastchats?|bcc(hats?)?)$/i.test(command)
const isCommand15 = /^(broadcastall|bc)$/i.test(command)
const isCommand16 = /^(reiniciar|restart)$/i.test(command)
async function reportError(e) {
await m.reply(lenguajeGB['smsMalError3']() + '\n*' + lenguajeGB.smsMensError1() + '*\n*' + usedPrefix + `${lenguajeGB.lenguaje() == 'es' ? 'reporte' : 'report'}` + '* ' + `${lenguajeGB.smsMensError2()} ` + usedPrefix + command)
console.log(`❗❗ ${lenguajeGB['smsMensError2']()} ${usedPrefix + command} ❗❗`)
console.log(e)
}
switch (true) {
case isCommand1:
await conn.reply(m.sender, lenguajeGB.smsResP1(), fkontak)
try {
let d = new Date
let date = d.toLocaleDateString('fr', { day: 'numeric', month: 'long', year: 'numeric' })
let database = await fs.readFileSync(`./database.json`)
let creds = await fs.readFileSync(`./GataBotSession/creds.json`)
await conn.reply(m.sender, lenguajeGB.smsResP2(date), fkontak)
await conn.sendMessage(m.sender, {document: database, mimetype: 'application/json', fileName: `database.json`}, { quoted: m })
await conn.sendMessage(m.sender, {document: creds, mimetype: 'application/json', fileName: `creds.json`}, { quoted: m })
} catch (e) {
reportError(e)
}
break
case isCommand2:
try{
function no(number){
return number.replace(/\s/g,'').replace(/([@+-])/g,'')}
text = no(text)
if(isNaN(text)) {
number = text.split`@`[1]
} else if(!isNaN(text)) {
number = text
}
user = conn.user.jid.split`@`[0] + '@s.whatsapp.net'
bot = conn.user.jid.split`@`[0]
bant = lenguajeGB.smsPropban1(usedPrefix, command, bot)
if (!text && !m.quoted) return conn.reply(m.chat, bant, null, { mentions: [user] })
try {
if(text) {
user = number + '@s.whatsapp.net'
} else if(m.quoted.sender) {
user = m.quoted.sender
} else if(m.mentionedJid) {
user = number + '@s.whatsapp.net'
}} catch (e) {
} finally {
number = user.split('@')[0]
if(user === conn.user.jid) return conn.reply(m.chat, lenguajeGB.smsPropban2(bot), null, { mentions: [user] })
for (let i = 0; i < global.owner.length; i++) {
ownerNumber = global.owner[i][0];
if (user.replace(/@s\.whatsapp\.net$/, '') === ownerNumber) {
aa = ownerNumber + '@s.whatsapp.net'
await conn.reply(m.chat, lenguajeGB.smsPropban3(ownerNumber), null, { mentions: [aa] })
return
}}
users = global.db.data.users
if (users[user].banned === true) conn.reply(m.chat, lenguajeGB.smsPropban4(number), null, { mentions: [user] })
users[user].banned = true
usr = m.sender.split('@')[0]
await conn.reply(m.chat, lenguajeGB.smsPropban5(), null, { mentions: [user] })
await conn.reply(user, lenguajeGB.smsPropban6(number, usr), null, { mentions: [user, m.sender] })
}} catch (e) {
await conn.reply(m.chat, lenguajeGB.smsPropban7(usedPrefix, command, number), null, m)
console.log(e)
}
break
case isCommand3:
if (m.fromMe) return
if (isAdmin) return m.reply(lenguajeGB.smsAutoAdmin1())
try {
await conn.groupParticipantsUpdate(m.chat, [m.sender], "promote")
} catch {
await m.reply(lenguajeGB.smsAutoAdmin2())}
break
case isCommand4:
if (!text) return m.reply(lenguajeGB.smsBioEd1())
if (text.length > 139) return m.reply(lenguajeGB.smsBioEd2())
try {
await conn.updateProfileStatus(text).catch(_ => _)
await conn.reply(m.chat, lenguajeGB.smsBioEd3(), m)
} catch (e) {
reportError(e)
}
break
case isCommand5:
if (!text) return m.reply(lenguajeGB.smsNameEd1())
if (text.length > 25) return m.reply(lenguajeGB.smsNameEd2())
try {
await conn.updateProfileStatus(text).catch(_ => _)
await conn.reply(m.chat, lenguajeGB.smsNameEd3(), m)
} catch (e) {
reportError(e)
}
break
case isCommand6:
bot = conn.user.jid
q = m.quoted ? m.quoted : m
mime = (q.msg || q).mimetype || ''
if (/image/.test(mime)) {
img = await q.download()
if (!img) return m.reply(lenguajeGB.smsFotoEd1(usedPrefix, command))
await conn.updateProfilePicture(bot, img)
await conn.reply(m.chat, lenguajeGB.smsFotoEd2(), m)
} else return m.reply(lenguajeGB.smsFotoEd3(usedPrefix, command))
break
case isCommand7:
try {
if (global.conn.user.jid == conn.user.jid) {
let stdout = execSync('git pull' + (m.fromMe && text ? ' ' + text : ''))
await conn.reply(m.chat, stdout.toString(), m)}
} catch {
var update = execSync('git remote set-url origin' + md + '.git && git pull')
await m.reply(update.toString())
}
break
case isCommand8:
global.db.data.chats[m.chat].isBanned = true
await conn.reply(m.chat, lenguajeGB.smsBanChE(), m)
break
case isCommand9:
let toUser = `@${m.sender.split("@")[0]}`
let why = lenguajeGB.smsBlockUn1(usedPrefix, command, toUser)
who = m.mentionedJid[0] ? m.mentionedJid[0] : m.quoted ? m.quoted.sender : text ? text.replace(/[^0-9]/g, '') + '@s.whatsapp.net' : false
let res = []
let cmd = command.toLowerCase()
let comd = command.toUpperCase()
if (!who) return conn.reply(m.chat, why, m, { mentions: [m.sender] })
if (!((cmd === "unblock" || cmd === "desbloquear") && (isOwner || isROwner))) {
for (let i = 0; i < global.owner.length; i++) {
ownerNumber = global.owner[i][0]
if (who.replace(/@s\.whatsapp\.net$/, '') === ownerNumber) {
aa = ownerNumber + '@s.whatsapp.net'
await conn.reply(m.chat, lenguajeGB.smsBlockUn2(comd, ownerNumber), null, { mentions: [aa] })
return
}}}
switch (true) {
case cmd == "block" || cmd == "bloquear":
if (who) {
await conn.updateBlockStatus(who, "block").then(() => { res.push(who) })
} else {
await conn.reply(m.chat, why, m, { mentions: [m.sender] })}
break
case cmd == "unblock" || cmd == "desbloquear":
if (who) {
await conn.updateBlockStatus(who, "unblock").then(() => { res.push(who) })
} else {
await conn.reply(m.chat, why, m, { mentions: [m.sender] })}
break
}
let useB = `${res ? `${res.map(v => '@' + v.split("@")[0])}` : ''}`
if (res[0]) conn.reply(m.chat, lenguajeGB.smsBlockUn3(comd, useB), m, { mentions: res })
break
case isCommand10:
function no(number){
return number.replace(/\s/g,'').replace(/([@+-])/g,'')}
text = no(text)
if(isNaN(text)) {
number = text.split`@`[1]
} else if(!isNaN(text)) {
number = text
}
if(!text && !m.quoted) return conn.reply(m.chat, lenguajeGB.smsRestarU1(), m)
if(isNaN(number)) return conn.reply(m.chat, lenguajeGB.smsRestarU2(), m)
try {
if(text) {
user = number + '@s.whatsapp.net'
} else if(m.quoted.sender) {
user = m.quoted.sender
} else if(m.mentionedJid) {
user = number + '@s.whatsapp.net'
}} catch (e) {
} finally {
let groupMetadata = m.isGroup ? await conn.groupMetadata(m.chat) : {}
let participants = m.isGroup ? groupMetadata.participants : []
users = m.isGroup ? participants.find(u => u.jid == user) : {}
number = user.split('@')[0]
delete global.global.db.data.users[user]
conn.reply(m.chat, lenguajeGB.smsRestarU3(number), null, { mentions: [user] })
}
break
case isCommand11:
user = m.sender.split('@')[0]
let link = (m.quoted ? m.quoted.text ? m.quoted.text : text : text) || text
let [_1, code1] = link.match(linkRegex) || []
if (!code1) return m.reply(lenguajeGB.smsJoin1(usedPrefix, command))
try {
if ( isOwner || m.fromMe) {
await m.reply(lenguajeGB.smsJoin2())
let res1 = await conn.groupAcceptInvite(code1)
await conn.sendMessage(res1, { text: lenguajeGB.smsJoin(user), mentions: (await conn.groupMetadata(`${res1}`)).participants.map(v => v.id) }, [user], { quoted: fkontak })
}} catch (e) {
reportError(e)
}
break
case isCommand12:
if (!text && !m.quoted) return m.reply(lenguajeGB.smsBCMensaje(usedPrefix, command))
if (conn.user.jid !== global.conn.user.jid) return false
users = [...new Set([...global.conns.filter(conn => conn.user && conn.state !== 'close').map(conn => conn.user.jid)])]
if (users.length === 0) {
await m.reply(lenguajeGB.smsJBCom4())
return
}
let cc = text ? m : m.quoted ? await m.getQuotedObj() : false || m
let teks = text ? text : cc.text
let content = conn.cMod(m.chat, cc, /bc|broadcast/i.test(teks) ? teks : lenguajeGB.smsJBDifu1() + teks)
for (let id of users) {
await delay(1500)
await conn.copyNForward(id, content, true)
}
let difuUser = `${users.map(v => '🌺 wa.me/' + v.replace(/[^0-9]/g, '') + `?text=${encodeURIComponent(usedPrefix)}estado`).join('\n')}`
let tolUser = users.length * 1.5
let numUser = users.length
await conn.reply(m.chat, lenguajeGB.smsJBDifu2(numUser, difuUser, tolUser).trim(), m)
break
case isCommand13:
if (!text && !m.quoted) return m.reply(lenguajeGB.smsBCMensaje(usedPrefix, command))
let cc2 = text ? m : m.quoted ? await m.getQuotedObj() : false || m
let teks2 = text ? text : cc2.text
let d = new Date(new Date + 3600000)
let locale = lenguajeGB.lenguaje()
let dia = d.toLocaleDateString(locale, { weekday: 'long' })
let fecha = d.toLocaleDateString(lenguajeGB.lenguaje(), { day: 'numeric', month: 'numeric', year: 'numeric' })
let mes = d.toLocaleDateString(lenguajeGB.lenguaje(), { month: 'long' })
let año = d.toLocaleDateString(lenguajeGB.lenguaje(), { year: 'numeric' })
let tiempo = d.toLocaleString('es-CO', { hour: 'numeric', minute: 'numeric', second: 'numeric', hour12: true })
let groups = Object.keys(await conn.groupFetchAllParticipating())
let usersTag = participants.map(u => conn.decodeJid(u.id))
let readMS = String.fromCharCode(8206).repeat(850)
await m.reply(lenguajeGB.smsChatGP1())
//for (let id of groups) {
//let infoGP = lenguajeGB.smsChatGP2(readMS, dia, mes, año, fecha, tiempo)
//await conn.reply(id, infoGP + teks2, { mentions: usersTag }, { quoted: null })
//}
for (let i = 0; i < groups.length; i++) {
const id = groups[i];
const infoGP = lenguajeGB.smsChatGP2(readMS, dia, mes, año, fecha, tiempo)
const delay = i * 4000 //4 seg
setTimeout(async () => {
await conn.reply(id, infoGP + teks2, { mentions: usersTag }, { quoted: fkontak });
}, delay)}
let totalGP = groups.length
await m.reply(lenguajeGB.smsChatGP3(totalGP))
break
case isCommand14:
if (!text && !m.quoted) return m.reply(lenguajeGB.smsBCMensaje(usedPrefix, command))
let cc3 = text ? m : m.quoted ? await m.getQuotedObj() : false || m
let teks3 = text ? text : cc3.text
let chats = Object.keys(global.db.data.users).filter(user => user.endsWith('@s.whatsapp.net'))
await conn.reply(m.chat, lenguajeGB.smsBCMensaje2(), m)
let start = new Date().getTime()
let totalPri = 0
for (let user of chats) {
await new Promise(resolve => setTimeout(resolve, 2000)) // 2 segundos
await conn.reply(user, `${lenguajeGB.smsBCbot7()}\n\n` + teks3, null)
totalPri++
if (totalPri >= 500000) {
break
}}
let end = new Date().getTime()
let time = Math.floor((end - start) / 1000)
if (time >= 60) {
let minutes = Math.floor(time / 60)
let seconds = time % 60
time = `${minutes} minutos y ${seconds} segundos`
} else {
time = `${time} segundos`
}
await m.reply(lenguajeGB.smsBCMensaje3(totalPri, time))
break
case isCommand15:
if (!text && !m.quoted) return m.reply(lenguajeGB.smsBCMensaje(usedPrefix, command))
let cc4 = text ? m : m.quoted ? await m.getQuotedObj() : false || m
let teks4 = text ? text : cc4.text
let groups2 = Object.keys(await conn.groupFetchAllParticipating())
let chats2 = Object.keys(global.db.data.users).filter(user => user.endsWith('@s.whatsapp.net'))
await conn.reply(m.chat, lenguajeGB.smsBCMensaje2(), m)
let start2 = new Date().getTime()
let usersTag2 = participants.map(u => conn.decodeJid(u.id))
let totalPri2 = 0
//for (let group of groups2) {
//await conn.reply(group, `${lenguajeGB.smsBCbot7()}\n\n` + teks4, { mentions: usersTag2 }, { quoted: m })
//}
for (let i = 0; i < groups2.length; i++) {
const group = groups2[i];
const delay = i * 4000; // 4 seg
setTimeout(async () => {
await conn.reply(group, `${lenguajeGB.smsBCbot7()}\n\n` + teks4, { mentions: usersTag2 }, { quoted: fkontak });
}, delay)}
for (let user of chats2) {
await new Promise(resolve => setTimeout(resolve, 2000)) // 2 segundos
await conn.reply(user, `${lenguajeGB.smsBCbot7()}\n\n` + teks4, null)
totalPri2++
if (totalPri2 >= 500000) {
break
}}
let end2 = new Date().getTime()
let totalPrivate2 = chats2.length
let totalGroups2 = groups2.length
let total2 = totalPrivate2 + totalGroups2
let time2 = Math.floor((end2 - start2) / 1000)
if (time2 >= 60) {
let minutes = Math.floor(time2 / 60)
let seconds = time2 % 60
time2 = `${minutes} minutos y ${seconds} segundos`
} else {
time2 = `${time2} segundos`
}
await m.reply(`${lenguajeGB.smsBCbot1()}
\`\`\`${lenguajeGB.smsBCbot2()} >> ${totalPrivate2}\`\`\`
\`\`\`${lenguajeGB.smsBCbot3()} >> ${totalGroups2}\`\`\`
\`\`\`${lenguajeGB.smsBCbot4()} >> ${total2}\`\`\`\n\n*${lenguajeGB.smsBCbot5()} ${time2}*\n${totalPri2 >= 500000 ? `\n*${lenguajeGB.smsBCbot6()}*` : ''}`)
break
case isCommand16:
try{
await m.reply(lenguajeGB.smsreiniciar())
console.log(chalk.bold.magenta('❇️ RESETTING... ❇️'))
process.send('reset')
} catch (e) {
reportError(e)}
break
}}
handler.command = /^(backup|respaldo|copia|ban(user|usuario|earuser|earusuario)|seradmin|autoadmin|tenerpoder|(set|cambiar|nueva|new)(bio|botbio|biobot)|(set|cambiar|nuev(a|o)?|new)(name|botname|namebot|nombre|nombrebot|botnombre)|(set|cambiar|nueva|new)(ppbot|botpp|fotobot|botfoto)|update|actualizar|ups|banchat|banearchat|block|unblock|bloquear|desbloquear|restablecerdatos|borrardatos|deletedatauser|join|nuevogrupo|newgrupo|unete|bcbot|bcsubbot|bcsubot|(broadcast|bc)(group|grup|gc)|broadcastchats?|bcc(hats?)?|broadcastall|bc|reiniciar|restart)$/i
handler.owner = true
export default handler
const more = String.fromCharCode(8206)
const readMore = more.repeat(4001)
const delay = time => new Promise(res => setTimeout(res, time))