apexify.js 3.0.2 → 3.1.0
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/.tsbuildinfo +1 -0
- package/README.md +158 -130
- package/dist/ai/ApexAI.d.ts +37 -0
- package/dist/ai/ApexAI.d.ts.map +1 -0
- package/dist/ai/ApexAI.js +258 -0
- package/dist/ai/ApexAI.js.map +1 -0
- package/dist/ai/buttons/drawMenu.d.ts +3 -0
- package/dist/ai/buttons/drawMenu.d.ts.map +1 -0
- package/dist/ai/buttons/drawMenu.js +271 -0
- package/dist/ai/buttons/drawMenu.js.map +1 -0
- package/dist/ai/buttons/tools.d.ts +3 -0
- package/dist/ai/buttons/tools.d.ts.map +1 -0
- package/dist/ai/buttons/tools.js +442 -0
- package/dist/ai/buttons/tools.js.map +1 -0
- package/dist/ai/functions/chunkString.d.ts +2 -0
- package/dist/ai/functions/chunkString.d.ts.map +1 -0
- package/{lib → dist}/ai/functions/chunkString.js +8 -8
- package/dist/ai/functions/chunkString.js.map +1 -0
- package/dist/ai/functions/draw.d.ts +3 -0
- package/dist/ai/functions/draw.d.ts.map +1 -0
- package/dist/ai/functions/draw.js +377 -0
- package/dist/ai/functions/draw.js.map +1 -0
- package/dist/ai/functions/generateVoiceResponse.d.ts +3 -0
- package/dist/ai/functions/generateVoiceResponse.d.ts.map +1 -0
- package/dist/ai/functions/generateVoiceResponse.js +158 -0
- package/dist/ai/functions/generateVoiceResponse.js.map +1 -0
- package/dist/ai/functions/imageReader.d.ts +3 -0
- package/dist/ai/functions/imageReader.d.ts.map +1 -0
- package/dist/ai/functions/imageReader.js +23 -0
- package/dist/ai/functions/imageReader.js.map +1 -0
- package/dist/ai/functions/readFiles.d.ts +3 -0
- package/dist/ai/functions/readFiles.d.ts.map +1 -0
- package/dist/ai/functions/readFiles.js +62 -0
- package/dist/ai/functions/readFiles.js.map +1 -0
- package/dist/ai/functions/shouldDrawImage.d.ts +2 -0
- package/dist/ai/functions/shouldDrawImage.d.ts.map +1 -0
- package/dist/ai/functions/shouldDrawImage.js +12 -0
- package/dist/ai/functions/shouldDrawImage.js.map +1 -0
- package/dist/ai/models.d.ts +9 -0
- package/dist/ai/models.d.ts.map +1 -0
- package/dist/ai/models.js +538 -0
- package/dist/ai/models.js.map +1 -0
- package/dist/ai/utils.d.ts +9 -0
- package/dist/ai/utils.d.ts.map +1 -0
- package/dist/ai/utils.js +20 -0
- package/dist/ai/utils.js.map +1 -0
- package/dist/canvas/ApexPainter.d.ts +26 -0
- package/dist/canvas/ApexPainter.d.ts.map +1 -0
- package/dist/canvas/ApexPainter.js +411 -0
- package/dist/canvas/ApexPainter.js.map +1 -0
- package/dist/canvas/utils/bg.d.ts +24 -0
- package/dist/canvas/utils/bg.d.ts.map +1 -0
- package/dist/canvas/utils/bg.js +77 -0
- package/dist/canvas/utils/bg.js.map +1 -0
- package/dist/canvas/utils/charts.d.ts +9 -0
- package/dist/canvas/utils/charts.d.ts.map +1 -0
- package/dist/canvas/utils/charts.js +453 -0
- package/dist/canvas/utils/charts.js.map +1 -0
- package/dist/canvas/utils/circular.d.ts +10 -0
- package/dist/canvas/utils/circular.d.ts.map +1 -0
- package/dist/canvas/utils/circular.js +22 -0
- package/dist/canvas/utils/circular.js.map +1 -0
- package/dist/canvas/utils/customLines.d.ts +2 -0
- package/dist/canvas/utils/customLines.d.ts.map +1 -0
- package/dist/canvas/utils/customLines.js +50 -0
- package/dist/canvas/utils/customLines.js.map +1 -0
- package/dist/canvas/utils/general functions.d.ts +8 -0
- package/dist/canvas/utils/general functions.d.ts.map +1 -0
- package/dist/canvas/utils/general functions.js +187 -0
- package/dist/canvas/utils/general functions.js.map +1 -0
- package/dist/canvas/utils/imageProperties.d.ts +60 -0
- package/dist/canvas/utils/imageProperties.d.ts.map +1 -0
- package/dist/canvas/utils/imageProperties.js +331 -0
- package/dist/canvas/utils/imageProperties.js.map +1 -0
- package/dist/canvas/utils/radius.d.ts +10 -0
- package/dist/canvas/utils/radius.d.ts.map +1 -0
- package/dist/canvas/utils/radius.js +31 -0
- package/dist/canvas/utils/radius.js.map +1 -0
- package/dist/canvas/utils/textProperties.d.ts +18 -0
- package/dist/canvas/utils/textProperties.d.ts.map +1 -0
- package/dist/canvas/utils/textProperties.js +67 -0
- package/dist/canvas/utils/textProperties.js.map +1 -0
- package/dist/canvas/utils/types.d.ts +389 -0
- package/dist/canvas/utils/types.d.ts.map +1 -0
- package/dist/canvas/utils/types.js +5 -0
- package/dist/canvas/utils/types.js.map +1 -0
- package/dist/canvas/utils/utils.d.ts +20 -0
- package/dist/canvas/utils/utils.d.ts.map +1 -0
- package/dist/canvas/utils/utils.js +43 -0
- package/dist/canvas/utils/utils.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/dist/utils.d.ts +12 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +12 -0
- package/dist/utils.js.map +1 -0
- package/example/barChartType1.txt +69 -0
- package/example/lineChart.txt +84 -0
- package/example/piechartUsagetyp1.txt +63 -0
- package/package.json +136 -78
- package/dataSQL/data.sql +0 -5
- package/dataSQL/dataName.sql +0 -0
- package/dataSQL/example_table.sql +0 -1
- package/index.js +0 -35
- package/lib/ai/apexAI.js +0 -446
- package/lib/ai/buttons/drawMenu.js +0 -351
- package/lib/ai/buttons/tools.js +0 -652
- package/lib/ai/functions/draw.js +0 -514
- package/lib/ai/functions/generateVoiceResponse.js +0 -239
- package/lib/ai/functions/processImageAttachments.js +0 -93
- package/lib/ai/functions/processMessageContent.js +0 -48
- package/lib/ai/functions/readFiles.js +0 -95
- package/lib/ai/functions/shouldDrawImage.js +0 -12
- package/lib/ai/models.js +0 -654
- package/lib/ai/utils.js +0 -21
- package/lib/canvas/ApexPainter.js +0 -1396
- package/lib/utils.js +0 -24
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.generateVoiceResponse = void 0;
|
|
40
|
-
var hercai_1 = require("hercai");
|
|
41
|
-
var google_translate_1 = require("@iamtraction/google-translate");
|
|
42
|
-
var axios_1 = require("axios");
|
|
43
|
-
var tesseract_1 = require("tesseract.js");
|
|
44
|
-
var chunkString_1 = require("./chunkString");
|
|
45
|
-
var draw_1 = require("./draw");
|
|
46
|
-
var fs_1 = require("fs");
|
|
47
|
-
var herc = new hercai_1.Hercai();
|
|
48
|
-
var isProcessing = false;
|
|
49
|
-
function generateVoiceResponse(message, numOfImages, finalText, hercai, response, imageModel, draw, drawValid, chatModel, voiceModel, voice_code, letter, apiKey, nsfw) {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
-
var msg, attachment, imageUrl, worker, text, translationResult, chunks, delay, _loop_1, _i, chunks_1, chunk, options, response_1, audioData, error_1, encodedParams, options, response_2, error_2, error_3;
|
|
52
|
-
var _this = this;
|
|
53
|
-
return __generator(this, function (_a) {
|
|
54
|
-
switch (_a.label) {
|
|
55
|
-
case 0:
|
|
56
|
-
if (message.author.bot || isProcessing || !message.guild) {
|
|
57
|
-
return [2 /*return*/];
|
|
58
|
-
}
|
|
59
|
-
isProcessing = true;
|
|
60
|
-
_a.label = 1;
|
|
61
|
-
case 1:
|
|
62
|
-
_a.trys.push([1, 23, 24, 25]);
|
|
63
|
-
msg = message.content;
|
|
64
|
-
if (!drawValid) return [3 /*break*/, 3];
|
|
65
|
-
return [4 /*yield*/, (0, draw_1.drawImage)(message, numOfImages, finalText, hercai, imageModel, nsfw)];
|
|
66
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
67
|
-
case 3:
|
|
68
|
-
if (!(message.attachments.size > 0)) return [3 /*break*/, 7];
|
|
69
|
-
attachment = message.attachments.first();
|
|
70
|
-
imageUrl = attachment.url;
|
|
71
|
-
return [4 /*yield*/, (0, tesseract_1.createWorker)()];
|
|
72
|
-
case 4:
|
|
73
|
-
worker = _a.sent();
|
|
74
|
-
return [4 /*yield*/, worker.recognize(imageUrl)];
|
|
75
|
-
case 5:
|
|
76
|
-
text = (_a.sent()).data.text;
|
|
77
|
-
return [4 /*yield*/, worker.terminate()];
|
|
78
|
-
case 6:
|
|
79
|
-
_a.sent();
|
|
80
|
-
msg += "\n" + text;
|
|
81
|
-
_a.label = 7;
|
|
82
|
-
case 7: return [4 /*yield*/, herc.question({
|
|
83
|
-
model: chatModel,
|
|
84
|
-
content: msg,
|
|
85
|
-
})];
|
|
86
|
-
case 8:
|
|
87
|
-
msg = _a.sent();
|
|
88
|
-
msg = msg.reply.replace(/\n/g, " ");
|
|
89
|
-
if (!(voiceModel === "google")) return [3 /*break*/, 11];
|
|
90
|
-
if (!!isEnglish(msg)) return [3 /*break*/, 10];
|
|
91
|
-
return [4 /*yield*/, (0, google_translate_1)(msg, {
|
|
92
|
-
from: "auto",
|
|
93
|
-
to: "en",
|
|
94
|
-
})];
|
|
95
|
-
case 9:
|
|
96
|
-
translationResult = _a.sent();
|
|
97
|
-
msg = translationResult.text;
|
|
98
|
-
_a.label = 10;
|
|
99
|
-
case 10:
|
|
100
|
-
chunks = (0, chunkString_1.chunkString)(msg, 200);
|
|
101
|
-
delay = 0;
|
|
102
|
-
_loop_1 = function (chunk) {
|
|
103
|
-
setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
104
|
-
var encodedChunk, url, mp3Stream;
|
|
105
|
-
return __generator(this, function (_a) {
|
|
106
|
-
switch (_a.label) {
|
|
107
|
-
case 0:
|
|
108
|
-
encodedChunk = encodeURIComponent(chunk);
|
|
109
|
-
url = "https://translate.google.com/translate_tts?ie=UTF-8&tl=en&client=tw-ob&q=".concat(encodedChunk);
|
|
110
|
-
return [4 /*yield*/, axios_1.get(url, {
|
|
111
|
-
responseType: "stream",
|
|
112
|
-
headers: {
|
|
113
|
-
Referer: "http://translate.google.com/",
|
|
114
|
-
"User-Agent": "stagefright/1.2 (Linux;Android 5.0)",
|
|
115
|
-
},
|
|
116
|
-
})];
|
|
117
|
-
case 1:
|
|
118
|
-
mp3Stream = _a.sent();
|
|
119
|
-
return [4 /*yield*/, message.reply({
|
|
120
|
-
files: [
|
|
121
|
-
{
|
|
122
|
-
attachment: mp3Stream.data,
|
|
123
|
-
name: "respond.mp3",
|
|
124
|
-
},
|
|
125
|
-
],
|
|
126
|
-
allowedMentions: { repliedUser: false },
|
|
127
|
-
})];
|
|
128
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}); }, delay);
|
|
132
|
-
delay += 3000;
|
|
133
|
-
};
|
|
134
|
-
for (_i = 0, chunks_1 = chunks; _i < chunks_1.length; _i++) {
|
|
135
|
-
chunk = chunks_1[_i];
|
|
136
|
-
_loop_1(chunk);
|
|
137
|
-
}
|
|
138
|
-
return [3 /*break*/, 22];
|
|
139
|
-
case 11:
|
|
140
|
-
if (!(voiceModel === "apexAI")) return [3 /*break*/, 17];
|
|
141
|
-
if (!apiKey) {
|
|
142
|
-
throw new Error('Error: The apexAI model requires a premium account for generation. Please visit our support server at https://discord.gg/4uhpr7w8wW for assistance.');
|
|
143
|
-
}
|
|
144
|
-
options = {
|
|
145
|
-
method: "POST",
|
|
146
|
-
url: "https://text-to-speech-neural-google.p.rapidapi.com/generateAudioFiles",
|
|
147
|
-
headers: {
|
|
148
|
-
"content-type": "application/json",
|
|
149
|
-
"X-RapidAPI-Key": "your_rapid_api_key_here",
|
|
150
|
-
"X-RapidAPI-Host": "text-to-speech-neural-google.p.rapidapi.com",
|
|
151
|
-
},
|
|
152
|
-
data: {
|
|
153
|
-
audioFormat: "ogg",
|
|
154
|
-
paragraphChunks: [msg],
|
|
155
|
-
voiceParams: {
|
|
156
|
-
name: "Wavenet-".concat(letter || "c"),
|
|
157
|
-
engine: "google",
|
|
158
|
-
languageCode: "en-US",
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
};
|
|
162
|
-
_a.label = 12;
|
|
163
|
-
case 12:
|
|
164
|
-
_a.trys.push([12, 15, , 16]);
|
|
165
|
-
return [4 /*yield*/, axios_1.request(options)];
|
|
166
|
-
case 13:
|
|
167
|
-
response_1 = _a.sent();
|
|
168
|
-
audioData = response_1.data.audioStream;
|
|
169
|
-
fs_1.writeFileSync("output.ogg", Buffer.from(audioData, "base64"));
|
|
170
|
-
return [4 /*yield*/, message.reply({
|
|
171
|
-
files: [
|
|
172
|
-
{
|
|
173
|
-
attachment: "output.ogg",
|
|
174
|
-
name: "respond.ogg",
|
|
175
|
-
},
|
|
176
|
-
],
|
|
177
|
-
allowedMentions: { repliedUser: false },
|
|
178
|
-
})];
|
|
179
|
-
case 14: return [2 /*return*/, _a.sent()];
|
|
180
|
-
case 15:
|
|
181
|
-
error_1 = _a.sent();
|
|
182
|
-
console.error(error_1);
|
|
183
|
-
return [3 /*break*/, 16];
|
|
184
|
-
case 16: return [3 /*break*/, 22];
|
|
185
|
-
case 17:
|
|
186
|
-
if (!(voiceModel === "zenithAi")) return [3 /*break*/, 22];
|
|
187
|
-
if (!apiKey) {
|
|
188
|
-
throw new Error('Error: The zenithAi model requires a premium account for generation. Please visit our support server at https://discord.gg/4uhpr7w8wW for assistance.');
|
|
189
|
-
}
|
|
190
|
-
encodedParams = new URLSearchParams();
|
|
191
|
-
encodedParams.set("voice_code", voice_code || "en-US-3");
|
|
192
|
-
encodedParams.set("text", msg);
|
|
193
|
-
encodedParams.set("speed", "1.00");
|
|
194
|
-
encodedParams.set("pitch", "1.00");
|
|
195
|
-
encodedParams.set("output_type", "audio_url");
|
|
196
|
-
options = {
|
|
197
|
-
method: "POST",
|
|
198
|
-
url: "https://cloudlabs-text-to-speech.p.rapidapi.com/synthesize",
|
|
199
|
-
headers: {
|
|
200
|
-
"content-type": "application/x-www-form-urlencoded",
|
|
201
|
-
"X-RapidAPI-Key": "your_rapid_api_key_here",
|
|
202
|
-
"X-RapidAPI-Host": "cloudlabs-text-to-speech.p.rapidapi.com",
|
|
203
|
-
},
|
|
204
|
-
data: encodedParams,
|
|
205
|
-
};
|
|
206
|
-
_a.label = 18;
|
|
207
|
-
case 18:
|
|
208
|
-
_a.trys.push([18, 21, , 22]);
|
|
209
|
-
return [4 /*yield*/, axios_1.request(options)];
|
|
210
|
-
case 19:
|
|
211
|
-
response_2 = _a.sent();
|
|
212
|
-
console.log(response_2.data.result.audio_url);
|
|
213
|
-
return [4 /*yield*/, message.reply({
|
|
214
|
-
files: [response_2.data.result.audio_url],
|
|
215
|
-
allowedMentions: { repliedUser: false },
|
|
216
|
-
})];
|
|
217
|
-
case 20: return [2 /*return*/, _a.sent()];
|
|
218
|
-
case 21:
|
|
219
|
-
error_2 = _a.sent();
|
|
220
|
-
console.error(error_2);
|
|
221
|
-
return [3 /*break*/, 22];
|
|
222
|
-
case 22: return [3 /*break*/, 25];
|
|
223
|
-
case 23:
|
|
224
|
-
error_3 = _a.sent();
|
|
225
|
-
console.error(error_3);
|
|
226
|
-
message.reply("The response of the bot was too long and couldn't be sent as a voice.");
|
|
227
|
-
return [3 /*break*/, 25];
|
|
228
|
-
case 24:
|
|
229
|
-
isProcessing = false;
|
|
230
|
-
return [7 /*endfinally*/];
|
|
231
|
-
case 25: return [2 /*return*/];
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
exports.generateVoiceResponse = generateVoiceResponse;
|
|
237
|
-
function isEnglish(str) {
|
|
238
|
-
return /^[A-Za-z0-9!@#$%^&()_+\-=\[\]{};':"\\|,.<>\/?]+$/.test(str);
|
|
239
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.processImageAttachments = void 0;
|
|
40
|
-
var tesseract_js_1 = require("tesseract.js");
|
|
41
|
-
function processImageAttachments(_0x5ebd94) {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
-
var _0x792a17, _i, _a, _0xa8c22c, _0x3ddc48, _0x37ac74, _0x3905ea, _0x8b7223_1, _0x2ba598_1;
|
|
44
|
-
return __generator(this, function (_b) {
|
|
45
|
-
switch (_b.label) {
|
|
46
|
-
case 0:
|
|
47
|
-
_0x792a17 = '';
|
|
48
|
-
_i = 0, _a = _0x5ebd94.values();
|
|
49
|
-
_b.label = 1;
|
|
50
|
-
case 1:
|
|
51
|
-
if (!(_i < _a.length)) return [3 /*break*/, 11];
|
|
52
|
-
_0xa8c22c = _a[_i];
|
|
53
|
-
_0x3ddc48 = _0xa8c22c.url;
|
|
54
|
-
return [4 /*yield*/, (0, tesseract_js_1.createWorker)()];
|
|
55
|
-
case 2:
|
|
56
|
-
_0x37ac74 = _b.sent();
|
|
57
|
-
_b.label = 3;
|
|
58
|
-
case 3:
|
|
59
|
-
_b.trys.push([3, 5, 6, 10]);
|
|
60
|
-
return [4 /*yield*/, _0x37ac74.recognize(_0x3ddc48)];
|
|
61
|
-
case 4:
|
|
62
|
-
_0x3905ea = (_b.sent()).data.text;
|
|
63
|
-
if (!_0x3905ea) {
|
|
64
|
-
console.error("Image text not recognized or is empty for URL:", _0x3ddc48);
|
|
65
|
-
return [3 /*break*/, 10];
|
|
66
|
-
}
|
|
67
|
-
_0x792a17 += '' + (_0x792a17 ? "\n" : '') + _0x3905ea;
|
|
68
|
-
return [3 /*break*/, 10];
|
|
69
|
-
case 5:
|
|
70
|
-
_0x8b7223_1 = _b.sent();
|
|
71
|
-
console.error("Error processing image at URL " + _0x3ddc48 + ": " + _0x8b7223_1.message);
|
|
72
|
-
return [3 /*break*/, 10];
|
|
73
|
-
case 6:
|
|
74
|
-
_b.trys.push([6, 8, , 9]);
|
|
75
|
-
return [4 /*yield*/, _0x37ac74.terminate()];
|
|
76
|
-
case 7:
|
|
77
|
-
_b.sent();
|
|
78
|
-
return [3 /*break*/, 9];
|
|
79
|
-
case 8:
|
|
80
|
-
_0x2ba598_1 = _b.sent();
|
|
81
|
-
console.error("Error terminating Tesseract worker: " + _0x2ba598_1.message);
|
|
82
|
-
return [3 /*break*/, 9];
|
|
83
|
-
case 9: return [7 /*endfinally*/];
|
|
84
|
-
case 10:
|
|
85
|
-
_i++;
|
|
86
|
-
return [3 /*break*/, 1];
|
|
87
|
-
case 11: return [2 /*return*/, _0x792a17];
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
exports.processImageAttachments = processImageAttachments;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.processMessageContent = void 0;
|
|
40
|
-
function processMessageContent(content) {
|
|
41
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
42
|
-
return __generator(this, function (_a) {
|
|
43
|
-
return [2 /*return*/, content ? "".concat(content, "\n") : ''];
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
exports.processMessageContent = processMessageContent;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.readPdf = exports.readTextFile = exports.downloadFile = void 0;
|
|
40
|
-
var pdf = require("pdf-parse");
|
|
41
|
-
var fs = require("fs");
|
|
42
|
-
var https = require("https");
|
|
43
|
-
function readPdf(url) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
-
var pdfBuffer, data;
|
|
46
|
-
return __generator(this, function (_a) {
|
|
47
|
-
switch (_a.label) {
|
|
48
|
-
case 0: return [4 /*yield*/, downloadFile(url)];
|
|
49
|
-
case 1:
|
|
50
|
-
pdfBuffer = _a.sent();
|
|
51
|
-
return [4 /*yield*/, pdf(pdfBuffer)];
|
|
52
|
-
case 2:
|
|
53
|
-
data = _a.sent();
|
|
54
|
-
return [2 /*return*/, data.text];
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
exports.readPdf = readPdf;
|
|
60
|
-
function readTextFile(url) {
|
|
61
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
-
var textBuffer;
|
|
63
|
-
return __generator(this, function (_a) {
|
|
64
|
-
switch (_a.label) {
|
|
65
|
-
case 0: return [4 /*yield*/, downloadFile(url)];
|
|
66
|
-
case 1:
|
|
67
|
-
textBuffer = _a.sent();
|
|
68
|
-
return [2 /*return*/, textBuffer.toString()];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
exports.readTextFile = readTextFile;
|
|
74
|
-
function downloadFile(url) {
|
|
75
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
-
return __generator(this, function (_a) {
|
|
77
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
78
|
-
var file = fs.createWriteStream('temp');
|
|
79
|
-
https.get(url, function (response) {
|
|
80
|
-
response.pipe(file);
|
|
81
|
-
file.on('finish', function () {
|
|
82
|
-
file.close(function () {
|
|
83
|
-
resolve(fs.readFileSync('temp'));
|
|
84
|
-
fs.unlinkSync('temp');
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
}).on('error', function (err) {
|
|
88
|
-
fs.unlinkSync('temp');
|
|
89
|
-
reject(err.message);
|
|
90
|
-
});
|
|
91
|
-
})];
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
exports.downloadFile = downloadFile;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.shouldDrawImage = void 0;
|
|
4
|
-
function shouldDrawImage(content, drawTrigger) {
|
|
5
|
-
if (!drawTrigger) {
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
var lowerContent = content.toLowerCase();
|
|
9
|
-
return drawTrigger.some(function (trigger) { return lowerContent.includes(trigger); });
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
exports.shouldDrawImage = shouldDrawImage;
|