@realvare/based 2.7.55 → 2.7.56

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 CHANGED
@@ -593,33 +593,95 @@ await conn.sendMessage(jid, {
593
593
  ```
594
594
 
595
595
  #### Advanced Media
596
+
596
597
  ```typescript
597
598
  // Album (Multiple images)
598
599
  await conn.sendMessage(jid, {
599
600
  album: imageBuffers.map(buffer => ({ image: buffer })),
600
601
  caption: 'ts gettin real'
601
602
  });
603
+ ```
604
+
605
+ #### Stickers
602
606
 
603
- // Sticker
607
+ Sending stickers is supported. You can send a sticker from a URL or a buffer. For creating stickers from images, you can use an external library like `wa-sticker-formatter`.
608
+
609
+ ```typescript
610
+ // Sticker from URL
604
611
  await conn.sendMessage(jid, {
605
612
  sticker: { url: './stickers/sticker.webp' }
606
613
  });
607
614
 
608
- // Location message
609
- await conn.sendMessage(jid, {
610
- location: {
611
- degreesLatitude: 45.4642,
612
- degreesLongitude: 9.1900,
613
- name: "Milano",
614
- address: "Piazza del Duomo, Milano"
615
- }
616
- });
615
+ // Sticker from buffer using wa-sticker-formatter
616
+ const { Sticker } = require('wa-sticker-formatter'); // Optional external library
617
+ const sticker = new Sticker('path/to/image.jpg', { pack: 'My Pack', author: 'My Bot' });
618
+ const buffer = await sticker.toBuffer();
619
+ await conn.sendMessage(jid, { sticker: buffer });
620
+ ```
621
+
622
+ ##### Sticker Packs
623
+
624
+ While WhatsApp supports installable sticker packs, Baileys (and this fork) does not have a native feature to create or send a pack as a single multi-sticker message (`StickerPackMessage`). This is a requested feature in Baileys (see issues [#1548](https://github.com/WhiskeySockets/Baileys/issues/1548)), but not yet implemented.
625
+
626
+ However, the library provides a way to send a sticker pack by sending a metadata message followed by the individual stickers. This simulates a sticker pack in the chat.
627
+
628
+ Here is how you can send a sticker pack:
629
+
630
+ ```typescript
631
+ import { Sticker } from 'wa-sticker-formatter';
632
+
633
+ const sticker1 = new Sticker('path/to/image1.png', { pack: 'My Sticker Pack', author: 'Me' });
634
+ const sticker2 = new Sticker('path/to/image2.png', { pack: 'My Sticker Pack', author: 'Me' });
635
+
636
+ const stickerPack = {
637
+ name: 'My Sticker Pack',
638
+ publisher: 'My Bot',
639
+ description: 'A cool sticker pack',
640
+ cover: 'path/to/cover.png', // or a buffer
641
+ stickers: [
642
+ {
643
+ sticker: await sticker1.toBuffer(),
644
+ emojis: ['🎉', '🎊'],
645
+ },
646
+ {
647
+ sticker: await sticker2.toBuffer(),
648
+ emojis: ['😄', '😊'],
649
+ }
650
+ ]
651
+ };
652
+
653
+ await conn.sendMessage(jid, { stickerPack: stickerPack });
654
+ ```
655
+
656
+ Alternatively, you can simulate a pack by sending multiple stickers in sequence with a small delay between them:
657
+
658
+ ```typescript
659
+ // Simulate a pack by sending multiple stickers
660
+ const stickers = ['sticker1.webp', 'sticker2.webp'];
661
+ for (const url of stickers) {
662
+ await conn.sendMessage(jid, { sticker: { url } });
663
+ await new Promise(resolve => setTimeout(resolve, 500)); // Small delay
664
+ }
665
+ ```
666
+ To create actual sticker packs that users can install, you should use external tools like the official WhatsApp Sticker Maker app. You can then integrate the individual stickers into your bot.
667
+
668
+ ##### Stickers on Status (2025 Feature)
669
+
670
+ The new interactive stickers on Status (e.g., with lyrics or questions) can be sent by sending a sticker to `status@broadcast`.
671
+
672
+ ```typescript
673
+ await conn.sendMessage('status@broadcast', {
674
+ sticker: { url: './sticker.webp' },
675
+ caption: 'Interactive sticker on Status'
676
+ }, { statusJidList: ['user1@s.whatsapp.net', 'user2@s.whatsapp.net'] });
617
677
  ```
618
678
 
619
679
  #### Interactive Messages
620
- These messages include interactive elements like buttons, lists, and templates.
680
+
681
+ These messages include interactive elements like buttons, lists, and polls.
621
682
 
622
683
  ##### Messages with Simple Buttons
684
+
623
685
  Send quick reply buttons.
624
686
 
625
687
  ```typescript
@@ -627,15 +689,16 @@ await conn.sendMessage(jid, {
627
689
  text: 'Choose an option:',
628
690
  footer: 'Footer',
629
691
  buttons: [
630
- { buttonId: 'cmd1', buttonText: { displayText: 'text1' }, type: 1 },
631
- { buttonId: 'cmd2', buttonText: { displayText: 'text2' }, type: 1 },
692
+ { buttonId: 'cmd1', buttonText: { displayText: 'Option 1' }, type: 1 },
693
+ { buttonId: 'cmd2', buttonText: { displayText: 'Option 2' }, type: 1 },
632
694
  ],
633
695
  headerType: 1,
634
696
  });
635
697
  ```
636
698
 
637
699
  ##### Messages with Buttons and Image
638
- Combine image with buttons.
700
+
701
+ Combine an image with buttons.
639
702
 
640
703
  ```typescript
641
704
  await conn.sendMessage(jid, {
@@ -649,7 +712,8 @@ await conn.sendMessage(jid, {
649
712
  ```
650
713
 
651
714
  ##### List Messages
652
- Send a list of options (only in private).
715
+
716
+ Send a list of options (only in private chats).
653
717
 
654
718
  ```typescript
655
719
  await conn.sendMessage(jid, {
@@ -669,6 +733,29 @@ await conn.sendMessage(jid, {
669
733
  });
670
734
  ```
671
735
 
736
+ ##### Poll Messages
737
+
738
+ Create a poll for users to vote on.
739
+
740
+ ```typescript
741
+ await conn.sendMessage(jid, {
742
+ poll: {
743
+ name: 'Favorite Anime?',
744
+ values: ['Aot', 'Bleach', 'Death note'],
745
+ selectableCount: 1 // or >1 for multi-select
746
+ }
747
+ });
748
+ ```
749
+
750
+ #### New Interactive Features (2025)
751
+
752
+ WhatsApp introduced several new features in 2025. Here's how to handle them with Baileys:
753
+
754
+ - **Missed Call Messages**: Baileys is primarily for messaging and does not handle calls. To approximate this feature, you could potentially listen for call events (if supported) and then send a voice or video note as a follow-up message.
755
+ - **Interactive Stickers on Status**: As shown in the sticker section, you can send stickers to `status@broadcast` with an interactive caption.
756
+ - **AI-Generated Images**: This is not a native Baileys feature. You need to integrate an external AI image generation API (like Meta AI), generate the image, and then send it as a regular image message.
757
+ - **Advanced Interactive Messages**: Features like "native flow" are partially supported in some forks (see issue [#398](https://github.com/WhiskeySockets/Baileys/issues/398)).
758
+
672
759
  #### Other Messages
673
760
  ```typescript
674
761
  // Message with quote
@@ -677,6 +764,16 @@ await conn.sendMessage(jid, {
677
764
  quoted: quotedMessage // The message to quote/reply/cite
678
765
  });
679
766
 
767
+ // Location message
768
+ await conn.sendMessage(jid, {
769
+ location: {
770
+ degreesLatitude: 45.4642,
771
+ degreesLongitude: 9.1900,
772
+ name: "Milano",
773
+ address: "Piazza del Duomo, Milano"
774
+ }
775
+ });
776
+
680
777
  // Contact Messages
681
778
  await conn.sendMessage(jid, {
682
779
  contacts: {
@@ -685,15 +782,6 @@ await conn.sendMessage(jid, {
685
782
  }
686
783
  });
687
784
 
688
- // Poll Messages (Survey)
689
- await conn.sendMessage(jid, {
690
- poll: {
691
- name: 'Favorite Anime?',
692
- values: ['Aot', 'Bleach', 'Death note'],
693
- selectableCount: 1 // how many choices possible
694
- }
695
- });
696
-
697
785
  // Ephemeral Messages (Self-Destructing)
698
786
  await conn.sendMessage(jid, {
699
787
  text: "This message will self-destruct {hopefully like israel}"
@@ -43,7 +43,7 @@ exports.DEFAULT_CONNECTION_CONFIG = {
43
43
  defaultQueryTimeoutMs: 60000,
44
44
  customUploadHosts: [],
45
45
  retryRequestDelayMs: 250,
46
- maxMsgRetryCount: 5,
46
+ maxMsgRetryCount: 10,
47
47
  fireInitQueries: true,
48
48
  auth: undefined,
49
49
  markOnlineOnConnect: false,
@@ -79,6 +79,7 @@ const makeMessagesRecvSocket = (config) => {
79
79
  }
80
80
  };
81
81
  const offerCall = async (toJid, isVideo = false) => {
82
+ toJid = resolveJid(toJid);
82
83
  const callId = (0, crypto_1.randomBytes)(16).toString('hex').toUpperCase().substring(0, 64);
83
84
  const offerContent = [];
84
85
  offerContent.push({ tag: 'audio', attrs: { enc: 'opus', rate: '16000' }, content: undefined });
@@ -137,6 +138,7 @@ const makeMessagesRecvSocket = (config) => {
137
138
  };
138
139
  };
139
140
  const rejectCall = async (callId, callFrom) => {
141
+ callFrom = resolveJid(callFrom);
140
142
  const stanza = ({
141
143
  tag: 'call',
142
144
  attrs: {
@@ -421,7 +423,9 @@ const makeMessagesRecvSocket = (config) => {
421
423
  action = 'demote';
422
424
  contentPath = content.data[Types_1.XWAPaths.DEMOTE];
423
425
  }
424
- ev.emit('newsletter-participants.update', { id, author: contentPath.actor.pn, user: contentPath.user.pn, new_role: contentPath.user_new_role, action });
426
+ const author = resolveJid(contentPath.actor.pn);
427
+ const user = resolveJid(contentPath.user.pn);
428
+ ev.emit('newsletter-participants.update', { id, author, user, new_role: contentPath.user_new_role, action });
425
429
  }
426
430
  if (operation === Types_1.MexOperations.UPDATE) {
427
431
  contentPath = content.data[Types_1.XWAPaths.METADATA_UPDATE];
@@ -809,7 +813,7 @@ const makeMessagesRecvSocket = (config) => {
809
813
  msg.messageStubParameters = [Utils_1.NO_MESSAGE_FOUND_ERROR_TEXT, response];
810
814
  }
811
815
  if (((_c = (_b = msg.message) === null || _b === void 0 ? void 0 : _b.protocolMessage) === null || _c === void 0 ? void 0 : _c.type) === WAProto_1.proto.Message.ProtocolMessage.Type.SHARE_PHONE_NUMBER && node.attrs.sender_pn) {
812
- ev.emit('chats.phoneNumberShare', { lid: node.attrs.from, jid: node.attrs.sender_pn });
816
+ ev.emit('chats.phoneNumberShare', { lid: resolveJid(node.attrs.from), jid: resolveJid(node.attrs.sender_pn) });
813
817
  }
814
818
  try {
815
819
  await Promise.all([
@@ -971,15 +975,15 @@ const makeMessagesRecvSocket = (config) => {
971
975
  // current hypothesis is that if pash is sent in the ack
972
976
  // it means -- the message hasn't reached all devices yet
973
977
  // we'll retry sending the message here
974
- if (attrs.phash) {
978
+ if (attrs.phash && attrs.class === 'message') {
975
979
  logger.info({ attrs }, 'received phash in ack, resending message...');
976
980
  const cacheKey = `${key.remoteJid}:${key.id}`;
977
- if ((msgRetryCache.get(cacheKey) || 0) >= maxMsgRetryCount) {
981
+ const retryCount = msgRetryCache.get(cacheKey) || 0;
982
+ if (retryCount >= maxMsgRetryCount) {
978
983
  logger.warn({ attrs }, 'reached max retry count, not sending message again');
979
984
  msgRetryCache.del(cacheKey);
980
985
  return;
981
986
  }
982
- const retryCount = msgRetryCache.get(cacheKey) || 0;
983
987
  const msg = await getMessage(key);
984
988
  if (msg) {
985
989
  await relayMessage(key.remoteJid, msg, { messageId: key.id, useUserDevicesCache: false });
@@ -1113,8 +1117,8 @@ const makeMessagesRecvSocket = (config) => {
1113
1117
  } else if (connection === 'open') {
1114
1118
  sendActiveReceipts = true;
1115
1119
  }
1116
- if (typeof update.isOnline !== 'undefined') {
1117
- sendActiveReceipts = update.isOnline;
1120
+ if (typeof update.isOnline !== 'undefined' && update.isOnline) {
1121
+ sendActiveReceipts = true;
1118
1122
  logger.trace(`sendActiveReceipts set to "${sendActiveReceipts}"`);
1119
1123
  }
1120
1124
  });
@@ -990,6 +990,21 @@ const makeMessagesSocket = (config) => {
990
990
  }
991
991
  };
992
992
 
993
+ // Helper function to send missed call note
994
+ const sendMissedCallNote = async (jid, media, options = {}) => {
995
+ const prepared = await prepareWAMessageMedia(media, { upload: sock.waUploadToServer });
996
+ return sock.sendMessage(jid, {
997
+ ...prepared,
998
+ ptt: !!media.audio,
999
+ contextInfo: {
1000
+ externalAdReply: {
1001
+ title: 'Missed Call Note',
1002
+ body: options.callInfo?.id ? `From call ${options.callInfo.id}` : 'Recent call'
1003
+ }
1004
+ }
1005
+ });
1006
+ };
1007
+
993
1008
  return {
994
1009
  ...sock,
995
1010
  getPrivacyTokens,
@@ -1004,6 +1019,7 @@ const makeMessagesSocket = (config) => {
1004
1019
  getUSyncDevices,
1005
1020
  createParticipantNodes,
1006
1021
  sendPeerDataOperationMessage,
1022
+ sendMissedCallNote,
1007
1023
  updateMediaMessage: async (message) => {
1008
1024
  const content = (0, Utils_1.assertMediaContent)(message.message);
1009
1025
  const mediaKey = content.mediaKey;
@@ -1098,4 +1114,4 @@ const makeMessagesSocket = (config) => {
1098
1114
  }
1099
1115
  };
1100
1116
  };
1101
- exports.makeMessagesSocket = makeMessagesSocket;
1117
+ exports.makeMessagesSocket = makeMessagesSocket;
@@ -25,6 +25,22 @@ export type WATextMessage = proto.Message.IExtendedTextMessage;
25
25
  export type WAContextInfo = proto.IContextInfo;
26
26
  export type WALocationMessage = proto.Message.ILocationMessage;
27
27
  export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
28
+ export interface StickerPackMessage {
29
+ name: string;
30
+ publisher: string;
31
+ description?: string;
32
+ cover?: WAMediaUpload;
33
+ stickers: Sticker[];
34
+ }
35
+ export interface Sticker {
36
+ sticker: WAMediaUpload;
37
+ emojis?: string[];
38
+ isAnimated?: boolean;
39
+ isLottie?: boolean;
40
+ fileName?: string;
41
+ accessibilityLabel?: string;
42
+ mimetype?: string;
43
+ }
28
44
  export declare const WAMessageStubType: typeof proto.WebMessageInfo.StubType;
29
45
  export declare const WAMessageStatus: typeof proto.WebMessageInfo.Status;
30
46
  export type WAMediaPayloadURL = {
@@ -300,7 +316,7 @@ export type AnyRegularMessageContent = (({
300
316
  } & Mentionable & Contextable & Interactiveable & Shopable & Cardsable & WithDimensions) | SharePhoneNumber | RequestPhoneNumber | ({
301
317
  album: AlbumMedia[];
302
318
  caption?: string;
303
- } & Mentionable & Contextable & Editable)) & ViewOnce;
319
+ } & Mentionable & Contextable & Editable) | { stickerPack: StickerPackMessage; }) & ViewOnce;
304
320
  export type AnyMessageContent = AnyRegularMessageContent | {
305
321
  forward: WAMessage;
306
322
  force?: boolean;
@@ -535,6 +535,15 @@ const generateWAMessageContent = async (message, options) => {
535
535
  // Aggiungi altri parametri se disponibili
536
536
  ...reqPayment
537
537
  });
538
+
539
+ // Pix adaptation for Brazilian payments
540
+ if (reqPayment.currencyCodeIso4217 === 'BRL' && reqPayment.pixKey) {
541
+ // Embed Pix key in note for dynamic requests
542
+ if (!m.requestPaymentMessage.noteMessage.extendedTextMessage) {
543
+ m.requestPaymentMessage.noteMessage = { extendedTextMessage: { text: '' } };
544
+ }
545
+ m.requestPaymentMessage.noteMessage.extendedTextMessage.text += `\nPix Key: ${reqPayment.pixKey}`;
546
+ }
538
547
  }
539
548
  else if ('sharePhoneNumber' in message) {
540
549
  m.protocolMessage = {
@@ -1194,4 +1203,3 @@ const assertMediaContent = (content) => {
1194
1203
  return mediaContent;
1195
1204
  };
1196
1205
  exports.assertMediaContent = assertMediaContent;
1197
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@realvare/based",
3
- "version": "2.7.55",
3
+ "version": "2.7.56",
4
4
  "description": "whatsapp api by sam",
5
5
  "keywords": [
6
6
  "baileys",
@@ -51,13 +51,14 @@
51
51
  "chalk": "^4.1.2",
52
52
  "cheerio": "^1.1.2",
53
53
  "gradient-string": "^2.0.2",
54
- "jimp": "^1.6.0",
54
+ "jimp": "^0.22.10",
55
55
  "libphonenumber-js": "^1.12.31",
56
56
  "libsignal": "github:realvare/libsignal",
57
57
  "lodash": "^4.17.21",
58
58
  "music-metadata": "^11.7.0",
59
59
  "pino": "^10.1.0",
60
60
  "protobufjs": "^7.5.4",
61
+ "sharp": "^0.33.5",
61
62
  "uuid": "^13.0.0",
62
63
  "ws": "^8.18.3"
63
64
  },