-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.js
More file actions
176 lines (167 loc) · 7.67 KB
/
Copy pathmain.js
File metadata and controls
176 lines (167 loc) · 7.67 KB
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
const {
WAConnection: _WAConnection,
MessageType,
Presence,
Mimetype,
GroupSettingChange,
} = require("@adiwajshing/baileys");
const simple = require("./lib/simple.js");
const WAConnection = simple.WAConnection(_WAConnection);
const fs = require("fs");
const { banner, start, success, getGroupAdmins } = require("./lib/functions");
const { color } = require("./lib/color");
const fetch = require("node-fetch");
const moment = require("moment-timezone");
blocked = [];
require("./index.js");
nocache("./index.js", (module) => console.log(`${module} is now updated!`));
const starts = async (client = new WAConnection()) => {
client.logger.level = "warn";
client.version = [ 2, 2140, 12 ]
client.browserDescription = ["Arasya Ganteng", "Chrome", "3.0"];
console.log(banner.string);
client.on("qr", () => {
console.log(
color("[", "white"),
color("!", "red"),
color("]", "white"),
color("Scan Bang, 20 detik gk di scan angus qr nya")
);
});
fs.existsSync("./session.json") && client.loadAuthInfo("./session.json");
client.on("connecting", () => {
start("2", "Menyambung.....");
});
client.on("open", () => {
success("2", "Tersambung√, Hai owner Jojooo👋");
});
await client.connect({ timeoutMs: 30 * 1000 });
fs.writeFileSync(
"./session.json",
JSON.stringify(client.base64EncodedAuthInfo(), null, "\t")
);
ownerNumber = ["6281319944917@s.whatsapp.net",`6281319944917@s.whatsapp.net`]
dtod = "6281319944917@s.whatsapp.net"
otod = `6281319944917@s.whatsapp.net`
client.on("group-update", async (anu) => {
metdata = await client.groupMetadata(anu.jid);
if (anu.announce == "false") {
teks = `- [ Group Opened ] -\n\n_Group telah dibuka oleh admin_\n_Sekarang semua member bisa mengirim pesan_`;
client.sendMessage(metdata.id, teks, MessageType.text);
console.log(`- [ Group Opened ] - In ${metdata.subject}`);
} else if (anu.announce == "true") {
teks = `- [ Group Closed ] -\n\n_Group telah ditutup oleh admin_\n_Sekarang hanya admin yang dapat mengirim pesan_`;
client.sendMessage(metdata.id, teks, MessageType.text);
console.log(`- [ Group Closed ] - In ${metdata.subject}`);
} else if (!anu.desc == "") {
tag = anu.descOwner.split("@")[0] + "@s.whatsapp.net";
teks = `- [ Group Description Change ] -\n\nDeskripsi Group telah diubah oleh Admin @${
anu.descOwner.split("@")[0]
}\n� Deskripsi Baru : ${anu.desc}`;
client.sendMessage(metdata.id, teks, MessageType.text, {
contextInfo: { mentionedJid: [tag] },
});
console.log(`- [ Group Description Change ] - In ${metdata.subject}`);
} else if (anu.restrict == "false") {
teks = `- [ Group Setting Change ] -\n\nEdit Group info telah dibuka untuk member\nSekarang semua member dapat mengedit info Group Ini`;
client.sendMessage(metdata.id, teks, MessageType.text);
console.log(`- [ Group Setting Change ] - In ${metdata.subject}`);
} else if (anu.restrict == "true") {
teks = `- [ Group Setting Change ] -\n\nEdit Group info telah ditutup untuk member\nSekarang hanya admin group yang dapat mengedit info Group Ini`;
client.sendMessage(metdata.id, teks, MessageType.text);
console.log(`- [ Group Setting Change ] - In ${metdata.subject}`);
}
});
client.on('group-participants-update', async (anu) => {
try {
const mdata = await client.groupMetadata(anu.jid)
mem = anu.participants[0];
console.log(anu)
if (anu.action == 'add') {
num = anu.participants[0]
try {
ppimg = await client.getProfilePicture(`${anu.participants[0].split('@')[0]}@c.us`)
} catch {
ppimg = 'https://telegra.ph/file/733a3f0eba6e9397be110.jpg'
}
if (anu.action == "add" && mem.includes(client.user.jid)) {
client.sendMessage(anu.jid, "Halloo!!\nAssalamualaikum semuaa👋", "conversation");
}
teks = `Haii kak *@${num.split('@')[0]}* ! Selamat Datang Di Grup ${mdata.subject}\nJangan Lupa Intro and following rules Grup❤️`
let buff = await getBuffer(ppimg)
client.sendMessage(mdata.id, buff, MessageType.image, {caption: teks, contextInfo: {"mentionedJid": [num]}})
} else if (anu.action == 'remove') {
num = anu.participants[0]
try {
ppimg = await client.getProfilePicture(`${num.split('@')[0]}@c.us`)
} catch {
ppimg = 'https://telegra.ph/file/733a3f0eba6e9397be110.jpg'
}
teks = `Byeee tod @${num.split('@')[0]}`
let buff = await getBuffer(ppimg)
client.sendMessage(mdata.id, buff, MessageType.image, {caption: teks, contextInfo: {"mentionedJid": [num]}})
}
else if (anu.action == 'promote') {
fkontakk = { key: { fromMe: false, participant: `0@s.whatsapp.net`, ...(anu.jid ? { remoteJid: '6283136505591-1604595598@g.us' } : {})}, message: { "contactMessage":{"displayName": `${mdata.subject}`,"vcard":`BEGIN:VCARD\nVERSION:3.0\nN:2;pemuda;;;\nFN:pemuda\nitem1.TEL;waid=6281319944917:6281319944917\nitem1.X-ABLabel:Mobile\nEND:VCARD` }}}
num = anu.participants[0]
teks = `*P R O M O T E - D E T E C T E D*\nUsername: @${num.split('@')[0]}\nTime : ${moment.tz('Asia/Jakarta').format('DD/MM HH:mm:ss')}\nGroup: ${mdata.subject}\n\nSelamat Yah atas Kenaikan Pangkatnya 🔥`
client.sendMessage(mdata.id, teks, MessageType.text, {contextInfo: {"mentionedJid": [num]}, quoted: fkontakk})
console.log(color('|TRM|'), color(`Promote Member ${num.split('@')[0]} In ${mdata.subject}`, 'cyan'))
}
else if (anu.action == 'demote') {
fkontakk = { key: { fromMe: false, participant: `0@s.whatsapp.net`, ...(anu.jid ? { remoteJid: '6283136505591-1604595598@g.us' } : {})}, message: { "contactMessage":{"displayName": `${mdata.subject}`,"vcard":`BEGIN:VCARD\nVERSION:3.0\nN:2;pemuda;;;\nFN:pemuda\nitem1.TEL;waid=6281319944917:6281319944917\nitem1.X-ABLabel:Mobile\nEND:VCARD` }}}
num = anu.participants[0]
teks = `*D E M O T E - D E T E C T E D*\nUsername: @${num.split('@')[0]}\nTime : ${moment.tz('Asia/Jakarta').format('DD/MM HH:mm:ss')}\nGroup: ${mdata.subject}\n\nMamposs Nggak jadi Admin lagi, mangkanya yg Becuss..!!`
client.sendMessage(mdata.id, teks, MessageType.text, {contextInfo: {"mentionedJid": [num]}, quoted: fkontakk})
console.log(color('|TRM|'), color(`Demote Admin ${num.split('@')[0]} In ${mdata.subject}`, 'cyan'))
}
} catch (e) {
console.log('Error : %s', color(e, 'red'))
}
})
//
client.on("chat-update", async (message) => {
require("./index.js")(client, message);
});
isBattre = "Not Detect"; //
isCharge = "Not Detect"; //
client.on(`CB:action,,battery`, (json) => {
const batteryLevelStr = json[2][0][1].value;
const batterylevel = parseInt(batteryLevelStr);
isBattre = batterylevel + "%";
isCharge = json[2][0][1].live;
});
client.on("CB:Blocklist", (json) => {
if (blocked.length > 2) return;
for (let i of json[1].blocklist) {
blocked.push(i.replace("c.us", "s.whatsapp.net"));
}
});
};
/**
* Uncache if there is file change
* @param {string} module Module name or path
* @param {function} cb <optional>
*/
function nocache(module, cb = () => {}) {
console.log("Module", `'${module}'`, "is now being watched for changes");
fs.watchFile(require.resolve(module), async () => {
await uncache(require.resolve(module));
cb(module);
});
}
/**
* Uncache a module
* @param {string} module Module name or path
*/
function uncache(module = ".") {
return new Promise((resolve, reject) => {
try {
delete require.cache[require.resolve(module)];
resolve();
} catch (e) {
reject(e);
}
});
}
starts();