-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_porn-detector.js
92 lines (79 loc) · 2.54 KB
/
_porn-detector.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
// Código elaborado por GataNina-Li (Gata Dios)
/*let { downloadContentFromMessage } = (await import(global.baileys))
import uploadImage from '../lib/uploadImage.js'
import { webp2png } from '../lib/webp2mp4.js'
import fetch from 'node-fetch'
import axios from 'axios'
import path from 'path'
global.enlace = null
let handler = m => m
handler.before = async function (m, { conn, __dirname, isBotAdmin }) {
let chat = global.db.data.chats[m.chat]
let media, link, buffer = false
let web = /https?:\/\/\S+/
if (!isBotAdmin || chat.delete || !m.isGroup) return
if (!chat.antiPorn) return
try{
let q = m
let mime = (q.msg || q).mimetype || q.mediaType || ''
let delet = q.key.participant
let bang = q.key.id
if (/sticker|image/.test(mime) || m.mtype == 'viewOnceMessageV2') {
let isTele = /^image\/(png|jpe?g)$/.test(mime)
if (isTele) {
media = await q.download()
link = await uploadImage(media)
}
if (m.mtype == 'viewOnceMessageV2') {
let msg = m.message.viewOnceMessageV2.message
let type = Object.keys(msg)[0]
if (type == 'imageMessage') {
media = await downloadContentFromMessage(msg[type], 'image')
buffer = Buffer.from([])
for await (const chunk of media) {
buffer = Buffer.concat([buffer, chunk])
}
link = await uploadImage(buffer)
}}
if (m.mtype == 'stickerMessage') {
try {
link = await webp2png(await q.download())
} catch {
link = false
}}
} else {
if (q.text || web.test(q.text)) {
await IsEnlace(q.text).then(result => {
link = result ? enlace : false
console.log(result)
}).catch(error => {
link = false
})
} else return
}
if (!link) return
const response = await fetch(`https://api.alyachan.dev/api/porn-detector?image=${link}&apikey=GataDios`)
const result = await response.json()
enlace = null
if (result.status && result.data.isPorn) {
await m.reply('*La imagen contiene contenido para adultos.*')
await conn.sendMessage(m.chat, { delete: { remoteJid: m.chat, fromMe: false, id: bang, participant: delet }})
}} catch (error) {
console.log(error)
}
}
export default handler
async function IsEnlace(texto) {
const regexEnlace = /https?:\/\/\S+/
const match = texto.match(regexEnlace)
if (match) {
enlace = match[0]
const response = await fetch(enlace, { method: 'HEAD' })
const contentType = response.headers.get('content-type')
//console.log(contentType)
if (contentType && (contentType.startsWith('image/jpeg') || contentType.startsWith('image/jpg') || contentType.startsWith('image/png') || contentType.startsWith('image/webp'))) {
return true
}}
return false
}
*/