@queenanya/baileys 8.4.0 → 8.4.2

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.
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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 WAMedia_1 = require("../WAMedia");
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, WAMedia_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, WAMedia_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;
@@ -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);
@@ -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);
@@ -1,3 +1,5 @@
1
1
  /** update the profile picture for yourself or a group as Full */
2
2
  export declare const updateProfilePictureFull: (jid: any, content: any, sock: any) => Promise<void>;
3
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;
package/package.json CHANGED
@@ -1,18 +1,11 @@
1
1
  {
2
2
  "name": "@queenanya/baileys",
3
- "version": "8.4.0",
3
+ "version": "8.4.2",
4
4
  "description": "Custom Baileys WhatsApp API",
5
5
  "keywords": [
6
- "baileys",
7
- "baileys-mod",
8
- "wabot",
9
- "whatsapp",
10
- "js-whatsapp",
11
- "whatsapp-api",
12
- "whatsapp-web",
13
- "whatsapp-bot",
14
- "automation",
15
- "multi-device"
6
+ "baileys", "baileys-mod", "wabot", "whatsapp",
7
+ "js-whatsapp", "whatsapp-api", "whatsapp-web", "whatsapp-bot",
8
+ "automation", "multi-device"
16
9
  ],
17
10
  "homepage": "https://github.com/nstar-y/bail",
18
11
  "repository": {
@@ -58,6 +51,7 @@
58
51
  "cheerio": "^1.0.0 || ^1.0.0_rc.12 || ^1.0.0-rc.10",
59
52
  "libphonenumber-js": "^1.10.20",
60
53
  "libsignal": "github:nstar-y/libsignal",
54
+ "link-preview-js": "^3.0.5",
61
55
  "jimp": "^0.22.12",
62
56
  "lodash": "^4.17.21",
63
57
  "music-metadata": "^7.12.3",
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateProfilePictureFull2 = exports.updateProfilePictureFull = void 0;
4
- const boom_1 = require("@hapi/boom");
5
- const WABinary_1 = require("../WABinary");
6
- const media_messages_1 = require("./media-messages");
7
- /** update the profile picture for yourself or a group as Full */
8
- const updateProfilePictureFull = async (jid, content, sock) => {
9
- const { authState, query } = sock;
10
- let targetJid;
11
- if (!jid) {
12
- 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');
13
- }
14
- if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
15
- targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
16
- }
17
- const { img } = await (0, media_messages_1.generateProfilePictureFP)(content);
18
- await query({
19
- tag: 'iq',
20
- attrs: {
21
- target: targetJid,
22
- to: WABinary_1.S_WHATSAPP_NET,
23
- type: 'set',
24
- xmlns: 'w:profile:picture'
25
- },
26
- content: [
27
- {
28
- tag: 'picture',
29
- attrs: { type: 'image' },
30
- content: img
31
- }
32
- ]
33
- });
34
- };
35
- exports.updateProfilePictureFull = updateProfilePictureFull;
36
- const updateProfilePictureFull2 = async (jid, content, sock) => {
37
- const { authState, query } = sock;
38
- let targetJid;
39
- if (!jid) {
40
- 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');
41
- }
42
- if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
43
- targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
44
- }
45
- const { preview } = await (0, media_messages_1.generatePP)(content);
46
- await query({
47
- tag: 'iq',
48
- attrs: {
49
- target: targetJid,
50
- to: WABinary_1.S_WHATSAPP_NET,
51
- type: 'set',
52
- xmlns: 'w:profile:picture'
53
- },
54
- content: [
55
- {
56
- tag: 'picture',
57
- attrs: { type: 'image' },
58
- content: preview
59
- }
60
- ]
61
- });
62
- };
63
- exports.updateProfilePictureFull2 = updateProfilePictureFull2;
File without changes
File without changes