@queenanya/baileys 8.4.1 → 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.
- package/lib/Socket/messages-send.js +3 -3
- package/package.json +5 -11
- package/lib/Utils/media-messages.d.ts +0 -18
- package/lib/Utils/media-messages.js +0 -102
- package/lib/Utils/media-set.d.ts +0 -3
- package/lib/Utils/media-set.js +0 -63
- /package/lib/{Media → WAMedia}/index.d.ts +0 -0
- /package/lib/{Media → WAMedia}/index.js +0 -0
- /package/lib/{Media → WAMedia}/media-messages.d.ts +0 -0
- /package/lib/{Media → WAMedia}/media-messages.js +0 -0
- /package/lib/{Media → WAMedia}/media-set.d.ts +0 -0
- /package/lib/{Media → WAMedia}/media-set.js +0 -0
|
@@ -12,7 +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
|
|
15
|
+
const WAMedia_1 = require("../WAMedia");
|
|
16
16
|
const WAUSync_1 = require("../WAUSync");
|
|
17
17
|
const newsletter_1 = require("./newsletter");
|
|
18
18
|
const makeMessagesSocket = (config) => {
|
|
@@ -794,7 +794,7 @@ return media
|
|
|
794
794
|
if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
|
|
795
795
|
targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
|
|
796
796
|
}
|
|
797
|
-
const { img } = await (0,
|
|
797
|
+
const { img } = await (0, WAMedia_1.generateProfilePictureFP)(content);
|
|
798
798
|
await query({
|
|
799
799
|
tag: 'iq',
|
|
800
800
|
attrs: {
|
|
@@ -820,7 +820,7 @@ return media
|
|
|
820
820
|
if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
|
|
821
821
|
targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
|
|
822
822
|
}
|
|
823
|
-
const { preview } = await (0,
|
|
823
|
+
const { preview } = await (0, WAMedia_1.generatePP)(content);
|
|
824
824
|
await query({
|
|
825
825
|
tag: 'iq',
|
|
826
826
|
attrs: {
|
package/package.json
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@queenanya/baileys",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.2",
|
|
4
4
|
"description": "Custom Baileys WhatsApp API",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"baileys",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
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,18 +0,0 @@
|
|
|
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
|
-
}>;
|
|
@@ -1,102 +0,0 @@
|
|
|
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;
|
package/lib/Utils/media-set.d.ts
DELETED
package/lib/Utils/media-set.js
DELETED
|
@@ -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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|