@queenanya/baileys 8.3.2 → 8.3.4
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/Socket/business.d.ts +0 -2
- package/lib/Socket/chats.d.ts +0 -2
- package/lib/Socket/chats.js +3 -3
- package/lib/Socket/groups.d.ts +0 -2
- package/lib/Socket/index.d.ts +0 -2
- package/lib/Socket/messages-recv.d.ts +0 -2
- package/lib/Socket/messages-send.d.ts +0 -2
- package/lib/Socket/newsletter.d.ts +0 -2
- package/lib/Utils/index.d.ts +2 -1
- package/lib/Utils/index.js +2 -1
- package/lib/Utils/media-messages.d.ts +14 -0
- package/lib/Utils/media-messages.js +72 -0
- package/lib/Utils/media-set.d.ts +3 -0
- package/lib/Utils/media-set.js +63 -0
- package/package.json +1 -1
package/lib/Socket/business.d.ts
CHANGED
|
@@ -114,8 +114,6 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
114
114
|
fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
115
115
|
fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
116
116
|
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
117
|
-
updateProfilePictureFull: any;
|
|
118
|
-
updateProfilePictureFull2: any;
|
|
119
117
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
120
118
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
121
119
|
updateProfileName: (name: string) => Promise<void>;
|
package/lib/Socket/chats.d.ts
CHANGED
|
@@ -25,8 +25,6 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
25
25
|
fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
|
|
26
26
|
fetchStatus: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
|
|
27
27
|
updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>;
|
|
28
|
-
updateProfilePictureFull: any;
|
|
29
|
-
updateProfilePictureFull2: any;
|
|
30
28
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
31
29
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
32
30
|
updateProfileName: (name: string) => Promise<void>;
|
package/lib/Socket/chats.js
CHANGED
|
@@ -10,7 +10,7 @@ const WAProto_1 = require("../../WAProto");
|
|
|
10
10
|
const Defaults_1 = require("../Defaults");
|
|
11
11
|
const Types_1 = require("../Types");
|
|
12
12
|
const Utils_1 = require("../Utils");
|
|
13
|
-
|
|
13
|
+
// import { updateProfilePictureFull, updateProfilePictureFull2 } from './chat-set'
|
|
14
14
|
const make_mutex_1 = require("../Utils/make-mutex");
|
|
15
15
|
const process_message_1 = __importDefault(require("../Utils/process-message"));
|
|
16
16
|
const WABinary_1 = require("../WABinary");
|
|
@@ -845,8 +845,8 @@ const makeChatsSocket = (config) => {
|
|
|
845
845
|
fetchDisappearingDuration,
|
|
846
846
|
fetchStatus,
|
|
847
847
|
updateProfilePicture,
|
|
848
|
-
updateProfilePictureFull
|
|
849
|
-
updateProfilePictureFull2
|
|
848
|
+
//updateProfilePictureFull,
|
|
849
|
+
//updateProfilePictureFull2,
|
|
850
850
|
removeProfilePicture,
|
|
851
851
|
updateProfileStatus,
|
|
852
852
|
updateProfileName,
|
package/lib/Socket/groups.d.ts
CHANGED
|
@@ -65,8 +65,6 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
65
65
|
fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
66
66
|
fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
67
67
|
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
68
|
-
updateProfilePictureFull: any;
|
|
69
|
-
updateProfilePictureFull2: any;
|
|
70
68
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
71
69
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
72
70
|
updateProfileName: (name: string) => Promise<void>;
|
package/lib/Socket/index.d.ts
CHANGED
|
@@ -113,8 +113,6 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
113
113
|
fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
114
114
|
fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
115
115
|
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
116
|
-
updateProfilePictureFull: any;
|
|
117
|
-
updateProfilePictureFull2: any;
|
|
118
116
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
119
117
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
120
118
|
updateProfileName: (name: string) => Promise<void>;
|
|
@@ -103,8 +103,6 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
103
103
|
fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
104
104
|
fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
105
105
|
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
106
|
-
updateProfilePictureFull: any;
|
|
107
|
-
updateProfilePictureFull2: any;
|
|
108
106
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
109
107
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
110
108
|
updateProfileName: (name: string) => Promise<void>;
|
|
@@ -93,8 +93,6 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
|
93
93
|
fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
|
|
94
94
|
fetchStatus: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
|
|
95
95
|
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
96
|
-
updateProfilePictureFull: any;
|
|
97
|
-
updateProfilePictureFull2: any;
|
|
98
96
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
99
97
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
100
98
|
updateProfileName: (name: string) => Promise<void>;
|
|
@@ -77,8 +77,6 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
|
77
77
|
fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
78
78
|
fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
79
79
|
updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>;
|
|
80
|
-
updateProfilePictureFull: any;
|
|
81
|
-
updateProfilePictureFull2: any;
|
|
82
80
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
83
81
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
84
82
|
updateProfileName: (name: string) => Promise<void>;
|
package/lib/Utils/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './generics';
|
|
2
2
|
export * from './decode-wa-message';
|
|
3
3
|
export * from './messages';
|
|
4
|
+
export * from './media-messages';
|
|
5
|
+
export * from './media-set';
|
|
4
6
|
export * from './messages-media';
|
|
5
7
|
export * from './validate-connection';
|
|
6
8
|
export * from './crypto';
|
|
@@ -15,4 +17,3 @@ export * from './use-multi-file-auth-state';
|
|
|
15
17
|
export * from './link-preview';
|
|
16
18
|
export * from './event-buffer';
|
|
17
19
|
export * from './process-message';
|
|
18
|
-
export * from './midea-msg';
|
package/lib/Utils/index.js
CHANGED
|
@@ -17,6 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./generics"), exports);
|
|
18
18
|
__exportStar(require("./decode-wa-message"), exports);
|
|
19
19
|
__exportStar(require("./messages"), exports);
|
|
20
|
+
__exportStar(require("./media-messages"), exports);
|
|
21
|
+
__exportStar(require("./media-set"), exports);
|
|
20
22
|
__exportStar(require("./messages-media"), exports);
|
|
21
23
|
__exportStar(require("./validate-connection"), exports);
|
|
22
24
|
__exportStar(require("./crypto"), exports);
|
|
@@ -31,4 +33,3 @@ __exportStar(require("./use-multi-file-auth-state"), exports);
|
|
|
31
33
|
__exportStar(require("./link-preview"), exports);
|
|
32
34
|
__exportStar(require("./event-buffer"), exports);
|
|
33
35
|
__exportStar(require("./process-message"), exports);
|
|
34
|
-
__exportStar(require("./midea-msg"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const generateProfilePictureFull: (img: any) => Promise<{
|
|
2
|
+
img: Buffer<ArrayBufferLike>;
|
|
3
|
+
}>;
|
|
4
|
+
export declare const generateProfilePictureFP: (buffer: any) => Promise<{
|
|
5
|
+
img: Buffer<ArrayBufferLike>;
|
|
6
|
+
preview: Buffer<ArrayBufferLike>;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const generatePP: (buffer: any) => Promise<{
|
|
9
|
+
img: Buffer<ArrayBufferLike>;
|
|
10
|
+
preview: Buffer<ArrayBufferLike>;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const changeprofileFull: (img: any) => Promise<{
|
|
13
|
+
img: any;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,72 @@
|
|
|
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.generatePP = exports.generateProfilePictureFP = exports.generateProfilePictureFull = void 0;
|
|
7
|
+
const jimp_1 = __importDefault(require("jimp"));
|
|
8
|
+
const jimp_2 = require("jimp");
|
|
9
|
+
const generateProfilePictureFull = async (img) => {
|
|
10
|
+
const jimp = await (0, jimp_2.read)(img);
|
|
11
|
+
const min = Math.min(jimp.getWidth(), jimp.getHeight());
|
|
12
|
+
const cropped = jimp.crop(0, 0, jimp.getWidth(), jimp.getHeight());
|
|
13
|
+
let width = jimp.getWidth(), hight = jimp.getHeight(), ratio;
|
|
14
|
+
if (width > hight) {
|
|
15
|
+
ratio = jimp.getWidth() / 720;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
ratio = jimp.getWidth() / 324;
|
|
19
|
+
}
|
|
20
|
+
;
|
|
21
|
+
width = width / ratio;
|
|
22
|
+
hight = hight / ratio;
|
|
23
|
+
img = cropped.quality(100).resize(width, hight).getBufferAsync(jimp_2.MIME_JPEG);
|
|
24
|
+
return {
|
|
25
|
+
img: await cropped.quality(100).resize(width, hight).getBufferAsync(jimp_2.MIME_JPEG),
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
exports.generateProfilePictureFull = generateProfilePictureFull;
|
|
29
|
+
const generateProfilePictureFP = async (buffer) => {
|
|
30
|
+
const jimp = await jimp_1.default.read(buffer);
|
|
31
|
+
const min = jimp.getWidth();
|
|
32
|
+
const max = jimp.getHeight();
|
|
33
|
+
const cropped = jimp.crop(0, 0, min, max);
|
|
34
|
+
return {
|
|
35
|
+
img: await cropped.scaleToFit(720, 720).getBufferAsync(jimp_1.default.MIME_JPEG),
|
|
36
|
+
preview: await cropped.normalize().getBufferAsync(jimp_1.default.MIME_JPEG),
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
exports.generateProfilePictureFP = generateProfilePictureFP;
|
|
40
|
+
const generatePP = async (buffer) => {
|
|
41
|
+
const jimp = await jimp_1.default.read(buffer);
|
|
42
|
+
const min = jimp.getWidth();
|
|
43
|
+
const max = jimp.getHeight();
|
|
44
|
+
const cropped = jimp.crop(0, 0, min, max);
|
|
45
|
+
return {
|
|
46
|
+
img: await cropped.scaleToFit(720, 720).getBufferAsync(jimp_1.default.MIME_JPEG),
|
|
47
|
+
preview: await cropped.normalize().getBufferAsync(jimp_1.default.MIME_JPEG),
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
exports.generatePP = generatePP;
|
|
51
|
+
const changeprofileFull = async (img) => {
|
|
52
|
+
const Jimp = require('jimp');
|
|
53
|
+
const { read, MIME_JPEG, RESIZE_BILINEAR } = require('jimp');
|
|
54
|
+
const jimp = await read(img);
|
|
55
|
+
const min = Math.min(jimp.getWidth(), jimp.getHeight());
|
|
56
|
+
const cropped = jimp.crop(0, 0, jimp.getWidth(), jimp.getHeight());
|
|
57
|
+
let width = jimp.getWidth(), hight = jimp.getHeight(), ratio;
|
|
58
|
+
if (width > hight) {
|
|
59
|
+
ratio = jimp.getWidth() / 720;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
ratio = jimp.getWidth() / 324;
|
|
63
|
+
}
|
|
64
|
+
;
|
|
65
|
+
width = width / ratio;
|
|
66
|
+
hight = hight / ratio;
|
|
67
|
+
img = cropped.quality(100).resize(width, hight).getBufferAsync(MIME_JPEG);
|
|
68
|
+
return {
|
|
69
|
+
img: await cropped.quality(100).resize(width, hight).getBufferAsync(MIME_JPEG),
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
exports.changeprofileFull = changeprofileFull;
|
|
@@ -0,0 +1,63 @@
|
|
|
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.generateProfilePictureFull)(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.generateProfilePictureFP)(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;
|