@queenanya/baileys 8.4.0 → 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.
- package/lib/Media/index.d.ts +2 -0
- package/lib/Media/index.js +18 -0
- package/lib/Media/media-messages.d.ts +18 -0
- package/lib/Media/media-messages.js +102 -0
- package/lib/Media/media-set.d.ts +5 -0
- package/lib/Media/media-set.js +164 -0
- package/lib/Socket/business.d.ts +2 -0
- package/lib/Socket/index.d.ts +2 -0
- package/lib/Socket/messages-recv.d.ts +2 -0
- package/lib/Socket/messages-send.d.ts +100 -0
- package/lib/Socket/messages-send.js +152 -0
- package/lib/Utils/index.d.ts +0 -2
- package/lib/Utils/index.js +0 -2
- package/package.json +1 -1
|
@@ -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;
|
package/lib/Socket/business.d.ts
CHANGED
|
@@ -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;
|
package/lib/Socket/index.d.ts
CHANGED
|
@@ -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 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;
|
package/lib/Utils/index.d.ts
CHANGED
package/lib/Utils/index.js
CHANGED
|
@@ -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);
|