-
Notifications
You must be signed in to change notification settings - Fork 9
/
inspectlink.js
52 lines (47 loc) · 1.63 KB
/
inspectlink.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
let linkRegex = /chat\.whatsapp\.com\/(?:invite\/)?([0-9A-Za-z]{20,24})/i
let handler = async (m, { conn, text }) => {
let [, code] = text.match(linkRegex) || []
if (!code) throw 'Link invalid'
let res = await conn.query({
json: ["query", "invite", code],
expect200: true
})
if (!res) throw res
let caption = `
-- [Group Link Inspector] --
${res.id}
*Judul:* ${res.subject}
*Dibuat* oleh @${res.id.split('-')[0]} pada *${formatDate(res.creation * 1000)}*${res.subjectOwner ? `
*Judul diubah* oleh @${res.subjectOwner.split`@`[0]} pada *${formatDate(res.subjectTime * 1000)}*`: ''}${res.descOwner ? `
*Deskripsi diubah* oleh @${res.descOwner.split`@`[0]} pada *${formatDate(res.descTime * 1000)}*` : ''}
*Jumlah Member:* ${res.size}
*Member yang diketahui join*: ${res.participants ? '\n' + res.participants.map((user, i) => ++i + '. @' + user.id.split`@`[0]).join('\n').trim() : 'Tidak ada'}
${res.desc ? `*Deskripsi:*
${res.desc}` : '*Tidak ada Deskripsi*'}
*JSON Version*
\`\`\`${JSON.stringify(res, null, 1)}\`\`\`
`.trim()
let pp = await conn.getProfilePicture(res.id).catch(console.error)
if (pp) conn.sendFile(m.chat, pp, 'pp.jpg', null, m)
m.reply(caption, false, {
contextInfo: {
mentionedJid: conn.parseMention(caption)
}
})
}
handler.help = ['inspect <chat.whatsapp.com>']
handler.tags = ['tools']
handler.command = /^inspect$/i
module.exports = handler
function formatDate(n, locale = 'id') {
let d = new Date(n)
return d.toLocaleDateString(locale, {
weekday: 'long',
day: 'numeric',
month: 'long',
year: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric'
})
}