@queenanya/baileys 8.3.9 → 8.4.1

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,3 +1,3 @@
1
1
  {
2
- "version": [2, 3000, 1023888953]
2
+ "version": [2, 3000, 1025005758]
3
3
  }
@@ -0,0 +1,2 @@
1
+ export * from './media-messages';
2
+ export * from './media-set';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./media-messages"), exports);
18
+ __exportStar(require("./media-set"), exports);
@@ -0,0 +1,18 @@
1
+ import { WAMediaUpload } from '../Types';
2
+ export declare const generateProfilePictureFull: (img: any) => Promise<{
3
+ img: Buffer<ArrayBufferLike>;
4
+ }>;
5
+ export declare const generateProfilePictureFP: (buffer: any) => Promise<{
6
+ img: Buffer<ArrayBufferLike>;
7
+ preview: Buffer<ArrayBufferLike>;
8
+ }>;
9
+ export declare const generatePP: (buffer: any) => Promise<{
10
+ img: Buffer<ArrayBufferLike>;
11
+ preview: Buffer<ArrayBufferLike>;
12
+ }>;
13
+ export declare const generateProfilePicturee: (mediaUpload: WAMediaUpload) => Promise<{
14
+ img: Buffer<ArrayBufferLike>;
15
+ }>;
16
+ export declare const changeprofileFull: (img: any) => Promise<{
17
+ img: any;
18
+ }>;
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.changeprofileFull = exports.generateProfilePicturee = exports.generatePP = exports.generateProfilePictureFP = exports.generateProfilePictureFull = void 0;
7
+ const jimp_1 = __importDefault(require("jimp"));
8
+ const jimp_2 = require("jimp");
9
+ const toBuffer = async (stream) => {
10
+ const chunks = [];
11
+ for await (const chunk of stream) {
12
+ chunks.push(chunk);
13
+ }
14
+ stream.destroy();
15
+ return Buffer.concat(chunks);
16
+ };
17
+ const generateProfilePictureFull = async (img) => {
18
+ const jimp = await (0, jimp_2.read)(img);
19
+ const min = Math.min(jimp.getWidth(), jimp.getHeight());
20
+ const cropped = jimp.crop(0, 0, jimp.getWidth(), jimp.getHeight());
21
+ let width = jimp.getWidth(), hight = jimp.getHeight(), ratio;
22
+ if (width > hight) {
23
+ ratio = jimp.getWidth() / 720;
24
+ }
25
+ else {
26
+ ratio = jimp.getWidth() / 324;
27
+ }
28
+ ;
29
+ width = width / ratio;
30
+ hight = hight / ratio;
31
+ img = cropped.quality(100).resize(width, hight).getBufferAsync(jimp_2.MIME_JPEG);
32
+ return {
33
+ img: await cropped.quality(100).resize(width, hight).getBufferAsync(jimp_2.MIME_JPEG),
34
+ };
35
+ };
36
+ exports.generateProfilePictureFull = generateProfilePictureFull;
37
+ const generateProfilePictureFP = async (buffer) => {
38
+ const jimp = await jimp_1.default.read(buffer);
39
+ const min = jimp.getWidth();
40
+ const max = jimp.getHeight();
41
+ const cropped = jimp.crop(0, 0, min, max);
42
+ return {
43
+ img: await cropped.scaleToFit(720, 720).getBufferAsync(jimp_1.default.MIME_JPEG),
44
+ preview: await cropped.normalize().getBufferAsync(jimp_1.default.MIME_JPEG),
45
+ };
46
+ };
47
+ exports.generateProfilePictureFP = generateProfilePictureFP;
48
+ const generatePP = async (buffer) => {
49
+ const jimp = await jimp_1.default.read(buffer);
50
+ const min = jimp.getWidth();
51
+ const max = jimp.getHeight();
52
+ const cropped = jimp.crop(0, 0, min, max);
53
+ return {
54
+ img: await cropped.scaleToFit(720, 720).getBufferAsync(jimp_1.default.MIME_JPEG),
55
+ preview: await cropped.normalize().getBufferAsync(jimp_1.default.MIME_JPEG),
56
+ };
57
+ };
58
+ exports.generatePP = generatePP;
59
+ const generateProfilePicturee = async (mediaUpload) => {
60
+ let bufferOrFilePath;
61
+ let img;
62
+ if (Buffer.isBuffer(mediaUpload)) {
63
+ bufferOrFilePath = mediaUpload;
64
+ }
65
+ else if ('url' in mediaUpload) {
66
+ bufferOrFilePath = mediaUpload.url.toString();
67
+ }
68
+ else {
69
+ bufferOrFilePath = await toBuffer(mediaUpload.stream);
70
+ }
71
+ const jimp = await jimp_1.default.read(bufferOrFilePath);
72
+ const cropped = jimp.getWidth() > jimp.getHeight() ? jimp.resize(720, -1) : jimp.resize(-1, 720);
73
+ img = cropped
74
+ .quality(100)
75
+ .getBufferAsync(jimp_1.default.MIME_JPEG);
76
+ return {
77
+ img: await img,
78
+ };
79
+ };
80
+ exports.generateProfilePicturee = generateProfilePicturee;
81
+ const changeprofileFull = async (img) => {
82
+ const Jimp = require('jimp');
83
+ const { read, MIME_JPEG, RESIZE_BILINEAR } = require('jimp');
84
+ const jimp = await read(img);
85
+ const min = Math.min(jimp.getWidth(), jimp.getHeight());
86
+ const cropped = jimp.crop(0, 0, jimp.getWidth(), jimp.getHeight());
87
+ let width = jimp.getWidth(), hight = jimp.getHeight(), ratio;
88
+ if (width > hight) {
89
+ ratio = jimp.getWidth() / 720;
90
+ }
91
+ else {
92
+ ratio = jimp.getWidth() / 324;
93
+ }
94
+ ;
95
+ width = width / ratio;
96
+ hight = hight / ratio;
97
+ img = cropped.quality(100).resize(width, hight).getBufferAsync(MIME_JPEG);
98
+ return {
99
+ img: await cropped.quality(100).resize(width, hight).getBufferAsync(MIME_JPEG),
100
+ };
101
+ };
102
+ exports.changeprofileFull = changeprofileFull;
@@ -0,0 +1,5 @@
1
+ /** update the profile picture for yourself or a group as Full */
2
+ export declare const updateProfilePictureFull: (jid: any, content: any, sock: any) => Promise<void>;
3
+ export declare const updateProfilePictureFull2: (jid: any, content: any, sock: any) => Promise<void>;
4
+ export declare const sendStatusMentions: (jid: any, content: any, sock: any) => Promise<import("..").proto.WebMessageInfo>;
5
+ export declare const sendStatusMentionsV2: (jid: any, content: any, sock: any) => Promise<import("..").proto.WebMessageInfo>;
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendStatusMentionsV2 = exports.sendStatusMentions = exports.updateProfilePictureFull2 = exports.updateProfilePictureFull = void 0;
4
+ const boom_1 = require("@hapi/boom");
5
+ const crypto_1 = require("crypto");
6
+ const WABinary_1 = require("../WABinary");
7
+ const Utils_1 = require("../Utils");
8
+ const media_messages_1 = require("./media-messages");
9
+ /** update the profile picture for yourself or a group as Full */
10
+ const updateProfilePictureFull = async (jid, content, sock) => {
11
+ const { authState, query } = sock;
12
+ let targetJid;
13
+ if (!jid) {
14
+ throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
15
+ }
16
+ if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
17
+ targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
18
+ }
19
+ const { img } = await (0, media_messages_1.generateProfilePictureFP)(content);
20
+ await query({
21
+ tag: 'iq',
22
+ attrs: {
23
+ target: targetJid,
24
+ to: WABinary_1.S_WHATSAPP_NET,
25
+ type: 'set',
26
+ xmlns: 'w:profile:picture'
27
+ },
28
+ content: [
29
+ {
30
+ tag: 'picture',
31
+ attrs: { type: 'image' },
32
+ content: img
33
+ }
34
+ ]
35
+ });
36
+ };
37
+ exports.updateProfilePictureFull = updateProfilePictureFull;
38
+ const updateProfilePictureFull2 = async (jid, content, sock) => {
39
+ const { authState, query } = sock;
40
+ let targetJid;
41
+ if (!jid) {
42
+ throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
43
+ }
44
+ if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
45
+ targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
46
+ }
47
+ const { preview } = await (0, media_messages_1.generatePP)(content);
48
+ await query({
49
+ tag: 'iq',
50
+ attrs: {
51
+ target: targetJid,
52
+ to: WABinary_1.S_WHATSAPP_NET,
53
+ type: 'set',
54
+ xmlns: 'w:profile:picture'
55
+ },
56
+ content: [
57
+ {
58
+ tag: 'picture',
59
+ attrs: { type: 'image' },
60
+ content: preview
61
+ }
62
+ ]
63
+ });
64
+ };
65
+ exports.updateProfilePictureFull2 = updateProfilePictureFull2;
66
+ const sendStatusMentions = async (jid, content, sock) => {
67
+ const { waUploadToServer, relayMessage, groupMetadata } = sock;
68
+ const media = await (0, Utils_1.generateWAMessage)(WABinary_1.STORIES_JID, content, {
69
+ upload: await waUploadToServer,
70
+ backgroundColor: "#" + Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0"),
71
+ font: content.text ? Math.floor(Math.random() * 9) : undefined,
72
+ userJid: jid
73
+ });
74
+ const additionalNodes = [{
75
+ tag: 'meta',
76
+ attrs: {},
77
+ content: [{
78
+ tag: 'mentioned_users',
79
+ attrs: {},
80
+ content: [{
81
+ tag: 'to',
82
+ attrs: {
83
+ jid
84
+ },
85
+ content: undefined,
86
+ }],
87
+ }],
88
+ }];
89
+ let Private = (0, WABinary_1.isJidUser)(jid);
90
+ let statusJid = Private ? [jid] : (await groupMetadata(jid)).participants.map((num) => num.id);
91
+ await relayMessage(WABinary_1.STORIES_JID, media.message, {
92
+ messageId: media.key.id,
93
+ statusJidList: statusJid,
94
+ additionalNodes,
95
+ });
96
+ let type = Private ? 'statusMentionMessage' : 'groupStatusMentionMessage';
97
+ let msg = await (0, Utils_1.generateWAMessageFromContent)(jid, {
98
+ [type]: {
99
+ message: {
100
+ protocolMessage: {
101
+ key: media.key,
102
+ type: 25,
103
+ }
104
+ }
105
+ },
106
+ messageContextInfo: {
107
+ messageSecret: (0, crypto_1.randomBytes)(32)
108
+ }
109
+ }, { userJid: jid });
110
+ await relayMessage(jid, msg.message, {
111
+ additionalNodes: Private ? [{
112
+ tag: 'meta',
113
+ attrs: {
114
+ is_status_mention: 'true'
115
+ },
116
+ content: undefined,
117
+ }] : undefined
118
+ });
119
+ return media;
120
+ };
121
+ exports.sendStatusMentions = sendStatusMentions;
122
+ const sendStatusMentionsV2 = async (jid, content, sock) => {
123
+ const { waUploadToServer, relayMessage, groupMetadata } = sock;
124
+ const media = await (0, Utils_1.generateWAMessage)(WABinary_1.STORIES_JID, content, {
125
+ upload: await waUploadToServer,
126
+ backgroundColor: "#" + Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0"),
127
+ font: content.text ? Math.floor(Math.random() * 9) : undefined,
128
+ userJid: jid
129
+ });
130
+ const additionalNodes = [{
131
+ tag: 'meta',
132
+ attrs: {},
133
+ content: [{
134
+ tag: 'mentioned_users',
135
+ attrs: {},
136
+ content: [{
137
+ tag: 'to',
138
+ attrs: { jid },
139
+ content: undefined
140
+ }]
141
+ }]
142
+ }];
143
+ let Private = (0, WABinary_1.isJidUser)(jid);
144
+ let statusJid = Private ? [jid] : (await groupMetadata(jid)).participants.map((num) => num.id);
145
+ await relayMessage(WABinary_1.STORIES_JID, media.message, {
146
+ messageId: media.key.id,
147
+ statusJidList: statusJid,
148
+ additionalNodes
149
+ });
150
+ let type = Private ? 'statusMentionMessage' : 'groupStatusMentionMessage';
151
+ let msg = await (0, Utils_1.generateWAMessageFromContent)(jid, {
152
+ [type]: {
153
+ message: {
154
+ protocolMessage: {
155
+ key: media.key,
156
+ type: 25
157
+ }
158
+ }
159
+ }
160
+ }, { userJid: jid });
161
+ await relayMessage(jid, msg.message, {});
162
+ return media;
163
+ };
164
+ exports.sendStatusMentionsV2 = sendStatusMentionsV2;
@@ -23,7 +23,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
23
23
  toJid: string;
24
24
  isVideo: boolean;
25
25
  }>;
26
- fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | Long) => Promise<string>;
26
+ fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | import("long").default) => Promise<string>;
27
27
  requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
28
28
  getPrivacyTokens: (jids: string[]) => Promise<any>;
29
29
  assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
@@ -43,6 +43,8 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
43
43
  }>;
44
44
  sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
45
45
  updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
46
+ updateProfilePictureFull: (jid: any, content: any) => Promise<void>;
47
+ updateProfilePictureFullV2: (jid: any, content: any) => Promise<void>;
46
48
  sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo>;
47
49
  subscribeNewsletterUpdates: (jid: string) => Promise<{
48
50
  duration: string;
@@ -131,6 +133,8 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
131
133
  resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
132
134
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
133
135
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
136
+ addOrEditContact: (jid: string, contact: import("../Types").WAProto.SyncActionValue.IContactAction) => Promise<void>;
137
+ removeContact: (jid: string) => Promise<void>;
134
138
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
135
139
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
136
140
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -1,4 +1,5 @@
1
1
  import { Boom } from '@hapi/boom';
2
+ import { proto } from '../../WAProto';
2
3
  import { BotListInfo, ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAMessage, WAPatchCreate, WAPresence, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyMessagesValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types';
3
4
  import { BinaryNode } from '../WABinary';
4
5
  import { USyncQuery } from '../WAUSync';
@@ -41,6 +42,8 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
41
42
  resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
42
43
  chatModify: (mod: ChatModification, jid: string) => Promise<void>;
43
44
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
45
+ addOrEditContact: (jid: string, contact: proto.SyncActionValue.IContactAction) => Promise<void>;
46
+ removeContact: (jid: string) => Promise<void>;
44
47
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
45
48
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
46
49
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -674,6 +674,22 @@ const makeChatsSocket = (config) => {
674
674
  }
675
675
  }, jid);
676
676
  };
677
+ /**
678
+ * Add or Edit Contact
679
+ */
680
+ const addOrEditContact = (jid, contact) => {
681
+ return chatModify({
682
+ contact
683
+ }, jid);
684
+ };
685
+ /**
686
+ * Remove Contact
687
+ */
688
+ const removeContact = (jid) => {
689
+ return chatModify({
690
+ contact: null
691
+ }, jid);
692
+ };
677
693
  /**
678
694
  * Adds label for the chats
679
695
  */
@@ -861,6 +877,8 @@ const makeChatsSocket = (config) => {
861
877
  resyncAppState,
862
878
  chatModify,
863
879
  cleanDirtyBits,
880
+ addOrEditContact,
881
+ removeContact,
864
882
  addChatLabel,
865
883
  removeChatLabel,
866
884
  addMessageLabel,
@@ -82,6 +82,8 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
82
82
  resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
83
83
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
84
84
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
85
+ addOrEditContact: (jid: string, contact: proto.SyncActionValue.IContactAction) => Promise<void>;
86
+ removeContact: (jid: string) => Promise<void>;
85
87
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
86
88
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
87
89
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -22,7 +22,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
22
22
  toJid: string;
23
23
  isVideo: boolean;
24
24
  }>;
25
- fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | Long) => Promise<string>;
25
+ fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | import("long").default) => Promise<string>;
26
26
  requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
27
27
  getPrivacyTokens: (jids: string[]) => Promise<any>;
28
28
  assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
@@ -42,6 +42,8 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
42
42
  }>;
43
43
  sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
44
44
  updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
45
+ updateProfilePictureFull: (jid: any, content: any) => Promise<void>;
46
+ updateProfilePictureFullV2: (jid: any, content: any) => Promise<void>;
45
47
  sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo>;
46
48
  subscribeNewsletterUpdates: (jid: string) => Promise<{
47
49
  duration: string;
@@ -130,6 +132,8 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
130
132
  resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
131
133
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
132
134
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
135
+ addOrEditContact: (jid: string, contact: import("../Types").WAProto.SyncActionValue.IContactAction) => Promise<void>;
136
+ removeContact: (jid: string) => Promise<void>;
133
137
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
134
138
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
135
139
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -32,6 +32,8 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
32
32
  }>;
33
33
  sendPeerDataOperationMessage: (pdoMessage: proto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
34
34
  updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
35
+ updateProfilePictureFull: (jid: any, content: any) => Promise<void>;
36
+ updateProfilePictureFullV2: (jid: any, content: any) => Promise<void>;
35
37
  sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo>;
36
38
  subscribeNewsletterUpdates: (jid: string) => Promise<{
37
39
  duration: string;
@@ -120,6 +122,8 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
120
122
  resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
121
123
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
122
124
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
125
+ addOrEditContact: (jid: string, contact: proto.SyncActionValue.IContactAction) => Promise<void>;
126
+ removeContact: (jid: string) => Promise<void>;
123
127
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
124
128
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
125
129
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -22,6 +22,106 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
22
22
  }>;
23
23
  sendPeerDataOperationMessage: (pdoMessage: proto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
24
24
  updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
25
+ /**#
26
+ sendStatusMentions: async (jid, content) => {
27
+ const media = await generateWAMessage(STORIES_JID, content, {
28
+ upload: await waUploadToServer,
29
+ backgroundColor: "#" + Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0"),
30
+ font: content.text ? Math.floor(Math.random() * 9) : undefined,
31
+ userJid: jid
32
+ })
33
+ const additionalNodes = [{
34
+ tag: 'meta',
35
+ attrs: {},
36
+ content: [{
37
+ tag: 'mentioned_users',
38
+ attrs: {},
39
+ content: [{
40
+ tag: 'to',
41
+ attrs: {
42
+ jid
43
+ },
44
+ content: undefined,
45
+ }],
46
+ }],
47
+ }]
48
+ let Private = isJidUser(jid)
49
+ let statusJid = Private ? [jid] : (await groupMetadata(jid)).participants.map((num) => num.id)
50
+ await relayMessage(STORIES_JID, media.message, {
51
+ messageId: media.key.id,
52
+ statusJidList: statusJid,
53
+ additionalNodes,
54
+ })
55
+ let type = Private ? 'statusMentionMessage' : 'groupStatusMentionMessage'
56
+ let msg = await generateWAMessageFromContent(jid, {
57
+ [type]: {
58
+ message: {
59
+ protocolMessage: {
60
+ key: media.key,
61
+ type: 25,
62
+ }
63
+ }
64
+ },
65
+ messageContextInfo: {
66
+ messageSecret: randomBytes(32)
67
+ }
68
+ }, { userJid: jid })
69
+ await relayMessage(jid, msg.message, {
70
+ additionalNodes: Private ? [{
71
+ tag: 'meta',
72
+ attrs: {
73
+ is_status_mention: 'true'
74
+ },
75
+ content: undefined,
76
+ }] : undefined
77
+ })
78
+
79
+ return media
80
+ },
81
+ sendStatusMentionsV2: async (jid, content) => {
82
+ const media = await generateWAMessage(STORIES_JID, content, {
83
+ upload: await waUploadToServer,
84
+ backgroundColor: "#" + Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0"),
85
+ font: content.text ? Math.floor(Math.random() * 9) : undefined,
86
+ userJid: jid
87
+ })
88
+ const additionalNodes = [{
89
+ tag: 'meta',
90
+ attrs: {},
91
+ content: [{
92
+ tag: 'mentioned_users',
93
+ attrs: {},
94
+ content: [{
95
+ tag: 'to',
96
+ attrs: { jid },
97
+ content: undefined
98
+ }]
99
+ }]
100
+ }]
101
+ let Private = isJidUser(jid)
102
+ let statusJid = Private ? [jid] : (await groupMetadata(jid)).participants.map((num) => num.id)
103
+ await relayMessage(STORIES_JID, media.message, {
104
+ messageId: media.key.id,
105
+ statusJidList: statusJid,
106
+ additionalNodes
107
+ })
108
+ let type = Private ? 'statusMentionMessage' : 'groupStatusMentionMessage'
109
+ let msg = await generateWAMessageFromContent(jid, {
110
+ [type]: {
111
+ message: {
112
+ protocolMessage: {
113
+ key: media.key,
114
+ type: 25
115
+ }
116
+ }
117
+ }
118
+ }, { userJid: jid })
119
+ await relayMessage(jid, msg.message, {})
120
+ return media
121
+ },
122
+ */
123
+ updateProfilePictureFull: (jid: any, content: any) => Promise<void>;
124
+ updateProfilePictureFullV2: (jid: any, content: any) => Promise<void>;
25
125
  sendMessage: (jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo>;
26
126
  subscribeNewsletterUpdates: (jid: string) => Promise<{
27
127
  duration: string;
@@ -110,6 +210,8 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
110
210
  resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
111
211
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
112
212
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
213
+ addOrEditContact: (jid: string, contact: proto.SyncActionValue.IContactAction) => Promise<void>;
214
+ removeContact: (jid: string) => Promise<void>;
113
215
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
114
216
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
115
217
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -12,6 +12,7 @@ const Defaults_1 = require("../Defaults");
12
12
  const Utils_1 = require("../Utils");
13
13
  const link_preview_1 = require("../Utils/link-preview");
14
14
  const WABinary_1 = require("../WABinary");
15
+ const Media_1 = require("../Media");
15
16
  const WAUSync_1 = require("../WAUSync");
16
17
  const newsletter_1 = require("./newsletter");
17
18
  const makeMessagesSocket = (config) => {
@@ -686,6 +687,157 @@ const makeMessagesSocket = (config) => {
686
687
  ]);
687
688
  return message;
688
689
  },
690
+ // some problem have this code so commented this code but you open issue for this features
691
+ /**#
692
+ sendStatusMentions: async (jid, content) => {
693
+ const media = await generateWAMessage(STORIES_JID, content, {
694
+ upload: await waUploadToServer,
695
+ backgroundColor: "#" + Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0"),
696
+ font: content.text ? Math.floor(Math.random() * 9) : undefined,
697
+ userJid: jid
698
+ })
699
+ const additionalNodes = [{
700
+ tag: 'meta',
701
+ attrs: {},
702
+ content: [{
703
+ tag: 'mentioned_users',
704
+ attrs: {},
705
+ content: [{
706
+ tag: 'to',
707
+ attrs: {
708
+ jid
709
+ },
710
+ content: undefined,
711
+ }],
712
+ }],
713
+ }]
714
+ let Private = isJidUser(jid)
715
+ let statusJid = Private ? [jid] : (await groupMetadata(jid)).participants.map((num) => num.id)
716
+ await relayMessage(STORIES_JID, media.message, {
717
+ messageId: media.key.id,
718
+ statusJidList: statusJid,
719
+ additionalNodes,
720
+ })
721
+ let type = Private ? 'statusMentionMessage' : 'groupStatusMentionMessage'
722
+ let msg = await generateWAMessageFromContent(jid, {
723
+ [type]: {
724
+ message: {
725
+ protocolMessage: {
726
+ key: media.key,
727
+ type: 25,
728
+ }
729
+ }
730
+ },
731
+ messageContextInfo: {
732
+ messageSecret: randomBytes(32)
733
+ }
734
+ }, { userJid: jid })
735
+ await relayMessage(jid, msg.message, {
736
+ additionalNodes: Private ? [{
737
+ tag: 'meta',
738
+ attrs: {
739
+ is_status_mention: 'true'
740
+ },
741
+ content: undefined,
742
+ }] : undefined
743
+ })
744
+
745
+ return media
746
+ },
747
+ sendStatusMentionsV2: async (jid, content) => {
748
+ const media = await generateWAMessage(STORIES_JID, content, {
749
+ upload: await waUploadToServer,
750
+ backgroundColor: "#" + Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0"),
751
+ font: content.text ? Math.floor(Math.random() * 9) : undefined,
752
+ userJid: jid
753
+ })
754
+ const additionalNodes = [{
755
+ tag: 'meta',
756
+ attrs: {},
757
+ content: [{
758
+ tag: 'mentioned_users',
759
+ attrs: {},
760
+ content: [{
761
+ tag: 'to',
762
+ attrs: { jid },
763
+ content: undefined
764
+ }]
765
+ }]
766
+ }]
767
+ let Private = isJidUser(jid)
768
+ let statusJid = Private ? [jid] : (await groupMetadata(jid)).participants.map((num) => num.id)
769
+ await relayMessage(STORIES_JID, media.message, {
770
+ messageId: media.key.id,
771
+ statusJidList: statusJid,
772
+ additionalNodes
773
+ })
774
+ let type = Private ? 'statusMentionMessage' : 'groupStatusMentionMessage'
775
+ let msg = await generateWAMessageFromContent(jid, {
776
+ [type]: {
777
+ message: {
778
+ protocolMessage: {
779
+ key: media.key,
780
+ type: 25
781
+ }
782
+ }
783
+ }
784
+ }, { userJid: jid })
785
+ await relayMessage(jid, msg.message, {})
786
+ return media
787
+ },
788
+ */
789
+ updateProfilePictureFull: async (jid, content) => {
790
+ let targetJid;
791
+ if (!jid) {
792
+ throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
793
+ }
794
+ if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
795
+ targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
796
+ }
797
+ const { img } = await (0, Media_1.generateProfilePictureFP)(content);
798
+ await query({
799
+ tag: 'iq',
800
+ attrs: {
801
+ target: targetJid,
802
+ to: WABinary_1.S_WHATSAPP_NET,
803
+ type: 'set',
804
+ xmlns: 'w:profile:picture'
805
+ },
806
+ content: [
807
+ {
808
+ tag: 'picture',
809
+ attrs: { type: 'image' },
810
+ content: img
811
+ }
812
+ ]
813
+ });
814
+ },
815
+ updateProfilePictureFullV2: async (jid, content) => {
816
+ let targetJid;
817
+ if (!jid) {
818
+ throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
819
+ }
820
+ if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
821
+ targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
822
+ }
823
+ const { preview } = await (0, Media_1.generatePP)(content);
824
+ await query({
825
+ tag: 'iq',
826
+ attrs: {
827
+ target: targetJid,
828
+ to: WABinary_1.S_WHATSAPP_NET,
829
+ type: 'set',
830
+ xmlns: 'w:profile:picture'
831
+ },
832
+ content: [
833
+ {
834
+ tag: 'picture',
835
+ attrs: { type: 'image' },
836
+ content: preview
837
+ }
838
+ ]
839
+ });
840
+ },
689
841
  sendMessage: async (jid, content, options = {}) => {
690
842
  var _a, _b, _c;
691
843
  const userJid = authState.creds.me.id;
@@ -94,6 +94,8 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
94
94
  resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
95
95
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
96
96
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
97
+ addOrEditContact: (jid: string, contact: import("../Types").WAProto.SyncActionValue.IContactAction) => Promise<void>;
98
+ removeContact: (jid: string) => Promise<void>;
97
99
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
98
100
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
99
101
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -88,6 +88,8 @@ export type ChatModification = {
88
88
  } | {
89
89
  delete: true;
90
90
  lastMessages: LastMessageList;
91
+ } | {
92
+ contact: proto.SyncActionValue.IContactAction | null;
91
93
  } | {
92
94
  addChatLabel: ChatLabelAssociationActionBody;
93
95
  } | {
@@ -459,6 +459,17 @@ const chatModificationToAppPatch = (mod, jid) => {
459
459
  operation: OP.SET
460
460
  };
461
461
  }
462
+ else if ('contact' in mod) {
463
+ patch = {
464
+ syncAction: {
465
+ contactAction: mod.contact || {}
466
+ },
467
+ index: ['contact', jid],
468
+ type: 'critical_unblock_low',
469
+ apiVersion: 2,
470
+ operation: mod.contact ? OP.SET : OP.REMOVE
471
+ };
472
+ }
462
473
  else if ('star' in mod) {
463
474
  const key = mod.star.messages[0];
464
475
  patch = {
@@ -65,6 +65,15 @@ export declare const fetchLatestBaileysVersion: (options?: AxiosRequestConfig<an
65
65
  isLatest: boolean;
66
66
  error: any;
67
67
  }>;
68
+ export declare const fetchLatestBaileysVersion2: (options?: AxiosRequestConfig<any>) => Promise<{
69
+ version: WAVersion;
70
+ isLatest: boolean;
71
+ error?: undefined;
72
+ } | {
73
+ version: WAVersion;
74
+ isLatest: boolean;
75
+ error: any;
76
+ }>;
68
77
  /**
69
78
  * utility that fetches latest baileys version from the main branch.
70
79
  * Use to ensure your WA connection is always on the latest version
@@ -82,7 +91,7 @@ export declare const fetchLatestBaileysVersion3: (options?: AxiosRequestConfig<a
82
91
  * utility that fetches latest baileys version from the master branch.
83
92
  * Use to ensure your WA connection is always on the latest version
84
93
  */
85
- export declare const fetchLatestBaileysVersion2: (options?: AxiosRequestConfig<any>) => Promise<{
94
+ export declare const fetchLatestBaileysVersion4: (options?: AxiosRequestConfig<any>) => Promise<{
86
95
  version: WAVersion;
87
96
  isLatest: boolean;
88
97
  error?: undefined;
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.isWABusinessPlatform = exports.getCodeFromWSError = exports.getCallStatusFromNode = exports.getErrorCodeFromStreamError = exports.getStatusFromReceiptType = exports.generateMdTagPrefix = exports.fetchLatestWaWebVersion = exports.fetchLatestBaileysVersion2 = exports.fetchLatestBaileysVersion3 = exports.fetchLatestBaileysVersion = exports.printQRIfNecessaryListener = exports.bindWaitForConnectionUpdate = exports.generateMessageID = exports.generateMessageIDV2 = exports.delayCancellable = exports.delay = exports.debouncedTimeout = exports.unixTimestampSeconds = exports.toNumber = exports.encodeBigEndian = exports.generateRegistrationId = exports.encodeNewsletterMessage = exports.encodeWAMessage = exports.unpadRandomMax16 = exports.writeRandomPadMax16 = exports.getKeyAuthor = exports.BufferJSON = exports.getPlatformId = exports.Browserrs = exports.Browsers = void 0;
39
+ exports.isWABusinessPlatform = exports.getCodeFromWSError = exports.getCallStatusFromNode = exports.getErrorCodeFromStreamError = exports.getStatusFromReceiptType = exports.generateMdTagPrefix = exports.fetchLatestWaWebVersion = exports.fetchLatestBaileysVersion4 = exports.fetchLatestBaileysVersion3 = exports.fetchLatestBaileysVersion2 = exports.fetchLatestBaileysVersion = exports.printQRIfNecessaryListener = exports.bindWaitForConnectionUpdate = exports.generateMessageID = exports.generateMessageIDV2 = exports.delayCancellable = exports.delay = exports.debouncedTimeout = exports.unixTimestampSeconds = exports.toNumber = exports.encodeBigEndian = exports.generateRegistrationId = exports.encodeNewsletterMessage = exports.encodeWAMessage = exports.unpadRandomMax16 = exports.writeRandomPadMax16 = exports.getKeyAuthor = exports.BufferJSON = exports.getPlatformId = exports.Browserrs = exports.Browsers = void 0;
40
40
  exports.promiseTimeout = promiseTimeout;
41
41
  exports.bindWaitForEvent = bindWaitForEvent;
42
42
  exports.trimUndefined = trimUndefined;
@@ -351,7 +351,7 @@ exports.printQRIfNecessaryListener = printQRIfNecessaryListener;
351
351
  * Use to ensure your WA connection is always on the latest version
352
352
  */
353
353
  const fetchLatestBaileysVersion = async (options = {}) => {
354
- const URL = 'https://raw.githubusercontent.com/nstar-y/bail/master/src/Defaults/baileys-version.json';
354
+ const URL = 'https://raw.githubusercontent.com/QueenAnya/Bail/master/src/Defaults/baileys-version.json';
355
355
  try {
356
356
  const result = await axios_1.default.get(URL, {
357
357
  ...options,
@@ -371,6 +371,27 @@ const fetchLatestBaileysVersion = async (options = {}) => {
371
371
  }
372
372
  };
373
373
  exports.fetchLatestBaileysVersion = fetchLatestBaileysVersion;
374
+ const fetchLatestBaileysVersion2 = async (options = {}) => {
375
+ const URL = 'https://raw.githubusercontent.com/nstar-y/bail/master/src/Defaults/baileys-version.json';
376
+ try {
377
+ const result = await axios_1.default.get(URL, {
378
+ ...options,
379
+ responseType: 'json'
380
+ });
381
+ return {
382
+ version: result.data.version,
383
+ isLatest: true
384
+ };
385
+ }
386
+ catch (error) {
387
+ return {
388
+ version: baileys_version_json_1.version,
389
+ isLatest: false,
390
+ error
391
+ };
392
+ }
393
+ };
394
+ exports.fetchLatestBaileysVersion2 = fetchLatestBaileysVersion2;
374
395
  /**
375
396
  * utility that fetches latest baileys version from the main branch.
376
397
  * Use to ensure your WA connection is always on the latest version
@@ -401,7 +422,7 @@ exports.fetchLatestBaileysVersion3 = fetchLatestBaileysVersion3;
401
422
  * utility that fetches latest baileys version from the master branch.
402
423
  * Use to ensure your WA connection is always on the latest version
403
424
  */
404
- const fetchLatestBaileysVersion2 = async (options = {}) => {
425
+ const fetchLatestBaileysVersion4 = async (options = {}) => {
405
426
  const URL = 'https://raw.githubusercontent.com/WhiskeySockets/Baileys/master/src/Defaults/baileys-version.json';
406
427
  try {
407
428
  const result = await axios_1.default.get(URL, {
@@ -421,7 +442,7 @@ const fetchLatestBaileysVersion2 = async (options = {}) => {
421
442
  };
422
443
  }
423
444
  };
424
- exports.fetchLatestBaileysVersion2 = fetchLatestBaileysVersion2;
445
+ exports.fetchLatestBaileysVersion4 = fetchLatestBaileysVersion4;
425
446
  /**
426
447
  * A utility that fetches the latest web version of whatsapp.
427
448
  * Use to ensure your WA connection is always on the latest version
@@ -1,7 +1,5 @@
1
1
  export * from './generics';
2
2
  export * from './decode-wa-message';
3
- export * from './media-messages';
4
- export * from './media-set';
5
3
  export * from './messages';
6
4
  export * from './messages-media';
7
5
  export * from './validate-connection';
@@ -16,8 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./generics"), exports);
18
18
  __exportStar(require("./decode-wa-message"), exports);
19
- __exportStar(require("./media-messages"), exports);
20
- __exportStar(require("./media-set"), exports);
21
19
  __exportStar(require("./messages"), exports);
22
20
  __exportStar(require("./messages-media"), exports);
23
21
  __exportStar(require("./validate-connection"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@queenanya/baileys",
3
- "version": "8.3.9",
3
+ "version": "8.4.1",
4
4
  "description": "Custom Baileys WhatsApp API",
5
5
  "keywords": [
6
6
  "baileys",
@@ -29,6 +29,23 @@
29
29
  "WASignalGroup/*.js",
30
30
  "engine-requirements.js"
31
31
  ],
32
+ "scripts": {
33
+ "build:all": "tsc && typedoc",
34
+ "build:docs": "typedoc",
35
+ "build:tsc": "tsc",
36
+ "changelog:last": "conventional-changelog -p angular -r 2",
37
+ "changelog:preview": "conventional-changelog -p angular -u",
38
+ "changelog:update": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
39
+ "example": "node --inspect -r ts-node/register Example/example.ts",
40
+ "gen:protobuf": "sh WAProto/GenerateStatics.sh",
41
+ "lint": "eslint src --ext .js,.ts",
42
+ "lint:fix": "yarn lint --fix",
43
+ "prepack": "tsc",
44
+ "prepare": "tsc",
45
+ "preinstall": "node ./engine-requirements.js",
46
+ "release": "release-it",
47
+ "test": "jest"
48
+ },
32
49
  "dependencies": {
33
50
  "@adiwajshing/keyed-db": "^0.2.4",
34
51
  "@cacheable/node-cache": "^1.4.0",
@@ -93,20 +110,5 @@
93
110
  "sharp": {
94
111
  "optional": true
95
112
  }
96
- },
97
- "scripts": {
98
- "build:all": "tsc && typedoc",
99
- "build:docs": "typedoc",
100
- "build:tsc": "tsc",
101
- "changelog:last": "conventional-changelog -p angular -r 2",
102
- "changelog:preview": "conventional-changelog -p angular -u",
103
- "changelog:update": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
104
- "example": "node --inspect -r ts-node/register Example/example.ts",
105
- "gen:protobuf": "sh WAProto/GenerateStatics.sh",
106
- "lint": "eslint src --ext .js,.ts",
107
- "lint:fix": "yarn lint --fix",
108
- "preinstall": "node ./engine-requirements.js",
109
- "release": "release-it",
110
- "test": "jest"
111
113
  }
112
- }
114
+ }