-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
hisoka_group.js
177 lines (166 loc) · 9.64 KB
/
hisoka_group.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
const { MessageMedia } = require("whatsapp-web.js")
const chalk = require("chalk")
const { jsonformat } = require("./lib/Function")
module.exports = async (hisoka, m) => {
if (m) {
let contact = await hisoka.getContactById(m.author)
let nameUser = contact.pushname || contact.shortName || contact.name
let metadata = await hisoka.getChatById(m.id.remote)
let groupName = metadata.name
console.log(chalk.black(chalk.bgWhite("[ Group Update ]")), chalk.black(chalk.bgGreen(new Date(m.timestamp * 1000))), chalk.black(chalk.bgGreen(m.body || m.type)) + "\n" + chalk.black(chalk.bgWhite("=> Author")), chalk.black(chalk.bgGreen(m.author)), chalk.black(chalk.yellow(nameUser)) + "\n" + chalk.black(chalk.bgWhite("=> Di")), chalk.bgGreen(groupName, m.id.remote))
}
try {
if (m.type == "description") {
// get metadata group
let metadata = await hisoka.getChatById(m.id.remote)
// get contact info
let contact = await hisoka.getContactById(m.author)
let teks = `
「 Group Description Change 」
⬡ *Author :* @${m.author.split("@")[0]}
⬡ *In :* ${metadata.name}
⬡ *Time :* ${new Date(m.timestamp * 1000)}
⬡ *New Description :*\n${m.body}
`
hisoka.sendMessage(m.id.remote, teks, { mentions: [contact] })
} else if (m.type == "subject") {
// get metadata group
let metadata = await hisoka.getChatById(m.id.remote)
// get contact info
let contact = await hisoka.getContactById(m.author)
let teks = `
「 Group Subject Change 」
⬡ *Author :* @${m.author.split("@")[0]}
⬡ *In :* ${metadata.name}
⬡ *Time :* ${new Date(m.timestamp * 1000)}
⬡ *New Subject :*\n${m.body}
`
hisoka.sendMessage(m.id.remote, teks, { mentions: [contact] })
} else if (m.type == "picture") {
// get metadata group
let metadata = await hisoka.getChatById(m.id.remote)
// get contact info
let contact = await hisoka.getContactById(m.author)
let teks = `
「 Group Profile Change 」
⬡ *Author :* @${m.author.split("@")[0]}
⬡ *In :* ${metadata.name}
⬡ *Time :* ${new Date(m.timestamp * 1000)}
⬡ *Type :* ${m.body}
`
let pp = hisoka.getProfilePicUrl(m.id.remote) || 'https://i0.wp.com/www.gambarunik.id/wp-content/uploads/2019/06/Top-Gambar-Foto-Profil-Kosong-Lucu-Tergokil-.jpg'
let message = await MessageMedia.fromUrl(pp)
hisoka.sendMessage(m.id.remote, message, { caption: teks, mentions: [contact] })
} else if (m.type == "ephemeral") {
// get metadata group
let metadata = await hisoka.getChatById(m.id.remote)
// get contact info
let contact = await hisoka.getContactById(m.author)
let teks = `
「 Group Ephemeral Detect 」
⬡ *Author :* @${m.author.split("@")[0]}
⬡ *In :* ${metadata.name}
⬡ *Time :* ${new Date(m.timestamp * 1000)}
⬡ *Type :*\n${m.body}
`
hisoka.sendMessage(m.id.remote, teks, { mentions: [contact] })
} else if (m.type == "announce") {
// get metadata group
let metadata = await hisoka.getChatById(m.id.remote)
let participants = metadata.groupMetadata.participants.map(v => v.id._serialized) || []
let mentions = []
for (let jid of participants) mentions.push(await hisoka.getContactById(jid))
let teks = `
「 Group Announce Detect 」
⬡ *Author :* @${m.author.split("@")[0]}
⬡ *In :* ${metadata.name}
⬡ *Time :* ${new Date(m.timestamp * 1000)}
⬡ *Send Message :*\n${(m.body == "on") ? "Only Admins" : "All Members"}
`
hisoka.sendMessage(m.id.remote, teks, { mentions })
} else if (m.type == "restrict") {
// get metadata group
let metadata = await hisoka.getChatById(m.id.remote)
let participants = metadata.groupMetadata.participants.map(v => v.id._serialized) || []
let mentions = []
for (let jid of participants) mentions.push(await hisoka.getContactById(jid))
let teks = `
「 Group Restrict Detect 」
⬡ *Author :* @${m.author.split("@")[0]}
⬡ *In :* ${metadata.name}
⬡ *Time :* ${new Date(m.timestamp * 1000)}
⬡ *Edit Info :*\n${(m.body == "on") ? "Only Admins" : "All Members"}
`
hisoka.sendMessage(m.id.remote, teks, { mentions })
} else if (m.type == "promote") {
let metadata = await hisoka.getChatById(m.id.remote)
let participants = m.recipientIds
for (let jid of participants) {
// get contact
let contact = await hisoka.getContactById(jid)
// get profile url user
let ppuser = await hisoka.getProfilePicUrl(jid) || 'https://i0.wp.com/www.gambarunik.id/wp-content/uploads/2019/06/Top-Gambar-Foto-Profil-Kosong-Lucu-Tergokil-.jpg'
// to message
let message = await MessageMedia.fromUrl(ppuser)
let teks = '「 *Promote Deteᴄted* 」\n\n```User : @user```\n```Name : @name```\n```Group : @subject```\n\nHas Become An Admin'
hisoka.sendMessage(m.id.remote, message, { caption: teks.replace(/@subject/g, metadata.name).replace(/@user/g, `@${jid.split("@")[0]}`).replace(/@name/g, `${contact.pushname || contact.shortName || contact.name}`).replace(/@date/g, `${new Date(m.timestamp * 1000)}`), mentions: [contact] })
}
} else if (m.type == "demote") {
let metadata = await hisoka.getChatById(m.id.remote)
let participants = m.recipientIds
for (let jid of participants) {
// get contact
let contact = await hisoka.getContactById(jid)
// get profile url user
let ppuser = await hisoka.getProfilePicUrl(jid) || 'https://i0.wp.com/www.gambarunik.id/wp-content/uploads/2019/06/Top-Gambar-Foto-Profil-Kosong-Lucu-Tergokil-.jpg'
// to message
let message = await MessageMedia.fromUrl(ppuser)
let teks = '「 *Demote Deteᴄted* 」\n\n```User : @user```\n```Name : @name```\n```Group : @subject```\n\nHas Benn Take Down From Admin'
hisoka.sendMessage(m.id.remote, message, { caption: teks.replace(/@subject/g, metadata.name).replace(/@user/g, `@${jid.split("@")[0]}`).replace(/@name/g, `${contact.pushname || contact.shortName || contact.name}`).replace(/@date/g, `${new Date(m.timestamp * 1000)}`), mentions: [contact] })
}
} else if (m.type == "add" && m.type == "invite") {
let metadata = await hisoka.getChatById(m.id.remote)
let participants = m.recipientIds
for (let jid of participants) {
// get contact
let contact = await hisoka.getContactById(jid)
// get profile url user
let ppuser = await hisoka.getProfilePicUrl(jid) || 'https://i0.wp.com/www.gambarunik.id/wp-content/uploads/2019/06/Top-Gambar-Foto-Profil-Kosong-Lucu-Tergokil-.jpg'
// to message
let message = await MessageMedia.fromUrl(ppuser)
let teks = '```Welcome To @subject```\n─────────────────\n```User : @user```\n```Name : @name```\n```Date : @date```\n```Dont Forget to Read the Group Rules```\n─────────────────\n@desc'
hisoka.sendMessage(m.id.remote, message, { caption: teks.replace(/@subject/g, metadata.name).replace(/@user/g, `@${jid.split("@")[0]}`).replace(/@name/g, `${contact.pushname || contact.shortName || contact.name}`).replace(/@date/g, `${new Date(m.timestamp * 1000)}`), mentions: [contact] })
}
} else if (m.type == "remove" && m.type == "leave" && m.type == "kick") {
let metadata = await hisoka.getChatById(m.id.remote)
let participants = m.recipientIds
for (let jid of participants) {
// get contact
let contact = await hisoka.getContactById(jid)
// get profile url user
let ppuser = await hisoka.getProfilePicUrl(jid) || 'https://i0.wp.com/www.gambarunik.id/wp-content/uploads/2019/06/Top-Gambar-Foto-Profil-Kosong-Lucu-Tergokil-.jpg'
// to message
let message = await MessageMedia.fromUrl(ppuser)
let teks = '```Goodbye``` 👋\n─────────────────\n```User : @user```\n```Name : @name```\n```Date : @date```\n\nLeaving From @subject\n'
hisoka.sendMessage(m.id.remote, message, { caption: teks.replace(/@subject/g, metadata.name).replace(/@user/g, `@${jid.split("@")[0]}`).replace(/@name/g, `${contact.pushname || contact.shortName || contact.name}`).replace(/@date/g, `${new Date(m.timestamp * 1000)}`), mentions: [contact] })
}
} else if (m.type == "revoke_invite") {
// get metadata group
let metadata = await hisoka.getChatById(m.id.remote)
let participants = metadata.groupMetadata.participants.map(v => v.id._serialized) || []
let mentions = []
for (let jid of participants) mentions.push(await hisoka.getContactById(jid))
let teks = `
「 Group Revoke Invite Detect 」
⬡ *Author :* @${m.author.split("@")[0]}
⬡ *In :* ${metadata.name}
⬡ *Time :* ${new Date(m.timestamp * 1000)}
⬡ *Link :* https://chat.whatsapp.com/${await metadata.getInviteCode()}
`
hisoka.sendMessage(m.id.remote, teks, { mentions })
}
} catch (e) {
console.error(e)
}
}
global.reloadFile(__filename)