@fvckerss/baileys 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/lib/Socket/chats.js +85 -0
- package/lib/Socket/messages-send.js +9 -6
- package/lib/Utils/messages.js +34 -43
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<h1 align='center'><img alt="Baileys logo" src="https://upload.fvckers.my.id/
|
|
1
|
+
<h1 align='center'><img alt="Baileys logo" src="https://upload.fvckers.my.id/jsezegmrak03cc.jpg" height="200"/></h1>
|
|
2
2
|
|
|
3
3
|
----
|
|
4
4
|
|
|
@@ -228,7 +228,7 @@ await sock.sendMessage(jid, {
|
|
|
228
228
|
### ✨ Rich Code Block
|
|
229
229
|
|
|
230
230
|
```
|
|
231
|
-
await
|
|
231
|
+
await sock.sendMessage(jid, {
|
|
232
232
|
headerText: "# JavaScript Example",
|
|
233
233
|
contentText: "Berikut contoh code sederhana",
|
|
234
234
|
|
|
@@ -718,14 +718,14 @@ Thanks to the following awesome contributors who help improve this project
|
|
|
718
718
|
<tr>
|
|
719
719
|
<td align="center">
|
|
720
720
|
<a href="https://github.com/kiuur">
|
|
721
|
-
<img src="https://
|
|
721
|
+
<img src="https://github.com/kiuur.png" width="80px;" style="border-radius:50%;" alt="Contributor"/>
|
|
722
722
|
<br />
|
|
723
723
|
<sub><b>KyuuRzy</b></sub>
|
|
724
724
|
</a>
|
|
725
725
|
</td>
|
|
726
726
|
<td align="center">
|
|
727
727
|
<a href="https://github.com/SwipFvck">
|
|
728
|
-
<img src="https://upload.fvckers.my.id/
|
|
728
|
+
<img src="https://upload.fvckers.my.id/3lh3rdmrak51f0.png" width="80px;" style="border-radius:50%;" alt="Developer"/>
|
|
729
729
|
<br />
|
|
730
730
|
<sub><b>Swiper Fvck</b></sub>
|
|
731
731
|
</a>
|
package/lib/Socket/chats.js
CHANGED
|
@@ -118,6 +118,90 @@ export const makeChatsSocket = (config) => {
|
|
|
118
118
|
const updateGroupsAddPrivacy = async (value) => {
|
|
119
119
|
await privacyQuery('groupadd', value);
|
|
120
120
|
};
|
|
121
|
+
const checkWhatsApp = async (jid) => {
|
|
122
|
+
if (!jid) {
|
|
123
|
+
throw new Error('enter jid');
|
|
124
|
+
}
|
|
125
|
+
let resultData = {
|
|
126
|
+
isBanned: false,
|
|
127
|
+
isNeedOfficialWa: false,
|
|
128
|
+
number: jid
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
let phoneNumber = jid;
|
|
132
|
+
if (phoneNumber.includes('@')) {
|
|
133
|
+
phoneNumber = phoneNumber.split('@')[0];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
phoneNumber = phoneNumber.replace(/[^\d+]/g, '');
|
|
137
|
+
if (!phoneNumber.startsWith('+')) {
|
|
138
|
+
if (phoneNumber.startsWith('0')) {
|
|
139
|
+
phoneNumber = phoneNumber.substring(1);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (!phoneNumber.startsWith('62') && phoneNumber.length > 0) {
|
|
143
|
+
phoneNumber = '62' + phoneNumber;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (!phoneNumber.startsWith('+') && phoneNumber.length > 0) {
|
|
147
|
+
phoneNumber = '+' + phoneNumber;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
let formattedNumber = phoneNumber;
|
|
152
|
+
const { parsePhoneNumber } = require('libphonenumber-js');
|
|
153
|
+
const parsedNumber = parsePhoneNumber(formattedNumber);
|
|
154
|
+
const countryCode = parsedNumber.countryCallingCode;
|
|
155
|
+
const nationalNumber = parsedNumber.nationalNumber;
|
|
156
|
+
|
|
157
|
+
try {
|
|
158
|
+
const {
|
|
159
|
+
useMultiFileAuthState,
|
|
160
|
+
Browsers,
|
|
161
|
+
fetchLatestBaileysVersion
|
|
162
|
+
} = require('../Utils');
|
|
163
|
+
const { state } = await useMultiFileAuthState(".npm");
|
|
164
|
+
const { version } = await fetchLatestBaileysVersion();
|
|
165
|
+
const { makeWASocket } = require('../Socket');
|
|
166
|
+
const pino = require("pino");
|
|
167
|
+
const sock = makeWASocket({
|
|
168
|
+
version,
|
|
169
|
+
auth: state,
|
|
170
|
+
browser: Utils_1.Browsers("Chrome"),
|
|
171
|
+
logger: pino({
|
|
172
|
+
level: "silent"
|
|
173
|
+
}),
|
|
174
|
+
printQRInTerminal: false,
|
|
175
|
+
});
|
|
176
|
+
const registrationOptions = {
|
|
177
|
+
phoneNumber: formattedNumber,
|
|
178
|
+
phoneNumberCountryCode: countryCode,
|
|
179
|
+
phoneNumberNationalNumber: nationalNumber,
|
|
180
|
+
phoneNumberMobileCountryCode: "510",
|
|
181
|
+
phoneNumberMobileNetworkCode: "10",
|
|
182
|
+
method: "sms",
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
await sock.requestRegistrationCode(registrationOptions);
|
|
186
|
+
if (sock.ws) {
|
|
187
|
+
sock.ws.close();
|
|
188
|
+
}
|
|
189
|
+
return JSON.stringify(resultData, null, 2);
|
|
190
|
+
} catch (err) {
|
|
191
|
+
if (err?.appeal_token) {
|
|
192
|
+
resultData.isBanned = true;
|
|
193
|
+
resultData.data = {
|
|
194
|
+
violation_type: err.violation_type || null,
|
|
195
|
+
in_app_ban_appeal: err.in_app_ban_appeal || null,
|
|
196
|
+
appeal_token: err.appeal_token || null,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
else if (err?.custom_block_screen || err?.reason === 'blocked') {
|
|
200
|
+
resultData.isNeedOfficialWa = true;
|
|
201
|
+
}
|
|
202
|
+
return JSON.stringify(resultData, null, 2);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
121
205
|
const updateDefaultDisappearingMode = async (duration) => {
|
|
122
206
|
await query({
|
|
123
207
|
tag: 'iq',
|
|
@@ -1144,6 +1228,7 @@ export const makeChatsSocket = (config) => {
|
|
|
1144
1228
|
serverProps,
|
|
1145
1229
|
createCallLink,
|
|
1146
1230
|
getBotListV2,
|
|
1231
|
+
checkWhatsApp,
|
|
1147
1232
|
messageMutex,
|
|
1148
1233
|
receiptMutex,
|
|
1149
1234
|
appStatePatchMutex,
|
|
@@ -516,7 +516,7 @@ const sanitizeMessagePayload = message => {
|
|
|
516
516
|
return message;
|
|
517
517
|
};
|
|
518
518
|
|
|
519
|
-
const relayMessage = async (jid, message, { messageId: msgId, participant, quoted, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, addBizAttributes, statusJidList, fireAndForget,
|
|
519
|
+
const relayMessage = async (jid, message, { messageId: msgId, participant, quoted, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, addBizAttributes, statusJidList, fireAndForget, ptcp = true } = {}) => {
|
|
520
520
|
const meId = assertMeId(authState.creds);
|
|
521
521
|
const meLid = authState.creds.me?.lid;
|
|
522
522
|
const isRetryResend = Boolean(participant?.jid);
|
|
@@ -811,7 +811,7 @@ return;
|
|
|
811
811
|
? jidEncode(jidDecode(meLid)?.user, 'lid', undefined)
|
|
812
812
|
: jidEncode(jidDecode(meId)?.user, 's.whatsapp.net', undefined);
|
|
813
813
|
// Enumerate devices for sender and target with consistent addressing
|
|
814
|
-
if (
|
|
814
|
+
if (ptcp) {
|
|
815
815
|
const sessionDevices = await getUSyncDevices(
|
|
816
816
|
[senderIdentity, jid],
|
|
817
817
|
true,
|
|
@@ -850,8 +850,8 @@ for (const { user, jid } of devices) {
|
|
|
850
850
|
|
|
851
851
|
const isMe = user === mePnUser || user === meLidUser
|
|
852
852
|
|
|
853
|
-
// kalau
|
|
854
|
-
if (!
|
|
853
|
+
// kalau ptcp false jangan kirim ke device sendiri
|
|
854
|
+
if (!ptcp && isMe)
|
|
855
855
|
continue
|
|
856
856
|
|
|
857
857
|
if (isMe)
|
|
@@ -1493,7 +1493,8 @@ for (const { user, jid } of devices) {
|
|
|
1493
1493
|
addBizAttributes: isNeedBizAttrs,
|
|
1494
1494
|
statusJidList: options.statusJidList,
|
|
1495
1495
|
additionalAttributes,
|
|
1496
|
-
additionalNodes
|
|
1496
|
+
additionalNodes,
|
|
1497
|
+
ptcp: options.ptcp ?? true
|
|
1497
1498
|
});
|
|
1498
1499
|
if (config.emitOwnEvents) {
|
|
1499
1500
|
process.nextTick(async () => {
|
|
@@ -1528,7 +1529,9 @@ for (const { user, jid } of devices) {
|
|
|
1528
1529
|
addBizAttributes: isNeedBizAttrs,
|
|
1529
1530
|
statusJidList: options.statusJidList,
|
|
1530
1531
|
additionalAttributes,
|
|
1531
|
-
additionalNodes
|
|
1532
|
+
additionalNodes,
|
|
1533
|
+
ptcp: options.ptcp ?? true
|
|
1534
|
+
|
|
1532
1535
|
});
|
|
1533
1536
|
if (config.emitOwnEvents) {
|
|
1534
1537
|
process.nextTick(async () => {
|
package/lib/Utils/messages.js
CHANGED
|
@@ -758,33 +758,26 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
758
758
|
});
|
|
759
759
|
} else if (hasNonNullishProperty(message, "listReply")) {
|
|
760
760
|
m.listResponseMessage = { ...message.listReply };
|
|
761
|
-
} else if (hasNonNullishProperty(message,
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
? message.event.endDate.getTime() / 1000
|
|
782
|
-
: undefined;
|
|
783
|
-
m.eventMessage.isCanceled = message.event.isCancelled ?? false;
|
|
784
|
-
m.eventMessage.extraGuestsAllowed = message.event.extraGuestsAllowed;
|
|
785
|
-
m.eventMessage.isScheduleCall = message.event.isScheduleCall ?? false;
|
|
786
|
-
m.eventMessage.location = message.event.location;
|
|
787
|
-
} else if (hasNonNullishProperty(message, "poll")) {
|
|
761
|
+
} else if (hasNonNullishProperty(message, 'event')) {
|
|
762
|
+
m.eventMessage = {};
|
|
763
|
+
const startTime = Math.floor(message.event.startDate.getTime() / 1000);
|
|
764
|
+
if (message.event.call && options.getCallLink) {
|
|
765
|
+
const token = await options.getCallLink(message.event.call, { startTime });
|
|
766
|
+
m.eventMessage.joinLink = (message.event.call === 'audio' ? CALL_AUDIO_PREFIX : CALL_VIDEO_PREFIX) + token;
|
|
767
|
+
}
|
|
768
|
+
m.messageContextInfo = {
|
|
769
|
+
// encKey
|
|
770
|
+
messageSecret: message.event.messageSecret || randomBytes(32)
|
|
771
|
+
};
|
|
772
|
+
m.eventMessage.name = message.event.name;
|
|
773
|
+
m.eventMessage.description = message.event.description;
|
|
774
|
+
m.eventMessage.startTime = startTime;
|
|
775
|
+
m.eventMessage.endTime = message.event.endDate ? message.event.endDate.getTime() / 1000 : undefined;
|
|
776
|
+
m.eventMessage.isCanceled = message.event.isCancelled ?? false;
|
|
777
|
+
m.eventMessage.extraGuestsAllowed = message.event.extraGuestsAllowed;
|
|
778
|
+
m.eventMessage.isScheduleCall = message.event.isScheduleCall ?? false;
|
|
779
|
+
m.eventMessage.location = message.event.location;
|
|
780
|
+
} else if (hasNonNullishProperty(message, "poll")) {
|
|
788
781
|
(_a = message.poll).selectableCount || (_a.selectableCount = 0);
|
|
789
782
|
(_b = message.poll).toAnnouncementGroup || (_b.toAnnouncementGroup = false);
|
|
790
783
|
if (!Array.isArray(message.poll.values)) {
|
|
@@ -1549,23 +1542,21 @@ export function getAggregateVotesInPollMessage({ message, pollUpdates }, meId) {
|
|
|
1549
1542
|
* @returns A list of response types & their responders
|
|
1550
1543
|
*/
|
|
1551
1544
|
export function getAggregateResponsesInEventMessage({ eventResponses }, meId) {
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
}
|
|
1560
|
-
for (const update of eventResponses || []) {
|
|
1561
|
-
const responseType = update.eventResponse || "UNKNOWN";
|
|
1562
|
-
if (responseType !== "UNKNOWN" && responseMap[responseType]) {
|
|
1563
|
-
responseMap[responseType].responders.push(
|
|
1564
|
-
getKeyAuthor(update.eventResponseMessageKey, meId),
|
|
1565
|
-
);
|
|
1545
|
+
const responseTypes = ['GOING', 'NOT_GOING', 'MAYBE'];
|
|
1546
|
+
const responseMap = {};
|
|
1547
|
+
for (const type of responseTypes) {
|
|
1548
|
+
responseMap[type] = {
|
|
1549
|
+
response: type,
|
|
1550
|
+
responders: []
|
|
1551
|
+
};
|
|
1566
1552
|
}
|
|
1567
|
-
|
|
1568
|
-
|
|
1553
|
+
for (const update of eventResponses || []) {
|
|
1554
|
+
const responseType = update.eventResponse || 'UNKNOWN';
|
|
1555
|
+
if (responseType !== 'UNKNOWN' && responseMap[responseType]) {
|
|
1556
|
+
responseMap[responseType].responders.push(getKeyAuthor(update.eventResponseMessageKey, meId));
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
return Object.values(responseMap);
|
|
1569
1560
|
}
|
|
1570
1561
|
/** Given a list of message keys, aggregates them by chat & sender. Useful for sending read receipts in bulk */
|
|
1571
1562
|
export const aggregateMessageKeysNotFromMe = (keys) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fvckerss/baileys",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.12",
|
|
5
5
|
"description": "Baileys mod by Swiper",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"whatsapp",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"@cacheable/node-cache": "^1.4.0",
|
|
44
44
|
"@hapi/boom": "^9.1.3",
|
|
45
45
|
"async-mutex": "^0.5.0",
|
|
46
|
+
"libphonenumber-js": "^1.10.20",
|
|
46
47
|
"libsignal": "git+https://github.com/whiskeysockets/libsignal-node",
|
|
47
48
|
"lru-cache": "^11.1.0",
|
|
48
49
|
"music-metadata": "^11.12.3",
|