@diegofemello/bitbot-types 1.3.21 → 1.3.22
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/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/utils/utils.d.ts +96 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +2110 -0
- package/package.json +1 -1
|
@@ -0,0 +1,2110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.timestampToDate = exports.stopWords = exports.pornWords = exports.makeText = exports.getRandomName = void 0;
|
|
4
|
+
exports.getRandomFrasesVitoria = getRandomFrasesVitoria;
|
|
5
|
+
exports.normalizeString = normalizeString;
|
|
6
|
+
exports.checkGuessWithOptions = checkGuessWithOptions;
|
|
7
|
+
exports.normalizeStringAndRemoveStopWords = normalizeStringAndRemoveStopWords;
|
|
8
|
+
exports.formatWords = formatWords;
|
|
9
|
+
exports.randomIntFromInterval = randomIntFromInterval;
|
|
10
|
+
exports.levenshteinDistance = levenshteinDistance;
|
|
11
|
+
exports.extractNumbersFromString = extractNumbersFromString;
|
|
12
|
+
exports.getRandomNumber = getRandomNumber;
|
|
13
|
+
exports.mapearParaIntervalo = mapearParaIntervalo;
|
|
14
|
+
exports.calcularValorOriginal = calcularValorOriginal;
|
|
15
|
+
exports.interpolateColor = interpolateColor;
|
|
16
|
+
exports.getWeightedRandomCard = getWeightedRandomCard;
|
|
17
|
+
exports.compareCardOrder = compareCardOrder;
|
|
18
|
+
exports.obterNivelTreinador = obterNivelTreinador;
|
|
19
|
+
exports.obterLimiteBuddy = obterLimiteBuddy;
|
|
20
|
+
exports.getValorPatrimonioPoke = getValorPatrimonioPoke;
|
|
21
|
+
exports.getPossePatrimonioPoke = getPossePatrimonioPoke;
|
|
22
|
+
exports.getValorPokemon = getValorPokemon;
|
|
23
|
+
exports.comparePokemonIds = comparePokemonIds;
|
|
24
|
+
exports.premiarPresente = premiarPresente;
|
|
25
|
+
exports.premiarMisteryBox = premiarMisteryBox;
|
|
26
|
+
exports.formatPokemonName = formatPokemonName;
|
|
27
|
+
exports.getValueApostaBicho = getValueApostaBicho;
|
|
28
|
+
exports.calcPremioBicho = calcPremioBicho;
|
|
29
|
+
exports.checkIsShiny = checkIsShiny;
|
|
30
|
+
exports.checkIsDark = checkIsDark;
|
|
31
|
+
exports.checkIsTera = checkIsTera;
|
|
32
|
+
exports.checkIsShinyOrDark = checkIsShinyOrDark;
|
|
33
|
+
exports.checkIsMega = checkIsMega;
|
|
34
|
+
exports.checkIsGmax = checkIsGmax;
|
|
35
|
+
exports.checkIsAlternative = checkIsAlternative;
|
|
36
|
+
exports.checkHasPokemon = checkHasPokemon;
|
|
37
|
+
exports.checkHasCard = checkHasCard;
|
|
38
|
+
exports.getDayId = getDayId;
|
|
39
|
+
exports.compareIds = compareIds;
|
|
40
|
+
exports.isOwner = isOwner;
|
|
41
|
+
exports.checkIsVip = checkIsVip;
|
|
42
|
+
exports.obterQuantoFaltaParaProximoNivel = obterQuantoFaltaParaProximoNivel;
|
|
43
|
+
exports.streamToBuffer = streamToBuffer;
|
|
44
|
+
exports.extractContactNumber = extractContactNumber;
|
|
45
|
+
exports.isBoolean = isBoolean;
|
|
46
|
+
exports.calcSlotValue = calcSlotValue;
|
|
47
|
+
exports.getRandomFromArray = getRandomFromArray;
|
|
48
|
+
exports.calcStars = calcStars;
|
|
49
|
+
exports.formatStars = formatStars;
|
|
50
|
+
exports.calcXpByStars = calcXpByStars;
|
|
51
|
+
exports.cleanObject = cleanObject;
|
|
52
|
+
exports.getErrorMessage = getErrorMessage;
|
|
53
|
+
exports.assignPosition = assignPosition;
|
|
54
|
+
exports.timeout = timeout;
|
|
55
|
+
exports.getActualMonth = getActualMonth;
|
|
56
|
+
exports.checkGuess = checkGuess;
|
|
57
|
+
exports.getRandomErroMessage = getRandomErroMessage;
|
|
58
|
+
exports.timeoutPromise = timeoutPromise;
|
|
59
|
+
exports.convertTime = convertTime;
|
|
60
|
+
exports.getLinkRegex = getLinkRegex;
|
|
61
|
+
exports.getCensuredText = getCensuredText;
|
|
62
|
+
exports.isOwnerGroup = isOwnerGroup;
|
|
63
|
+
exports.extrairIdsMencionados = extrairIdsMencionados;
|
|
64
|
+
exports.generateCode = generateCode;
|
|
65
|
+
exports.drawHangman = drawHangman;
|
|
66
|
+
exports.clearObject = clearObject;
|
|
67
|
+
exports.getMonthId = getMonthId;
|
|
68
|
+
exports.isShiny = isShiny;
|
|
69
|
+
exports.compareCardsOrder = compareCardsOrder;
|
|
70
|
+
exports.privateNumber = privateNumber;
|
|
71
|
+
exports.limitDescription = limitDescription;
|
|
72
|
+
exports.convertToCurrency = convertToCurrency;
|
|
73
|
+
exports.getDateFormat = getDateFormat;
|
|
74
|
+
exports.getBlobFromPath = getBlobFromPath;
|
|
75
|
+
exports.base64ToBlob = base64ToBlob;
|
|
76
|
+
exports.loadImage = loadImage;
|
|
77
|
+
exports.blobToBase64 = blobToBase64;
|
|
78
|
+
exports.formatTime = formatTime;
|
|
79
|
+
exports.raidComparator = raidComparator;
|
|
80
|
+
exports.toISOStringWithOffset = toISOStringWithOffset;
|
|
81
|
+
const frasesVitoria = [
|
|
82
|
+
`AEEEE CARAI!!!`,
|
|
83
|
+
`🤩`,
|
|
84
|
+
`😱`,
|
|
85
|
+
`PARABÉNS!!!`,
|
|
86
|
+
`OLHA SÓ!!!`,
|
|
87
|
+
`QUE SORTE!!!`,
|
|
88
|
+
`OLOQUINHO MEU!`,
|
|
89
|
+
`CARAI BICHÃO!!`,
|
|
90
|
+
`Me dá um pouco dessa sorte ai!?`,
|
|
91
|
+
];
|
|
92
|
+
function getRandomFrasesVitoria() {
|
|
93
|
+
return frasesVitoria[getRandomNumber(0, frasesVitoria.length - 1)];
|
|
94
|
+
}
|
|
95
|
+
const normalizedStopWords = [
|
|
96
|
+
'de',
|
|
97
|
+
'que',
|
|
98
|
+
'do',
|
|
99
|
+
'da',
|
|
100
|
+
'e',
|
|
101
|
+
'para',
|
|
102
|
+
'co',
|
|
103
|
+
'no',
|
|
104
|
+
'se',
|
|
105
|
+
'na',
|
|
106
|
+
'po',
|
|
107
|
+
'mai',
|
|
108
|
+
'do',
|
|
109
|
+
'como',
|
|
110
|
+
'ma',
|
|
111
|
+
'foi',
|
|
112
|
+
'ao',
|
|
113
|
+
'ele',
|
|
114
|
+
'da',
|
|
115
|
+
'te',
|
|
116
|
+
'seu',
|
|
117
|
+
'sua',
|
|
118
|
+
'ou',
|
|
119
|
+
'se',
|
|
120
|
+
'quando',
|
|
121
|
+
'muito',
|
|
122
|
+
'ha',
|
|
123
|
+
'no',
|
|
124
|
+
'ja',
|
|
125
|
+
'esta',
|
|
126
|
+
'eu',
|
|
127
|
+
'tambe',
|
|
128
|
+
'so',
|
|
129
|
+
'pelo',
|
|
130
|
+
'pela',
|
|
131
|
+
'ate',
|
|
132
|
+
'isso',
|
|
133
|
+
'ela',
|
|
134
|
+
'entre',
|
|
135
|
+
'era',
|
|
136
|
+
'depoi',
|
|
137
|
+
'mesmo',
|
|
138
|
+
'ao',
|
|
139
|
+
'te',
|
|
140
|
+
'seu',
|
|
141
|
+
'que',
|
|
142
|
+
'na',
|
|
143
|
+
'me',
|
|
144
|
+
'esse',
|
|
145
|
+
'ele',
|
|
146
|
+
'estao',
|
|
147
|
+
'voce',
|
|
148
|
+
'vc',
|
|
149
|
+
'tinha',
|
|
150
|
+
'fora',
|
|
151
|
+
'essa',
|
|
152
|
+
'nu',
|
|
153
|
+
'ne',
|
|
154
|
+
'sua',
|
|
155
|
+
'meu',
|
|
156
|
+
'minha',
|
|
157
|
+
'te',
|
|
158
|
+
'numa',
|
|
159
|
+
'pelo',
|
|
160
|
+
'ela',
|
|
161
|
+
'havia',
|
|
162
|
+
'seja',
|
|
163
|
+
'qual',
|
|
164
|
+
'sera',
|
|
165
|
+
'no',
|
|
166
|
+
'tenho',
|
|
167
|
+
'nao',
|
|
168
|
+
'nao',
|
|
169
|
+
'lhe',
|
|
170
|
+
'dele',
|
|
171
|
+
'essa',
|
|
172
|
+
'esse',
|
|
173
|
+
'pela',
|
|
174
|
+
'este',
|
|
175
|
+
'fosse',
|
|
176
|
+
'dele',
|
|
177
|
+
'tu',
|
|
178
|
+
'te',
|
|
179
|
+
'voce',
|
|
180
|
+
'vo',
|
|
181
|
+
'lhe',
|
|
182
|
+
'meu',
|
|
183
|
+
'minha',
|
|
184
|
+
'teu',
|
|
185
|
+
'tua',
|
|
186
|
+
'teu',
|
|
187
|
+
'tua',
|
|
188
|
+
'nosso',
|
|
189
|
+
'nossa',
|
|
190
|
+
'nosso',
|
|
191
|
+
'nossa',
|
|
192
|
+
'dela',
|
|
193
|
+
'dela',
|
|
194
|
+
'esta',
|
|
195
|
+
'este',
|
|
196
|
+
'esta',
|
|
197
|
+
'aquele',
|
|
198
|
+
'aquela',
|
|
199
|
+
'aquele',
|
|
200
|
+
'aquela',
|
|
201
|
+
'isto',
|
|
202
|
+
'aquilo',
|
|
203
|
+
'estou',
|
|
204
|
+
'esta',
|
|
205
|
+
'estamo',
|
|
206
|
+
'estao',
|
|
207
|
+
'estive',
|
|
208
|
+
'esteve',
|
|
209
|
+
'estivemo',
|
|
210
|
+
'estivera',
|
|
211
|
+
'estava',
|
|
212
|
+
'estavamo',
|
|
213
|
+
'estava',
|
|
214
|
+
'estivera',
|
|
215
|
+
'estiveramo',
|
|
216
|
+
'esteja',
|
|
217
|
+
'estejamo',
|
|
218
|
+
'esteja',
|
|
219
|
+
'estivesse',
|
|
220
|
+
'estivessemo',
|
|
221
|
+
'estivesse',
|
|
222
|
+
'estive',
|
|
223
|
+
'estivermo',
|
|
224
|
+
'estivere',
|
|
225
|
+
'hei',
|
|
226
|
+
'ha',
|
|
227
|
+
'havemo',
|
|
228
|
+
'hao',
|
|
229
|
+
'houve',
|
|
230
|
+
'houvemo',
|
|
231
|
+
'houvera',
|
|
232
|
+
'houvera',
|
|
233
|
+
'houveramo',
|
|
234
|
+
'haja',
|
|
235
|
+
'hajamo',
|
|
236
|
+
'haja',
|
|
237
|
+
'houvesse',
|
|
238
|
+
'houvessemo',
|
|
239
|
+
'houvesse',
|
|
240
|
+
'houve',
|
|
241
|
+
'houvermo',
|
|
242
|
+
'houvere',
|
|
243
|
+
'houverei',
|
|
244
|
+
'houvera',
|
|
245
|
+
'houveremo',
|
|
246
|
+
'houverao',
|
|
247
|
+
'houveria',
|
|
248
|
+
'houveriamo',
|
|
249
|
+
'houveria',
|
|
250
|
+
'sou',
|
|
251
|
+
'somo',
|
|
252
|
+
'sao',
|
|
253
|
+
'era',
|
|
254
|
+
'eramo',
|
|
255
|
+
'era',
|
|
256
|
+
'fui',
|
|
257
|
+
'foi',
|
|
258
|
+
'fomo',
|
|
259
|
+
'fora',
|
|
260
|
+
'fora',
|
|
261
|
+
'foramo',
|
|
262
|
+
'seja',
|
|
263
|
+
'sejamo',
|
|
264
|
+
'seja',
|
|
265
|
+
'fosse',
|
|
266
|
+
'fossemo',
|
|
267
|
+
'fosse',
|
|
268
|
+
'formo',
|
|
269
|
+
'fore',
|
|
270
|
+
'serei',
|
|
271
|
+
'sera',
|
|
272
|
+
'seremo',
|
|
273
|
+
'serao',
|
|
274
|
+
'seria',
|
|
275
|
+
'seriamo',
|
|
276
|
+
'seria',
|
|
277
|
+
'temo',
|
|
278
|
+
'te',
|
|
279
|
+
'tinhamo',
|
|
280
|
+
'tinha',
|
|
281
|
+
'tive',
|
|
282
|
+
'teve',
|
|
283
|
+
'tivemo',
|
|
284
|
+
'tivera',
|
|
285
|
+
'tivera',
|
|
286
|
+
'tiveramo',
|
|
287
|
+
'tenha',
|
|
288
|
+
'tenhamo',
|
|
289
|
+
'tenha',
|
|
290
|
+
'tivesse',
|
|
291
|
+
'tivessemo',
|
|
292
|
+
'tivesse',
|
|
293
|
+
'tive',
|
|
294
|
+
'tivermo',
|
|
295
|
+
'tivere',
|
|
296
|
+
'terei',
|
|
297
|
+
'tera',
|
|
298
|
+
'teremo',
|
|
299
|
+
'terao',
|
|
300
|
+
'teria',
|
|
301
|
+
'teriamo',
|
|
302
|
+
'teria',
|
|
303
|
+
'vc',
|
|
304
|
+
'tb',
|
|
305
|
+
'q',
|
|
306
|
+
'cmg',
|
|
307
|
+
'p',
|
|
308
|
+
'eh',
|
|
309
|
+
'mt',
|
|
310
|
+
'td',
|
|
311
|
+
'pra',
|
|
312
|
+
'pro',
|
|
313
|
+
'the',
|
|
314
|
+
'the',
|
|
315
|
+
'i',
|
|
316
|
+
'me',
|
|
317
|
+
'my',
|
|
318
|
+
'myself',
|
|
319
|
+
'we',
|
|
320
|
+
'ou',
|
|
321
|
+
'ou',
|
|
322
|
+
'ourselve',
|
|
323
|
+
'you',
|
|
324
|
+
'you',
|
|
325
|
+
'you',
|
|
326
|
+
'yourself',
|
|
327
|
+
'yourselve',
|
|
328
|
+
'he',
|
|
329
|
+
'hi',
|
|
330
|
+
'hi',
|
|
331
|
+
'himself',
|
|
332
|
+
'she',
|
|
333
|
+
'he',
|
|
334
|
+
'he',
|
|
335
|
+
'herself',
|
|
336
|
+
'it',
|
|
337
|
+
'it',
|
|
338
|
+
'itself',
|
|
339
|
+
'they',
|
|
340
|
+
'the',
|
|
341
|
+
'thei',
|
|
342
|
+
'thei',
|
|
343
|
+
'themselve',
|
|
344
|
+
'what',
|
|
345
|
+
'which',
|
|
346
|
+
'who',
|
|
347
|
+
'who',
|
|
348
|
+
'thi',
|
|
349
|
+
'that',
|
|
350
|
+
'these',
|
|
351
|
+
'those',
|
|
352
|
+
'are',
|
|
353
|
+
'wa',
|
|
354
|
+
'were',
|
|
355
|
+
'be',
|
|
356
|
+
'bee',
|
|
357
|
+
'being',
|
|
358
|
+
'have',
|
|
359
|
+
'ha',
|
|
360
|
+
'had',
|
|
361
|
+
'having',
|
|
362
|
+
'do',
|
|
363
|
+
'dao',
|
|
364
|
+
'did',
|
|
365
|
+
'doing',
|
|
366
|
+
'the',
|
|
367
|
+
'but',
|
|
368
|
+
'if',
|
|
369
|
+
'because',
|
|
370
|
+
'until',
|
|
371
|
+
'while',
|
|
372
|
+
'by',
|
|
373
|
+
'with',
|
|
374
|
+
'about',
|
|
375
|
+
'against',
|
|
376
|
+
'betwee',
|
|
377
|
+
'into',
|
|
378
|
+
'through',
|
|
379
|
+
'during',
|
|
380
|
+
'before',
|
|
381
|
+
'afte',
|
|
382
|
+
'above',
|
|
383
|
+
'below',
|
|
384
|
+
'fro',
|
|
385
|
+
'up',
|
|
386
|
+
'dow',
|
|
387
|
+
'out',
|
|
388
|
+
'off',
|
|
389
|
+
'ove',
|
|
390
|
+
'unde',
|
|
391
|
+
'agai',
|
|
392
|
+
'furthe',
|
|
393
|
+
'the',
|
|
394
|
+
'once',
|
|
395
|
+
'here',
|
|
396
|
+
'there',
|
|
397
|
+
'whe',
|
|
398
|
+
'where',
|
|
399
|
+
'why',
|
|
400
|
+
'how',
|
|
401
|
+
'all',
|
|
402
|
+
'any',
|
|
403
|
+
'both',
|
|
404
|
+
'each',
|
|
405
|
+
'few',
|
|
406
|
+
'more',
|
|
407
|
+
'most',
|
|
408
|
+
'othe',
|
|
409
|
+
'some',
|
|
410
|
+
'such',
|
|
411
|
+
'no',
|
|
412
|
+
'no',
|
|
413
|
+
'not',
|
|
414
|
+
'only',
|
|
415
|
+
'ow',
|
|
416
|
+
'same',
|
|
417
|
+
'so',
|
|
418
|
+
'tha',
|
|
419
|
+
'too',
|
|
420
|
+
'very',
|
|
421
|
+
'ca',
|
|
422
|
+
'wa',
|
|
423
|
+
'wo',
|
|
424
|
+
];
|
|
425
|
+
function normalizeString(input, isCommand = false, removeResultLen = 0, lower = true) {
|
|
426
|
+
if (!input || typeof input !== 'string')
|
|
427
|
+
return '';
|
|
428
|
+
let result = '';
|
|
429
|
+
if (lower) {
|
|
430
|
+
result = `${input}`
|
|
431
|
+
.toLowerCase()
|
|
432
|
+
.replace(/[']/g, '')
|
|
433
|
+
.normalize('NFD')
|
|
434
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
435
|
+
.replace(/[áàãâä]/g, 'a')
|
|
436
|
+
.replace(/[éèêë]/g, 'e')
|
|
437
|
+
.replace(/[íìîï]/g, 'i')
|
|
438
|
+
.replace(/[óòõôö]/g, 'o')
|
|
439
|
+
.replace(/[úùûü]/g, 'u')
|
|
440
|
+
.replace(/[ç]/g, 'c')
|
|
441
|
+
.replace(isCommand ? /[^a-z0-9@ -]+/g : /[^a-z0-9@ ]+/g, ' ')
|
|
442
|
+
.replace(/\s+/g, ' ')
|
|
443
|
+
.trim();
|
|
444
|
+
}
|
|
445
|
+
else {
|
|
446
|
+
result = `${input}`
|
|
447
|
+
.replace(/[']/g, '')
|
|
448
|
+
.normalize('NFD')
|
|
449
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
450
|
+
.replace(/[áàãâä]/g, 'a')
|
|
451
|
+
.replace(/[éèêë]/g, 'e')
|
|
452
|
+
.replace(/[íìîï]/g, 'i')
|
|
453
|
+
.replace(/[óòõôö]/g, 'o')
|
|
454
|
+
.replace(/[úùûü]/g, 'u')
|
|
455
|
+
.replace(/[ÁÀÃÂÄ]/g, 'A')
|
|
456
|
+
.replace(/[ÉÈÊË]/g, 'E')
|
|
457
|
+
.replace(/[ÍÌÎÏ]/g, 'I')
|
|
458
|
+
.replace(/[ÓÒÕÔÖ]/g, 'O')
|
|
459
|
+
.replace(/[ÚÙÛÜ]/g, 'U')
|
|
460
|
+
.replace(/[Ç]/g, 'C')
|
|
461
|
+
.replace(/[ç]/g, 'c')
|
|
462
|
+
.replace(isCommand ? /[^a-zA-Z0-9@ -]+/g : /[^a-zA-Z0-9@ ]+/g, ' ')
|
|
463
|
+
.replace(/\s+/g, ' ')
|
|
464
|
+
.trim();
|
|
465
|
+
}
|
|
466
|
+
if (removeResultLen > 0) {
|
|
467
|
+
return result.slice(0, removeResultLen);
|
|
468
|
+
}
|
|
469
|
+
return result;
|
|
470
|
+
}
|
|
471
|
+
function checkGuessWithOptions(input, options, limite = 2) {
|
|
472
|
+
const normalizedInput = normalizeStringAndRemoveStopWords(input);
|
|
473
|
+
limite = input.length <= 4 && limite >= 2 ? limite - 1 : limite;
|
|
474
|
+
for (const option of options) {
|
|
475
|
+
const normalizedOption = normalizeStringAndRemoveStopWords(option);
|
|
476
|
+
console.log(normalizedInput, normalizedOption);
|
|
477
|
+
const distance = levenshteinDistance(normalizedInput, normalizedOption);
|
|
478
|
+
if (distance <= limite) {
|
|
479
|
+
return option;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
return '';
|
|
483
|
+
}
|
|
484
|
+
function normalizeStringAndRemoveStopWords(input, join = '', wordsToRemove = [], minLetters = 1, wordsToInclude = []) {
|
|
485
|
+
if (!input || typeof input !== 'string')
|
|
486
|
+
return '';
|
|
487
|
+
const resultWords = normalizeString(input)
|
|
488
|
+
.replace(/-/g, ' ')
|
|
489
|
+
.replace(/\b(a|o|as|os|e|um|um|uma|of|and|or|for|to|in|at)\b/g, '')
|
|
490
|
+
.replace(/oes\b/g, 'ao')
|
|
491
|
+
.replace(/s\b/g, '')
|
|
492
|
+
.replace(/r\b/g, '')
|
|
493
|
+
.replace(/m\b/g, '')
|
|
494
|
+
.replace(/n\b/g, '')
|
|
495
|
+
.replace(/s\b/g, '')
|
|
496
|
+
.trim()
|
|
497
|
+
.split(' ')
|
|
498
|
+
.filter((word) => word &&
|
|
499
|
+
word.length > minLetters &&
|
|
500
|
+
((!normalizedStopWords.includes(word) &&
|
|
501
|
+
!wordsToRemove.includes(word)) ||
|
|
502
|
+
wordsToInclude.includes(word)));
|
|
503
|
+
const result = [...new Set(resultWords)].join(join).trim() ?? '';
|
|
504
|
+
if (join === '') {
|
|
505
|
+
return result.replace(/\s+/g, '');
|
|
506
|
+
}
|
|
507
|
+
return result;
|
|
508
|
+
}
|
|
509
|
+
function formatWords(palavra, qtdShow, qtdShowInLast = 0, lettersToShow = []) {
|
|
510
|
+
const palavraArray = [...(palavra?.toUpperCase() || '')];
|
|
511
|
+
const newLettersToShow = lettersToShow.map((letter) => letter.toUpperCase());
|
|
512
|
+
const translated = palavraArray.map((char, i) => {
|
|
513
|
+
if (char === ' ' ||
|
|
514
|
+
char === '-' ||
|
|
515
|
+
char === "'" ||
|
|
516
|
+
char === '"' ||
|
|
517
|
+
char === '.' ||
|
|
518
|
+
char === ',' ||
|
|
519
|
+
char === '!' ||
|
|
520
|
+
char === '?' ||
|
|
521
|
+
char === ':' ||
|
|
522
|
+
i < qtdShow ||
|
|
523
|
+
i >= palavraArray.length - qtdShowInLast ||
|
|
524
|
+
(newLettersToShow?.length &&
|
|
525
|
+
newLettersToShow.includes(normalizeString(char)?.toUpperCase()))) {
|
|
526
|
+
return char;
|
|
527
|
+
}
|
|
528
|
+
else {
|
|
529
|
+
return '_';
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
return translated.join(' ').toUpperCase();
|
|
533
|
+
}
|
|
534
|
+
function randomIntFromInterval(min, max) {
|
|
535
|
+
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
536
|
+
}
|
|
537
|
+
function levenshteinDistance(a, b) {
|
|
538
|
+
const dp = [];
|
|
539
|
+
for (let i = 0; i <= a.length; i++) {
|
|
540
|
+
dp[i] = [i];
|
|
541
|
+
}
|
|
542
|
+
for (let j = 1; j <= b.length; j++) {
|
|
543
|
+
dp[0][j] = j;
|
|
544
|
+
}
|
|
545
|
+
for (let i = 1; i <= a.length; i++) {
|
|
546
|
+
for (let j = 1; j <= b.length; j++) {
|
|
547
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
548
|
+
dp[i][j] = Math.min(dp[i - 1][j] + 1, dp[i][j - 1] + 1, dp[i - 1][j - 1] + cost);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
return dp[a.length][b.length];
|
|
552
|
+
}
|
|
553
|
+
function extractNumbersFromString(str) {
|
|
554
|
+
if (!str)
|
|
555
|
+
return '';
|
|
556
|
+
return str.replace(/\D/g, '');
|
|
557
|
+
}
|
|
558
|
+
function getRandomNumber(min, max, notIn = []) {
|
|
559
|
+
const randomNumber = Math.floor(Math.random() * (max - min + 1)) + min;
|
|
560
|
+
if (notIn.includes(randomNumber)) {
|
|
561
|
+
return getRandomNumber(min, max, notIn);
|
|
562
|
+
}
|
|
563
|
+
return randomNumber;
|
|
564
|
+
}
|
|
565
|
+
function mapearParaIntervalo(valorOriginal, minOriginal, maxOriginal, minMapeado, maxMapeado) {
|
|
566
|
+
const percentagem = (valorOriginal - minOriginal) / (maxOriginal - minOriginal);
|
|
567
|
+
const valorMapeado = minMapeado + percentagem * (maxMapeado - minMapeado);
|
|
568
|
+
return valorMapeado;
|
|
569
|
+
}
|
|
570
|
+
function calcularValorOriginal(valorMapeado, minOriginal, maxOriginal, minMapeado, maxMapeado) {
|
|
571
|
+
const percentagem = (valorMapeado - minMapeado) / (maxMapeado - minMapeado);
|
|
572
|
+
const valorOriginal = minOriginal + percentagem * (maxOriginal - minOriginal);
|
|
573
|
+
return valorOriginal;
|
|
574
|
+
}
|
|
575
|
+
function interpolateColor(color1, color2, factor, start = 0, end = 1) {
|
|
576
|
+
const normalizedFactor = mapearParaIntervalo(factor, start, end, 0, 1);
|
|
577
|
+
const hexToRGB = (hex) => ({
|
|
578
|
+
r: parseInt(hex.substring(1, 3), 16),
|
|
579
|
+
g: parseInt(hex.substring(3, 5), 16),
|
|
580
|
+
b: parseInt(hex.substring(5, 7), 16),
|
|
581
|
+
});
|
|
582
|
+
const RGBToHex = (r, g, b) => `#${((1 << 24) | (r << 16) | (g << 8) | b).toString(16).slice(1)}`;
|
|
583
|
+
const startRGB = hexToRGB(color1);
|
|
584
|
+
const endRGB = hexToRGB(color2);
|
|
585
|
+
const r = Math.round(startRGB.r + normalizedFactor * (endRGB.r - startRGB.r));
|
|
586
|
+
const g = Math.round(startRGB.g + normalizedFactor * (endRGB.g - startRGB.g));
|
|
587
|
+
const b = Math.round(startRGB.b + normalizedFactor * (endRGB.b - startRGB.b));
|
|
588
|
+
const result = RGBToHex(r, g, b);
|
|
589
|
+
return result;
|
|
590
|
+
}
|
|
591
|
+
const getRandomName = (ext) => {
|
|
592
|
+
const extension = ext ? '.' + ext : '';
|
|
593
|
+
return `${Math.floor(Math.random() * 10000)}${extension}`;
|
|
594
|
+
};
|
|
595
|
+
exports.getRandomName = getRandomName;
|
|
596
|
+
const makeText = (texto, ...params) => {
|
|
597
|
+
for (let i = 0; i < params.length; i++) {
|
|
598
|
+
const regex = new RegExp(`{p${i + 1}}`, 'g');
|
|
599
|
+
texto = texto.replace(regex, params[i]);
|
|
600
|
+
}
|
|
601
|
+
return texto.replace('@c.us', '').replace('@g.us', '');
|
|
602
|
+
};
|
|
603
|
+
exports.makeText = makeText;
|
|
604
|
+
function getWeightedRandomCard(cards, rarity = 8) {
|
|
605
|
+
const weightedIndices = [];
|
|
606
|
+
cards.forEach((card, index) => {
|
|
607
|
+
const weight = rarity - card.rarity;
|
|
608
|
+
for (let i = 0; i < weight; i++) {
|
|
609
|
+
weightedIndices.push(index);
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
const randomIndex = getRandomNumber(0, weightedIndices.length - 1);
|
|
613
|
+
return cards[weightedIndices[randomIndex]];
|
|
614
|
+
}
|
|
615
|
+
function compareCardOrder(a, b) {
|
|
616
|
+
const orderLetters = [
|
|
617
|
+
'M',
|
|
618
|
+
'W',
|
|
619
|
+
'P',
|
|
620
|
+
'X',
|
|
621
|
+
'R',
|
|
622
|
+
'Y',
|
|
623
|
+
'V',
|
|
624
|
+
'G',
|
|
625
|
+
'N',
|
|
626
|
+
'H',
|
|
627
|
+
'K',
|
|
628
|
+
'T',
|
|
629
|
+
'S',
|
|
630
|
+
'D',
|
|
631
|
+
'B',
|
|
632
|
+
'E',
|
|
633
|
+
];
|
|
634
|
+
const aOrder = orderLetters.indexOf(a.id[0]);
|
|
635
|
+
const bOrder = orderLetters.indexOf(b.id[0]);
|
|
636
|
+
if (aOrder !== bOrder) {
|
|
637
|
+
return aOrder - bOrder;
|
|
638
|
+
}
|
|
639
|
+
const aNumber = parseInt(a.id.slice(1), 10);
|
|
640
|
+
const bNumber = parseInt(b.id.slice(1), 10);
|
|
641
|
+
return aNumber - bNumber;
|
|
642
|
+
}
|
|
643
|
+
function obterNivelTreinador(pontos) {
|
|
644
|
+
if (!pontos)
|
|
645
|
+
return 0;
|
|
646
|
+
let nivel = 0;
|
|
647
|
+
let pontosRestantes = pontos;
|
|
648
|
+
while (pontosRestantes >= calcularXPNecessarioParaProximoNivel(nivel)) {
|
|
649
|
+
pontosRestantes -= calcularXPNecessarioParaProximoNivel(nivel);
|
|
650
|
+
nivel++;
|
|
651
|
+
}
|
|
652
|
+
return nivel;
|
|
653
|
+
}
|
|
654
|
+
function obterLimiteBuddy(level = 0) {
|
|
655
|
+
if (level >= 25)
|
|
656
|
+
return 6;
|
|
657
|
+
if (level >= 20)
|
|
658
|
+
return 5;
|
|
659
|
+
if (level >= 15)
|
|
660
|
+
return 4;
|
|
661
|
+
if (level >= 10)
|
|
662
|
+
return 3;
|
|
663
|
+
if (level >= 5)
|
|
664
|
+
return 2;
|
|
665
|
+
return 1;
|
|
666
|
+
}
|
|
667
|
+
function getValorPatrimonioPoke(pokemon, isShiny = false) {
|
|
668
|
+
if (!pokemon)
|
|
669
|
+
return 0;
|
|
670
|
+
if (checkIsShinyOrDark(pokemon.number)) {
|
|
671
|
+
isShiny = true;
|
|
672
|
+
}
|
|
673
|
+
return Math.floor(((isShiny ? pokemon.valor_patrimonio_shiny : pokemon.valor_patrimonio) ||
|
|
674
|
+
200) * 0.9);
|
|
675
|
+
}
|
|
676
|
+
function getPossePatrimonioPoke(pokemon, isShiny = false) {
|
|
677
|
+
if (!pokemon)
|
|
678
|
+
return 0;
|
|
679
|
+
if (checkIsShinyOrDark(pokemon.number)) {
|
|
680
|
+
isShiny = true;
|
|
681
|
+
}
|
|
682
|
+
return (isShiny ? pokemon.valor_posse_shiny : pokemon.valor_posse) || 200;
|
|
683
|
+
}
|
|
684
|
+
function getValorPokemon(pokemon) {
|
|
685
|
+
if (!pokemon)
|
|
686
|
+
return 9999;
|
|
687
|
+
let valor = pokemon?.real_price || 1500;
|
|
688
|
+
const isShiny = checkIsShiny(pokemon.number);
|
|
689
|
+
const isDark = checkIsDark(pokemon.number);
|
|
690
|
+
if (isShiny) {
|
|
691
|
+
valor += 20;
|
|
692
|
+
}
|
|
693
|
+
if (isDark) {
|
|
694
|
+
valor += 24;
|
|
695
|
+
}
|
|
696
|
+
return isShiny ? valor * 1.9 : isDark ? valor * 2.5 : valor;
|
|
697
|
+
}
|
|
698
|
+
function comparePokemonIds(a, b) {
|
|
699
|
+
if (!a || !b)
|
|
700
|
+
return 0;
|
|
701
|
+
if (!a)
|
|
702
|
+
return -1;
|
|
703
|
+
if (!b)
|
|
704
|
+
return 1;
|
|
705
|
+
const getNumericPrefix = (str) => {
|
|
706
|
+
const match = str.match(/^\d+/);
|
|
707
|
+
return match ? Number(match[0]) : 0;
|
|
708
|
+
};
|
|
709
|
+
const hasS = (str) => /[sd]/.test(str);
|
|
710
|
+
const hasF = (str) => /[fgm]/.test(str);
|
|
711
|
+
const getFNumber = (str) => {
|
|
712
|
+
const match = str.match(/[fgm](\d+)/);
|
|
713
|
+
return match ? Number(match[1]) : null;
|
|
714
|
+
};
|
|
715
|
+
const aNum = getNumericPrefix(a);
|
|
716
|
+
const bNum = getNumericPrefix(b);
|
|
717
|
+
if (aNum !== bNum) {
|
|
718
|
+
return aNum - bNum;
|
|
719
|
+
}
|
|
720
|
+
const aHasS = hasS(a);
|
|
721
|
+
const bHasS = hasS(b);
|
|
722
|
+
const aHasF = hasF(a);
|
|
723
|
+
const bHasF = hasF(b);
|
|
724
|
+
if (!aHasS && !aHasF && !bHasS && !bHasF) {
|
|
725
|
+
return 0;
|
|
726
|
+
}
|
|
727
|
+
if (!aHasS && !aHasF)
|
|
728
|
+
return -1;
|
|
729
|
+
if (!bHasS && !bHasF)
|
|
730
|
+
return 1;
|
|
731
|
+
if (aHasS && !aHasF && bHasS && !bHasF) {
|
|
732
|
+
return 0;
|
|
733
|
+
}
|
|
734
|
+
if (aHasS && !aHasF)
|
|
735
|
+
return -1;
|
|
736
|
+
if (bHasS && !bHasF)
|
|
737
|
+
return 1;
|
|
738
|
+
if (aHasF && bHasF) {
|
|
739
|
+
const aFNum = getFNumber(a) || 0;
|
|
740
|
+
const bFNum = getFNumber(b) || 0;
|
|
741
|
+
if (aFNum !== bFNum) {
|
|
742
|
+
return aFNum - bFNum;
|
|
743
|
+
}
|
|
744
|
+
else {
|
|
745
|
+
return aHasS ? 1 : -1;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
if (aHasF && !bHasF)
|
|
749
|
+
return 1;
|
|
750
|
+
if (!aHasF && bHasF)
|
|
751
|
+
return -1;
|
|
752
|
+
return aHasS ? 1 : -1;
|
|
753
|
+
}
|
|
754
|
+
function premiarPresente(buffed, hasLuck) {
|
|
755
|
+
const rand = Math.random();
|
|
756
|
+
if (rand <= 0.03 && !buffed && !hasLuck) {
|
|
757
|
+
return -3;
|
|
758
|
+
}
|
|
759
|
+
else if (rand > 0.985) {
|
|
760
|
+
return -4;
|
|
761
|
+
}
|
|
762
|
+
else if (rand > 0.96) {
|
|
763
|
+
return -2;
|
|
764
|
+
}
|
|
765
|
+
else if (rand > (buffed && hasLuck ? 0.58 : buffed ? 0.69 : hasLuck ? 0.84 : 0.89)) {
|
|
766
|
+
return -1;
|
|
767
|
+
}
|
|
768
|
+
else {
|
|
769
|
+
if (rand > 0.45 || buffed) {
|
|
770
|
+
return getRandomNumber(75, 150);
|
|
771
|
+
}
|
|
772
|
+
else {
|
|
773
|
+
return getRandomNumber(40, 95);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
function premiarMisteryBox(box, ganhouAnteriormente = false, nerf = false) {
|
|
778
|
+
if (!box)
|
|
779
|
+
return 0;
|
|
780
|
+
const min = (nerf ? Math.round(box.startMoney / 1.5) : box.startMoney) || 100;
|
|
781
|
+
const max = nerf ? Math.round(box.endMoney / 1.25) : box.endMoney;
|
|
782
|
+
if (!ganhouAnteriormente) {
|
|
783
|
+
const percentCard = nerf ? box.percentCard - 0.1 : box.percentCard;
|
|
784
|
+
if (percentCard >= Math.random()) {
|
|
785
|
+
return -1;
|
|
786
|
+
}
|
|
787
|
+
if (box.pokes?.length > 0 && Math.random() > 0.89) {
|
|
788
|
+
return -2;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
return getRandomNumber(min, max);
|
|
792
|
+
}
|
|
793
|
+
function formatPokemonName(pokemon, includeId = false) {
|
|
794
|
+
if (!pokemon?.name)
|
|
795
|
+
return `${includeId ? `[${pokemon?.number ?? '???'}] ` : ''}Desconhecido`;
|
|
796
|
+
return `${includeId ? `[${pokemon.number}] ` : ''}${pokemon.name}${pokemon.form_name ? ` (${pokemon.form_name})` : ''}${checkIsShiny(pokemon.number ?? '') ? ' ✨' : checkIsDark(pokemon.number ?? '') ? ' 🩸' : ''}`;
|
|
797
|
+
}
|
|
798
|
+
function getValueApostaBicho(isMega) {
|
|
799
|
+
return isMega ? 300 : 75;
|
|
800
|
+
}
|
|
801
|
+
function calcPremioBicho(jogoBicho, isMega) {
|
|
802
|
+
const lenApostas = jogoBicho.apostadores?.length ?? 0;
|
|
803
|
+
const aposta = getValueApostaBicho(isMega);
|
|
804
|
+
const valorAcumulado = lenApostas * aposta;
|
|
805
|
+
if ((lenApostas < 12 && !isMega) || lenApostas < 5) {
|
|
806
|
+
return valorAcumulado;
|
|
807
|
+
}
|
|
808
|
+
const participantsDistinct = jogoBicho.apostadores
|
|
809
|
+
.map((apostador) => apostador.user_id)
|
|
810
|
+
.filter((value, index, self) => self.indexOf(value) === index) ?? [];
|
|
811
|
+
const qtdApostadores = participantsDistinct.length;
|
|
812
|
+
let valorAdicional = isMega ? 5000 : 800;
|
|
813
|
+
const qtdToDivide = isMega ? 100 : 16;
|
|
814
|
+
const q = qtdApostadores / 10;
|
|
815
|
+
if (q > 1) {
|
|
816
|
+
valorAdicional += (valorAdicional / 10) * q;
|
|
817
|
+
}
|
|
818
|
+
if (qtdApostadores <= qtdToDivide) {
|
|
819
|
+
const qtdToAdd = Math.floor(valorAdicional / qtdToDivide);
|
|
820
|
+
valorAdicional = qtdToAdd * qtdApostadores;
|
|
821
|
+
}
|
|
822
|
+
return valorAcumulado + valorAdicional;
|
|
823
|
+
}
|
|
824
|
+
function checkIsShiny(id) {
|
|
825
|
+
return /[s]$/i.test(id);
|
|
826
|
+
}
|
|
827
|
+
function checkIsDark(id) {
|
|
828
|
+
return /[d]$/i.test(id);
|
|
829
|
+
}
|
|
830
|
+
function checkIsTera(id) {
|
|
831
|
+
return /[t]$/i.test(id);
|
|
832
|
+
}
|
|
833
|
+
function checkIsShinyOrDark(id) {
|
|
834
|
+
return /[sd]$/i.test(id);
|
|
835
|
+
}
|
|
836
|
+
function checkIsMega(id) {
|
|
837
|
+
return /[m]/i.test(id);
|
|
838
|
+
}
|
|
839
|
+
function checkIsGmax(id) {
|
|
840
|
+
return /[g]/i.test(id);
|
|
841
|
+
}
|
|
842
|
+
function checkIsAlternative(id) {
|
|
843
|
+
return /[fgm]/i.test(id);
|
|
844
|
+
}
|
|
845
|
+
function checkHasPokemon(pokemons, pokemonId, min = 1) {
|
|
846
|
+
const pokemon = (pokemons ?? [])?.find((c) => (c.id ?? '').toLowerCase() === pokemonId.toLowerCase() &&
|
|
847
|
+
(c.quantidade >= min || !min));
|
|
848
|
+
if (!pokemon)
|
|
849
|
+
return null;
|
|
850
|
+
return pokemon;
|
|
851
|
+
}
|
|
852
|
+
function checkHasCard(cards, cardsIds, exactly = false, min = 1) {
|
|
853
|
+
if (!cards?.length)
|
|
854
|
+
return null;
|
|
855
|
+
return cards?.find((c) => cardsIds.some((cardId) => (exactly
|
|
856
|
+
? c.id === cardId
|
|
857
|
+
: c.id.match(new RegExp(`^${cardId}`, 'i'))) && c.quantidade >= min));
|
|
858
|
+
}
|
|
859
|
+
function getDayId(date = new Date(), adjust = true) {
|
|
860
|
+
if (adjust) {
|
|
861
|
+
date.setHours(date.getHours() - 3);
|
|
862
|
+
}
|
|
863
|
+
const year = date.getFullYear();
|
|
864
|
+
let month = (date.getMonth() + 1).toString();
|
|
865
|
+
let day = date.getDate().toString();
|
|
866
|
+
if (month.length === 1)
|
|
867
|
+
month = `0${month}`;
|
|
868
|
+
if (day.length === 1)
|
|
869
|
+
day = `0${day}`;
|
|
870
|
+
return Number(`${year}${month}${day}`);
|
|
871
|
+
}
|
|
872
|
+
const getNumericPrefix = (str) => {
|
|
873
|
+
const extracted = str?.split(/s|d|f|g|m/)[0];
|
|
874
|
+
const match = extracted?.match(/^\d+/);
|
|
875
|
+
return match ? Number(match[0]) : 999999;
|
|
876
|
+
};
|
|
877
|
+
const getNumberInfo = (id) => {
|
|
878
|
+
const numberAfterForm = id.split(/s|d/)?.[0]?.split(/f|g|m/)?.[1] || '0';
|
|
879
|
+
let formIndex = 0;
|
|
880
|
+
if (checkIsAlternative(id)) {
|
|
881
|
+
formIndex++;
|
|
882
|
+
}
|
|
883
|
+
if (checkIsMega(id)) {
|
|
884
|
+
formIndex++;
|
|
885
|
+
}
|
|
886
|
+
if (checkIsGmax(id)) {
|
|
887
|
+
formIndex += 2;
|
|
888
|
+
}
|
|
889
|
+
if (checkIsShiny(id)) {
|
|
890
|
+
formIndex += 0.5;
|
|
891
|
+
}
|
|
892
|
+
if (checkIsDark(id)) {
|
|
893
|
+
formIndex += 0.25;
|
|
894
|
+
}
|
|
895
|
+
return {
|
|
896
|
+
numberAfterForm: Number(numberAfterForm),
|
|
897
|
+
formIndex,
|
|
898
|
+
};
|
|
899
|
+
};
|
|
900
|
+
function compareIds(a, b) {
|
|
901
|
+
if (a == 'BATTLE')
|
|
902
|
+
return -1;
|
|
903
|
+
if (b == 'BATTLE')
|
|
904
|
+
return 1;
|
|
905
|
+
if (!a || !b)
|
|
906
|
+
return 0;
|
|
907
|
+
if (!a)
|
|
908
|
+
return -1;
|
|
909
|
+
if (!b)
|
|
910
|
+
return 1;
|
|
911
|
+
const numA = getNumericPrefix(a);
|
|
912
|
+
const numB = getNumericPrefix(b);
|
|
913
|
+
if (numA !== numB) {
|
|
914
|
+
return numA - numB;
|
|
915
|
+
}
|
|
916
|
+
const numberInfoA = getNumberInfo(a);
|
|
917
|
+
const numberInfoB = getNumberInfo(b);
|
|
918
|
+
if (numberInfoA.numberAfterForm !== numberInfoB.numberAfterForm) {
|
|
919
|
+
return numberInfoA.numberAfterForm - numberInfoB.numberAfterForm;
|
|
920
|
+
}
|
|
921
|
+
if (numberInfoA.formIndex !== numberInfoB.formIndex) {
|
|
922
|
+
return numberInfoA.formIndex - numberInfoB.formIndex;
|
|
923
|
+
}
|
|
924
|
+
return 0;
|
|
925
|
+
}
|
|
926
|
+
function isOwner(contactId) {
|
|
927
|
+
return ['5521975525315@c.us', '5521992287892@c.us'].includes(contactId);
|
|
928
|
+
}
|
|
929
|
+
function checkIsVip(vip) {
|
|
930
|
+
return vip && vip.until && new Date(vip.until) > new Date();
|
|
931
|
+
}
|
|
932
|
+
// export function shuffle(array: any[]) {
|
|
933
|
+
// if (!array || !array.length) return array;
|
|
934
|
+
// for (let i = array.length - 1; i > 0; i--) {
|
|
935
|
+
// const j = Math.floor(Math.random() * (i + 1));
|
|
936
|
+
// [array[i], array[j]] = [array[j], array[i]];
|
|
937
|
+
// }
|
|
938
|
+
// return array;
|
|
939
|
+
// }
|
|
940
|
+
function calcularXPNecessarioParaProximoNivel(nivel) {
|
|
941
|
+
return nivel === 0
|
|
942
|
+
? 185
|
|
943
|
+
: nivel >= 10
|
|
944
|
+
? (nivel + 1) * 235
|
|
945
|
+
: (nivel + 1) * 135 + 50;
|
|
946
|
+
}
|
|
947
|
+
function obterQuantoFaltaParaProximoNivel(pontos) {
|
|
948
|
+
if (!pontos)
|
|
949
|
+
return 0;
|
|
950
|
+
let nivel = 0;
|
|
951
|
+
let pontosRestantes = pontos;
|
|
952
|
+
while (pontosRestantes >= calcularXPNecessarioParaProximoNivel(nivel)) {
|
|
953
|
+
pontosRestantes -= calcularXPNecessarioParaProximoNivel(nivel);
|
|
954
|
+
nivel++;
|
|
955
|
+
}
|
|
956
|
+
return calcularXPNecessarioParaProximoNivel(nivel) - pontosRestantes;
|
|
957
|
+
}
|
|
958
|
+
function streamToBuffer(readableStream) {
|
|
959
|
+
return new Promise((resolve, reject) => {
|
|
960
|
+
const chunks = [];
|
|
961
|
+
readableStream.on('data', (data) => {
|
|
962
|
+
chunks.push(data instanceof Buffer ? data : Buffer.from(data));
|
|
963
|
+
});
|
|
964
|
+
readableStream.on('end', () => {
|
|
965
|
+
resolve(Buffer.concat(chunks));
|
|
966
|
+
});
|
|
967
|
+
readableStream.on('error', reject);
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
function extractContactNumber(contactId) {
|
|
971
|
+
if (!contactId)
|
|
972
|
+
return '';
|
|
973
|
+
return contactId.split('@')[0];
|
|
974
|
+
}
|
|
975
|
+
function isBoolean(value) {
|
|
976
|
+
return (value === 'true' ||
|
|
977
|
+
value === '1' ||
|
|
978
|
+
value === true ||
|
|
979
|
+
value === 'True' ||
|
|
980
|
+
value === 'TRUE' ||
|
|
981
|
+
value === 'T' ||
|
|
982
|
+
Number(value) >= 1);
|
|
983
|
+
}
|
|
984
|
+
function calcSlotValue(slots) {
|
|
985
|
+
const calcValue = slots * 18;
|
|
986
|
+
let valor = calcValue > 999 ? 999 : calcValue;
|
|
987
|
+
if (slots > 90) {
|
|
988
|
+
const qtd = slots - 90;
|
|
989
|
+
valor += qtd * 25;
|
|
990
|
+
}
|
|
991
|
+
return valor;
|
|
992
|
+
}
|
|
993
|
+
function getRandomFromArray(array) {
|
|
994
|
+
if (!array?.length) {
|
|
995
|
+
return null;
|
|
996
|
+
}
|
|
997
|
+
else if (array.length === 1) {
|
|
998
|
+
return array[0];
|
|
999
|
+
}
|
|
1000
|
+
else {
|
|
1001
|
+
return array[Math.floor(Math.random() * array.length)];
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
function calcStars(finalMultiplier) {
|
|
1005
|
+
let qtdEstrelas = Math.floor(finalMultiplier);
|
|
1006
|
+
qtdEstrelas = qtdEstrelas < 1 ? 1 : qtdEstrelas;
|
|
1007
|
+
return qtdEstrelas >= 6 ? 6 : qtdEstrelas < 1 ? 1 : qtdEstrelas;
|
|
1008
|
+
}
|
|
1009
|
+
function formatStars(qtdEstrelas) {
|
|
1010
|
+
qtdEstrelas = Math.floor(qtdEstrelas);
|
|
1011
|
+
if (qtdEstrelas < 1)
|
|
1012
|
+
qtdEstrelas = 1;
|
|
1013
|
+
if (qtdEstrelas > 6)
|
|
1014
|
+
qtdEstrelas = 6;
|
|
1015
|
+
let starEmoji = '⭐';
|
|
1016
|
+
if (qtdEstrelas > 5) {
|
|
1017
|
+
starEmoji = '🌟';
|
|
1018
|
+
}
|
|
1019
|
+
let stars = '';
|
|
1020
|
+
for (let i = 0; i < qtdEstrelas; i++) {
|
|
1021
|
+
stars += starEmoji;
|
|
1022
|
+
}
|
|
1023
|
+
return stars;
|
|
1024
|
+
}
|
|
1025
|
+
function calcXpByStars(stars, xp) {
|
|
1026
|
+
const level = obterNivelTreinador(xp);
|
|
1027
|
+
const mapXp = {
|
|
1028
|
+
0: 15,
|
|
1029
|
+
1: 30,
|
|
1030
|
+
2: 40,
|
|
1031
|
+
3: 60,
|
|
1032
|
+
4: 80,
|
|
1033
|
+
5: 110,
|
|
1034
|
+
6: 150,
|
|
1035
|
+
};
|
|
1036
|
+
let result = mapXp[stars] ?? 50;
|
|
1037
|
+
result += Math.round((result * level) / 100);
|
|
1038
|
+
return Math.round(result);
|
|
1039
|
+
}
|
|
1040
|
+
function cleanObject(obj, options) {
|
|
1041
|
+
const { removeFalse = false, removeEmptyArrays = true, removeEmptyObjects = true, removeZero = false, removeLowerThanZero = false, } = options || {};
|
|
1042
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
1043
|
+
const shouldRemove = value === undefined ||
|
|
1044
|
+
value === null ||
|
|
1045
|
+
value === '' ||
|
|
1046
|
+
(removeFalse && value === false) ||
|
|
1047
|
+
(removeZero && value === 0) ||
|
|
1048
|
+
(removeLowerThanZero && value < 0) ||
|
|
1049
|
+
(removeEmptyArrays && Array.isArray(value) && value.length === 0) ||
|
|
1050
|
+
(removeEmptyObjects &&
|
|
1051
|
+
typeof value === 'object' &&
|
|
1052
|
+
!Array.isArray(value) &&
|
|
1053
|
+
value !== null &&
|
|
1054
|
+
Object.keys(value).length === 0);
|
|
1055
|
+
if (!shouldRemove) {
|
|
1056
|
+
if (typeof value === 'object' &&
|
|
1057
|
+
value !== null &&
|
|
1058
|
+
!Array.isArray(value)) {
|
|
1059
|
+
acc[key] = cleanObject(value, options);
|
|
1060
|
+
}
|
|
1061
|
+
else {
|
|
1062
|
+
acc[key] = value;
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
return acc;
|
|
1066
|
+
}, {});
|
|
1067
|
+
}
|
|
1068
|
+
function getErrorMessage(error, logMessage) {
|
|
1069
|
+
let errorMessage = 'Erro desconhecido';
|
|
1070
|
+
if (typeof error === 'string') {
|
|
1071
|
+
errorMessage = error;
|
|
1072
|
+
}
|
|
1073
|
+
else if (error instanceof Error) {
|
|
1074
|
+
errorMessage = error.message;
|
|
1075
|
+
}
|
|
1076
|
+
else if (typeof error === 'object' && error !== null) {
|
|
1077
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1078
|
+
const anyError = error;
|
|
1079
|
+
// NestJS HttpException ou errors do tipo { message: string | string[] }
|
|
1080
|
+
if (anyError.message) {
|
|
1081
|
+
if (Array.isArray(anyError.message)) {
|
|
1082
|
+
errorMessage = anyError.message.join(', ');
|
|
1083
|
+
}
|
|
1084
|
+
else {
|
|
1085
|
+
errorMessage = String(anyError.message);
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
// AxiosError com response.data.message
|
|
1089
|
+
else if (anyError.response?.data?.message) {
|
|
1090
|
+
errorMessage = Array.isArray(anyError.response.data.message)
|
|
1091
|
+
? anyError.response.data.message.join(', ')
|
|
1092
|
+
: String(anyError.response.data.message);
|
|
1093
|
+
}
|
|
1094
|
+
// AxiosError com response.data.error
|
|
1095
|
+
else if (anyError.response?.data?.error) {
|
|
1096
|
+
errorMessage = String(anyError.response.data.error);
|
|
1097
|
+
}
|
|
1098
|
+
// Errors do tipo { error: '...' }
|
|
1099
|
+
else if (anyError.error) {
|
|
1100
|
+
errorMessage = String(anyError.error);
|
|
1101
|
+
}
|
|
1102
|
+
// Fallback: tenta stringify o objeto
|
|
1103
|
+
else {
|
|
1104
|
+
errorMessage = JSON.stringify(anyError);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
if (logMessage) {
|
|
1108
|
+
if (typeof logMessage === 'string') {
|
|
1109
|
+
console.error(logMessage, errorMessage, error);
|
|
1110
|
+
}
|
|
1111
|
+
else {
|
|
1112
|
+
console.error(errorMessage, error?.stack);
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
return errorMessage;
|
|
1116
|
+
}
|
|
1117
|
+
function assignPosition(array, key, positionKey) {
|
|
1118
|
+
array
|
|
1119
|
+
.sort((a, b) => Number(b[key]) - Number(a[key]))
|
|
1120
|
+
.forEach((e, i) => {
|
|
1121
|
+
e[positionKey] = (i + 1);
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
async function timeout(ms) {
|
|
1125
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1126
|
+
}
|
|
1127
|
+
exports.pornWords = [
|
|
1128
|
+
'anus',
|
|
1129
|
+
'arrombado',
|
|
1130
|
+
'boceta',
|
|
1131
|
+
'boiola',
|
|
1132
|
+
'bokete',
|
|
1133
|
+
'bolagato',
|
|
1134
|
+
'bolcat',
|
|
1135
|
+
'boquete',
|
|
1136
|
+
'bosseta',
|
|
1137
|
+
'branquelo',
|
|
1138
|
+
'brecha',
|
|
1139
|
+
'brexa',
|
|
1140
|
+
'brioco',
|
|
1141
|
+
'bronha',
|
|
1142
|
+
'buceta',
|
|
1143
|
+
'bugre',
|
|
1144
|
+
'bunda',
|
|
1145
|
+
'bunduda',
|
|
1146
|
+
'busseta',
|
|
1147
|
+
'bárbaro',
|
|
1148
|
+
'caceta',
|
|
1149
|
+
'cacete',
|
|
1150
|
+
'caipira',
|
|
1151
|
+
'canalha',
|
|
1152
|
+
'canceroso',
|
|
1153
|
+
'caralho',
|
|
1154
|
+
'casseta',
|
|
1155
|
+
'cassete',
|
|
1156
|
+
'checheca',
|
|
1157
|
+
'chereca',
|
|
1158
|
+
'chibumba',
|
|
1159
|
+
'chochota',
|
|
1160
|
+
'chota',
|
|
1161
|
+
'chupada',
|
|
1162
|
+
'chupado',
|
|
1163
|
+
'clitoris',
|
|
1164
|
+
'clitóris',
|
|
1165
|
+
'culhao',
|
|
1166
|
+
'culhão',
|
|
1167
|
+
'curalho',
|
|
1168
|
+
'cuzao',
|
|
1169
|
+
'cuzão',
|
|
1170
|
+
'cuzuda',
|
|
1171
|
+
'escrota',
|
|
1172
|
+
'escroto',
|
|
1173
|
+
'esporrada',
|
|
1174
|
+
'esporrado',
|
|
1175
|
+
'esporro',
|
|
1176
|
+
'fodida',
|
|
1177
|
+
'fodido',
|
|
1178
|
+
'fornica',
|
|
1179
|
+
'fornicação',
|
|
1180
|
+
'fornição',
|
|
1181
|
+
'fudendo',
|
|
1182
|
+
'fudeção',
|
|
1183
|
+
'fudida',
|
|
1184
|
+
'fudido',
|
|
1185
|
+
'furada',
|
|
1186
|
+
'furado',
|
|
1187
|
+
'furnica',
|
|
1188
|
+
'furnicar',
|
|
1189
|
+
'gonorrea',
|
|
1190
|
+
'gonorreia',
|
|
1191
|
+
'gonorreia',
|
|
1192
|
+
'grelinho',
|
|
1193
|
+
'grelo',
|
|
1194
|
+
'leprosa',
|
|
1195
|
+
'leproso',
|
|
1196
|
+
'masturba',
|
|
1197
|
+
'merda',
|
|
1198
|
+
'mija',
|
|
1199
|
+
'mijada',
|
|
1200
|
+
'mijado',
|
|
1201
|
+
'mijo',
|
|
1202
|
+
'nhaca',
|
|
1203
|
+
'nojeira',
|
|
1204
|
+
'gore',
|
|
1205
|
+
'pau',
|
|
1206
|
+
'pelado',
|
|
1207
|
+
'pelada',
|
|
1208
|
+
'nua',
|
|
1209
|
+
'pemba',
|
|
1210
|
+
'pentelha',
|
|
1211
|
+
'pentelho',
|
|
1212
|
+
'perereca',
|
|
1213
|
+
'perneta',
|
|
1214
|
+
'peru',
|
|
1215
|
+
'peão',
|
|
1216
|
+
'pica',
|
|
1217
|
+
'picao',
|
|
1218
|
+
'picão',
|
|
1219
|
+
'pilantra',
|
|
1220
|
+
'pinel',
|
|
1221
|
+
'pintudo',
|
|
1222
|
+
'pintão',
|
|
1223
|
+
'piroca',
|
|
1224
|
+
'piroco',
|
|
1225
|
+
'piru',
|
|
1226
|
+
'prega',
|
|
1227
|
+
'prequito',
|
|
1228
|
+
'priquito',
|
|
1229
|
+
'prostibulo',
|
|
1230
|
+
'prostituta',
|
|
1231
|
+
'prostituto',
|
|
1232
|
+
'punheta',
|
|
1233
|
+
'punhetao',
|
|
1234
|
+
'punhetão',
|
|
1235
|
+
'pustula',
|
|
1236
|
+
'puta',
|
|
1237
|
+
'piroca',
|
|
1238
|
+
'penis',
|
|
1239
|
+
'porno',
|
|
1240
|
+
'prolapse',
|
|
1241
|
+
'prostituta',
|
|
1242
|
+
'rabao',
|
|
1243
|
+
'rabão',
|
|
1244
|
+
'rabo',
|
|
1245
|
+
'rabuda',
|
|
1246
|
+
'rabudao',
|
|
1247
|
+
'rabudão',
|
|
1248
|
+
'rabudo',
|
|
1249
|
+
'rabudona',
|
|
1250
|
+
'rachada',
|
|
1251
|
+
'rola',
|
|
1252
|
+
'rolinha',
|
|
1253
|
+
'sacana',
|
|
1254
|
+
'safada',
|
|
1255
|
+
'safado',
|
|
1256
|
+
'sapatao',
|
|
1257
|
+
'sapatão',
|
|
1258
|
+
'sifilis',
|
|
1259
|
+
'sífilis',
|
|
1260
|
+
'siririca',
|
|
1261
|
+
'tarada',
|
|
1262
|
+
'tarado',
|
|
1263
|
+
'testuda',
|
|
1264
|
+
'transa',
|
|
1265
|
+
'tesuda',
|
|
1266
|
+
'tesudo',
|
|
1267
|
+
'tesão',
|
|
1268
|
+
'tezao',
|
|
1269
|
+
'tezuda',
|
|
1270
|
+
'tezudo',
|
|
1271
|
+
'traveco',
|
|
1272
|
+
'vadia',
|
|
1273
|
+
'vagina',
|
|
1274
|
+
'xana',
|
|
1275
|
+
'xaninha',
|
|
1276
|
+
'xavasca',
|
|
1277
|
+
'xerereca',
|
|
1278
|
+
'xexeca',
|
|
1279
|
+
'xibiu',
|
|
1280
|
+
'xibumba',
|
|
1281
|
+
'xiíta',
|
|
1282
|
+
'xochota',
|
|
1283
|
+
'xota',
|
|
1284
|
+
'xoxota',
|
|
1285
|
+
'sexo',
|
|
1286
|
+
'pornhub',
|
|
1287
|
+
'xvideos',
|
|
1288
|
+
'redtube',
|
|
1289
|
+
'xxx',
|
|
1290
|
+
'cumshot',
|
|
1291
|
+
'dildo',
|
|
1292
|
+
'anal',
|
|
1293
|
+
'porn',
|
|
1294
|
+
'mature',
|
|
1295
|
+
'sex',
|
|
1296
|
+
'xx',
|
|
1297
|
+
'bbw',
|
|
1298
|
+
'slut',
|
|
1299
|
+
'whore',
|
|
1300
|
+
'tits',
|
|
1301
|
+
'titty',
|
|
1302
|
+
'titties',
|
|
1303
|
+
'pussy',
|
|
1304
|
+
'sperm',
|
|
1305
|
+
'cheat',
|
|
1306
|
+
'booty',
|
|
1307
|
+
'ebony',
|
|
1308
|
+
'asian',
|
|
1309
|
+
'brazilian',
|
|
1310
|
+
'fuck',
|
|
1311
|
+
'cock',
|
|
1312
|
+
'cunt',
|
|
1313
|
+
'lesbian',
|
|
1314
|
+
'shemale',
|
|
1315
|
+
'boob',
|
|
1316
|
+
'boobies',
|
|
1317
|
+
'boobs',
|
|
1318
|
+
'naughty',
|
|
1319
|
+
'fatty',
|
|
1320
|
+
'bitch',
|
|
1321
|
+
'granny',
|
|
1322
|
+
'jizz',
|
|
1323
|
+
'faggot',
|
|
1324
|
+
'horny',
|
|
1325
|
+
'bukakke',
|
|
1326
|
+
'bdsm',
|
|
1327
|
+
'vagina',
|
|
1328
|
+
'smut',
|
|
1329
|
+
'x-rated',
|
|
1330
|
+
'lusty',
|
|
1331
|
+
'erotic',
|
|
1332
|
+
'cunnilingus',
|
|
1333
|
+
'blowjob',
|
|
1334
|
+
'panty',
|
|
1335
|
+
'hentai',
|
|
1336
|
+
'latex',
|
|
1337
|
+
'fetisch',
|
|
1338
|
+
'fetish',
|
|
1339
|
+
'erotik',
|
|
1340
|
+
'erotic',
|
|
1341
|
+
'bondage',
|
|
1342
|
+
'naked',
|
|
1343
|
+
'strip',
|
|
1344
|
+
'mature',
|
|
1345
|
+
'stocking',
|
|
1346
|
+
'coitus',
|
|
1347
|
+
'depraved',
|
|
1348
|
+
'tube',
|
|
1349
|
+
'perverse',
|
|
1350
|
+
'rectal',
|
|
1351
|
+
'prolapse',
|
|
1352
|
+
'hentai',
|
|
1353
|
+
'calcinha',
|
|
1354
|
+
'calc',
|
|
1355
|
+
'cow',
|
|
1356
|
+
'dick',
|
|
1357
|
+
'moaning',
|
|
1358
|
+
'orgy',
|
|
1359
|
+
'threesome',
|
|
1360
|
+
];
|
|
1361
|
+
exports.stopWords = [
|
|
1362
|
+
'de',
|
|
1363
|
+
'a',
|
|
1364
|
+
'o',
|
|
1365
|
+
'que',
|
|
1366
|
+
'e',
|
|
1367
|
+
'do',
|
|
1368
|
+
'da',
|
|
1369
|
+
'em',
|
|
1370
|
+
'um',
|
|
1371
|
+
'para',
|
|
1372
|
+
'é',
|
|
1373
|
+
'com',
|
|
1374
|
+
'uma',
|
|
1375
|
+
'os',
|
|
1376
|
+
'no',
|
|
1377
|
+
'se',
|
|
1378
|
+
'na',
|
|
1379
|
+
'por',
|
|
1380
|
+
'mais',
|
|
1381
|
+
'as',
|
|
1382
|
+
'dos',
|
|
1383
|
+
'como',
|
|
1384
|
+
'mas',
|
|
1385
|
+
'foi',
|
|
1386
|
+
'ao',
|
|
1387
|
+
'ele',
|
|
1388
|
+
'das',
|
|
1389
|
+
'tem',
|
|
1390
|
+
'à',
|
|
1391
|
+
'seu',
|
|
1392
|
+
'sua',
|
|
1393
|
+
'ou',
|
|
1394
|
+
'ser',
|
|
1395
|
+
'quando',
|
|
1396
|
+
'muito',
|
|
1397
|
+
'há',
|
|
1398
|
+
'nos',
|
|
1399
|
+
'já',
|
|
1400
|
+
'está',
|
|
1401
|
+
'eu',
|
|
1402
|
+
'também',
|
|
1403
|
+
'só',
|
|
1404
|
+
'pelo',
|
|
1405
|
+
'pela',
|
|
1406
|
+
'até',
|
|
1407
|
+
'isso',
|
|
1408
|
+
'ela',
|
|
1409
|
+
'entre',
|
|
1410
|
+
'era',
|
|
1411
|
+
'depois',
|
|
1412
|
+
'mesmo',
|
|
1413
|
+
'aos',
|
|
1414
|
+
'ter',
|
|
1415
|
+
'seus',
|
|
1416
|
+
'quem',
|
|
1417
|
+
'nas',
|
|
1418
|
+
'me',
|
|
1419
|
+
'esse',
|
|
1420
|
+
'eles',
|
|
1421
|
+
'estão',
|
|
1422
|
+
'você',
|
|
1423
|
+
'vc',
|
|
1424
|
+
'tinha',
|
|
1425
|
+
'foram',
|
|
1426
|
+
'essa',
|
|
1427
|
+
'num',
|
|
1428
|
+
'nem',
|
|
1429
|
+
'suas',
|
|
1430
|
+
'meu',
|
|
1431
|
+
'às',
|
|
1432
|
+
'minha',
|
|
1433
|
+
'têm',
|
|
1434
|
+
'numa',
|
|
1435
|
+
'pelos',
|
|
1436
|
+
'elas',
|
|
1437
|
+
'havia',
|
|
1438
|
+
'seja',
|
|
1439
|
+
'qual',
|
|
1440
|
+
'será',
|
|
1441
|
+
'nós',
|
|
1442
|
+
'tenho',
|
|
1443
|
+
'não',
|
|
1444
|
+
'nao',
|
|
1445
|
+
'lhe',
|
|
1446
|
+
'deles',
|
|
1447
|
+
'essas',
|
|
1448
|
+
'esses',
|
|
1449
|
+
'pelas',
|
|
1450
|
+
'este',
|
|
1451
|
+
'fosse',
|
|
1452
|
+
'dele',
|
|
1453
|
+
'tu',
|
|
1454
|
+
'te',
|
|
1455
|
+
'vocês',
|
|
1456
|
+
'vos',
|
|
1457
|
+
'lhes',
|
|
1458
|
+
'meus',
|
|
1459
|
+
'minhas',
|
|
1460
|
+
'teu',
|
|
1461
|
+
'tua',
|
|
1462
|
+
'teus',
|
|
1463
|
+
'tuas',
|
|
1464
|
+
'nosso',
|
|
1465
|
+
'nossa',
|
|
1466
|
+
'nossos',
|
|
1467
|
+
'nossas',
|
|
1468
|
+
'dela',
|
|
1469
|
+
'delas',
|
|
1470
|
+
'esta',
|
|
1471
|
+
'estes',
|
|
1472
|
+
'estas',
|
|
1473
|
+
'aquele',
|
|
1474
|
+
'aquela',
|
|
1475
|
+
'aqueles',
|
|
1476
|
+
'aquelas',
|
|
1477
|
+
'isto',
|
|
1478
|
+
'aquilo',
|
|
1479
|
+
'estou',
|
|
1480
|
+
'está',
|
|
1481
|
+
'estamos',
|
|
1482
|
+
'estão',
|
|
1483
|
+
'estive',
|
|
1484
|
+
'esteve',
|
|
1485
|
+
'estivemos',
|
|
1486
|
+
'estiveram',
|
|
1487
|
+
'estava',
|
|
1488
|
+
'estávamos',
|
|
1489
|
+
'estavam',
|
|
1490
|
+
'estivera',
|
|
1491
|
+
'estivéramos',
|
|
1492
|
+
'esteja',
|
|
1493
|
+
'estejamos',
|
|
1494
|
+
'estejam',
|
|
1495
|
+
'estivesse',
|
|
1496
|
+
'estivéssemos',
|
|
1497
|
+
'estivessem',
|
|
1498
|
+
'estiver',
|
|
1499
|
+
'estivermos',
|
|
1500
|
+
'estiverem',
|
|
1501
|
+
'hei',
|
|
1502
|
+
'há',
|
|
1503
|
+
'havemos',
|
|
1504
|
+
'hão',
|
|
1505
|
+
'houve',
|
|
1506
|
+
'houvemos',
|
|
1507
|
+
'houveram',
|
|
1508
|
+
'houvera',
|
|
1509
|
+
'houvéramos',
|
|
1510
|
+
'haja',
|
|
1511
|
+
'hajamos',
|
|
1512
|
+
'hajam',
|
|
1513
|
+
'houvesse',
|
|
1514
|
+
'houvéssemos',
|
|
1515
|
+
'houvessem',
|
|
1516
|
+
'houver',
|
|
1517
|
+
'houvermos',
|
|
1518
|
+
'houverem',
|
|
1519
|
+
'houverei',
|
|
1520
|
+
'houverá',
|
|
1521
|
+
'houveremos',
|
|
1522
|
+
'houverão',
|
|
1523
|
+
'houveria',
|
|
1524
|
+
'houveríamos',
|
|
1525
|
+
'houveriam',
|
|
1526
|
+
'sou',
|
|
1527
|
+
'somos',
|
|
1528
|
+
'são',
|
|
1529
|
+
'era',
|
|
1530
|
+
'éramos',
|
|
1531
|
+
'eram',
|
|
1532
|
+
'fui',
|
|
1533
|
+
'foi',
|
|
1534
|
+
'fomos',
|
|
1535
|
+
'foram',
|
|
1536
|
+
'fora',
|
|
1537
|
+
'fôramos',
|
|
1538
|
+
'seja',
|
|
1539
|
+
'sejamos',
|
|
1540
|
+
'sejam',
|
|
1541
|
+
'fosse',
|
|
1542
|
+
'fôssemos',
|
|
1543
|
+
'fossem',
|
|
1544
|
+
'for',
|
|
1545
|
+
'formos',
|
|
1546
|
+
'forem',
|
|
1547
|
+
'serei',
|
|
1548
|
+
'será',
|
|
1549
|
+
'seremos',
|
|
1550
|
+
'serão',
|
|
1551
|
+
'seria',
|
|
1552
|
+
'seríamos',
|
|
1553
|
+
'seriam',
|
|
1554
|
+
'temos',
|
|
1555
|
+
'tém',
|
|
1556
|
+
'tínhamos',
|
|
1557
|
+
'tinham',
|
|
1558
|
+
'tive',
|
|
1559
|
+
'teve',
|
|
1560
|
+
'tivemos',
|
|
1561
|
+
'tiveram',
|
|
1562
|
+
'tivera',
|
|
1563
|
+
'tivéramos',
|
|
1564
|
+
'tenha',
|
|
1565
|
+
'tenhamos',
|
|
1566
|
+
'tenham',
|
|
1567
|
+
'tivesse',
|
|
1568
|
+
'tivéssemos',
|
|
1569
|
+
'tivessem',
|
|
1570
|
+
'tiver',
|
|
1571
|
+
'tivermos',
|
|
1572
|
+
'tiverem',
|
|
1573
|
+
'terei',
|
|
1574
|
+
'terá',
|
|
1575
|
+
'teremos',
|
|
1576
|
+
'terão',
|
|
1577
|
+
'teria',
|
|
1578
|
+
'teríamos',
|
|
1579
|
+
'teriam',
|
|
1580
|
+
'vc',
|
|
1581
|
+
'tb',
|
|
1582
|
+
'q',
|
|
1583
|
+
'n',
|
|
1584
|
+
'cmg',
|
|
1585
|
+
'p',
|
|
1586
|
+
'eh',
|
|
1587
|
+
'mt',
|
|
1588
|
+
'td',
|
|
1589
|
+
'pra',
|
|
1590
|
+
'pro',
|
|
1591
|
+
'the',
|
|
1592
|
+
'of',
|
|
1593
|
+
'and',
|
|
1594
|
+
'or',
|
|
1595
|
+
'for',
|
|
1596
|
+
'to',
|
|
1597
|
+
'in',
|
|
1598
|
+
'at',
|
|
1599
|
+
'the',
|
|
1600
|
+
'i',
|
|
1601
|
+
'me',
|
|
1602
|
+
'my',
|
|
1603
|
+
'myself',
|
|
1604
|
+
'we',
|
|
1605
|
+
'our',
|
|
1606
|
+
'ours',
|
|
1607
|
+
'ourselves',
|
|
1608
|
+
'you',
|
|
1609
|
+
'your',
|
|
1610
|
+
'yours',
|
|
1611
|
+
'yourself',
|
|
1612
|
+
'yourselves',
|
|
1613
|
+
'he',
|
|
1614
|
+
'him',
|
|
1615
|
+
'his',
|
|
1616
|
+
'himself',
|
|
1617
|
+
'she',
|
|
1618
|
+
'her',
|
|
1619
|
+
'hers',
|
|
1620
|
+
'herself',
|
|
1621
|
+
'it',
|
|
1622
|
+
'its',
|
|
1623
|
+
'itself',
|
|
1624
|
+
'they',
|
|
1625
|
+
'them',
|
|
1626
|
+
'their',
|
|
1627
|
+
'theirs',
|
|
1628
|
+
'themselves',
|
|
1629
|
+
'what',
|
|
1630
|
+
'which',
|
|
1631
|
+
'who',
|
|
1632
|
+
'whom',
|
|
1633
|
+
'this',
|
|
1634
|
+
'that',
|
|
1635
|
+
'these',
|
|
1636
|
+
'those',
|
|
1637
|
+
'am',
|
|
1638
|
+
'is',
|
|
1639
|
+
'are',
|
|
1640
|
+
'was',
|
|
1641
|
+
'were',
|
|
1642
|
+
'be',
|
|
1643
|
+
'been',
|
|
1644
|
+
'being',
|
|
1645
|
+
'have',
|
|
1646
|
+
'has',
|
|
1647
|
+
'had',
|
|
1648
|
+
'having',
|
|
1649
|
+
'do',
|
|
1650
|
+
'does',
|
|
1651
|
+
'did',
|
|
1652
|
+
'doing',
|
|
1653
|
+
'a',
|
|
1654
|
+
'an',
|
|
1655
|
+
'the',
|
|
1656
|
+
'and',
|
|
1657
|
+
'but',
|
|
1658
|
+
'if',
|
|
1659
|
+
'or',
|
|
1660
|
+
'because',
|
|
1661
|
+
'as',
|
|
1662
|
+
'until',
|
|
1663
|
+
'while',
|
|
1664
|
+
'of',
|
|
1665
|
+
'at',
|
|
1666
|
+
'by',
|
|
1667
|
+
'for',
|
|
1668
|
+
'with',
|
|
1669
|
+
'about',
|
|
1670
|
+
'against',
|
|
1671
|
+
'between',
|
|
1672
|
+
'into',
|
|
1673
|
+
'through',
|
|
1674
|
+
'during',
|
|
1675
|
+
'before',
|
|
1676
|
+
'after',
|
|
1677
|
+
'above',
|
|
1678
|
+
'below',
|
|
1679
|
+
'to',
|
|
1680
|
+
'from',
|
|
1681
|
+
'up',
|
|
1682
|
+
'down',
|
|
1683
|
+
'in',
|
|
1684
|
+
'out',
|
|
1685
|
+
'on',
|
|
1686
|
+
'off',
|
|
1687
|
+
'over',
|
|
1688
|
+
'under',
|
|
1689
|
+
'again',
|
|
1690
|
+
'further',
|
|
1691
|
+
'then',
|
|
1692
|
+
'once',
|
|
1693
|
+
'here',
|
|
1694
|
+
'there',
|
|
1695
|
+
'when',
|
|
1696
|
+
'where',
|
|
1697
|
+
'why',
|
|
1698
|
+
'how',
|
|
1699
|
+
'all',
|
|
1700
|
+
'any',
|
|
1701
|
+
'both',
|
|
1702
|
+
'each',
|
|
1703
|
+
'few',
|
|
1704
|
+
'more',
|
|
1705
|
+
'most',
|
|
1706
|
+
'other',
|
|
1707
|
+
'some',
|
|
1708
|
+
'such',
|
|
1709
|
+
'no',
|
|
1710
|
+
'nor',
|
|
1711
|
+
'not',
|
|
1712
|
+
'only',
|
|
1713
|
+
'own',
|
|
1714
|
+
'same',
|
|
1715
|
+
'so',
|
|
1716
|
+
'than',
|
|
1717
|
+
'too',
|
|
1718
|
+
'very',
|
|
1719
|
+
'wa',
|
|
1720
|
+
'wo',
|
|
1721
|
+
];
|
|
1722
|
+
function getActualMonth(desloc = 0) {
|
|
1723
|
+
const currentDate = new Date();
|
|
1724
|
+
const currentMonth = currentDate.getMonth();
|
|
1725
|
+
if (desloc) {
|
|
1726
|
+
return (currentMonth - desloc + 12) % 12;
|
|
1727
|
+
}
|
|
1728
|
+
return currentMonth;
|
|
1729
|
+
}
|
|
1730
|
+
function checkGuess(input, real, limite = 2) {
|
|
1731
|
+
const normalizedInput = normalizeStringAndRemoveStopWords(input);
|
|
1732
|
+
const normalizedMovieName = normalizeStringAndRemoveStopWords(real);
|
|
1733
|
+
limite = input.length <= 5 && limite >= 2 ? limite - 1 : limite;
|
|
1734
|
+
const distance = levenshteinDistance(normalizedInput, normalizedMovieName);
|
|
1735
|
+
return distance <= limite;
|
|
1736
|
+
}
|
|
1737
|
+
const messagesErro = [
|
|
1738
|
+
'[❗] Putz, deu ruim aí, erro no comando.\nTenta de novo mais tarde, quem sabe cola, né?',
|
|
1739
|
+
'[❗] Pô, que zica! Deu um bug no comando, mané.\nMelhor tentar outra hora.',
|
|
1740
|
+
'[❗] Ih rapaz, alguma coisa deu tilt aí.\nComando foi pro beleléu.\nDá um tempo ai e tenta de novo.',
|
|
1741
|
+
'[❗] Ah, não! Deu uma falha aí, comando foi pro espaço.\nDá um tempo e tenta de novo, talvez role.',
|
|
1742
|
+
'[❗] Opa, que vacilo! Parece que o comando pirou.\nDá um refresco e tenta outra hora.',
|
|
1743
|
+
'[❗] Eita, deu um crash aí! Comando se perdeu.\nDescansa e tenta dar uma chance depois.',
|
|
1744
|
+
'[❗] Xii, deu zebra! Comando não foi na onda.\nRelaxa e tenta mais tarde, pode colar.',
|
|
1745
|
+
'[❗] Caramba, erro aí no comando, mané! Bateu um bug.\nDescansa e tenta refazer mais tarde.',
|
|
1746
|
+
'[❗] Oxi, que coisa! Comando se embolou.\nTenta dar um tempo e refazer mais tarde.',
|
|
1747
|
+
'[❗] Ah, que bad! Deu tilt no comando, não foi na moral.\nRelaxa e tenta de novo depois.',
|
|
1748
|
+
'[❗] Putz, o comando deu ruim.\nDescansa e tenta dar uma chance depois.',
|
|
1749
|
+
'[❗] Vish, que sinistro! Comando fez o role errado.\nDá um tempo aí e tenta de novo.',
|
|
1750
|
+
'[❗] Eita, deu ruim! Comando deu mole.\nRelaxa e tenta refazer mais tarde.',
|
|
1751
|
+
'[❗] Ih, o bagulho deu uma bugada! Comando não foi na manha.\nDá um descanso e tenta mais tarde.',
|
|
1752
|
+
'[❗] Puts, deu tilt no comando.\nTenta recarregar depois, quem sabe dá certo.',
|
|
1753
|
+
'[❗] Ah, que zica! Comando deu uma pane.\nRelaxa e tenta dar um replay mais tarde.',
|
|
1754
|
+
'[❗] Caramba, erro aí no comando, brother! Deu uma bugada.\nDá um tempo e tenta de novo.',
|
|
1755
|
+
'[❗] Ih, rapaz! Comando deu uns rolinhos.\nDescansa e tenta refazer mais tarde.',
|
|
1756
|
+
'[❗] Xiii, deu uma zebra aí! Comando não foi na onda.\nRelaxa e tenta dar um replay depois.',
|
|
1757
|
+
'[❗] Pô, que vacilo! Comando deu um tilt.\nDescansa e tenta de novo mais tarde.',
|
|
1758
|
+
];
|
|
1759
|
+
function getRandomErroMessage() {
|
|
1760
|
+
return messagesErro[Math.floor(Math.random() * messagesErro.length)];
|
|
1761
|
+
}
|
|
1762
|
+
async function timeoutPromise(timeoutNumber, timeoutMessage = 'Timeout') {
|
|
1763
|
+
setTimeout(() => {
|
|
1764
|
+
throw new Error(timeoutMessage);
|
|
1765
|
+
}, timeoutNumber);
|
|
1766
|
+
}
|
|
1767
|
+
const timestampToDate = (timestampMsg) => {
|
|
1768
|
+
const date = new Date(timestampMsg);
|
|
1769
|
+
const dateFormatted = date.toLocaleString('pt-BR', {
|
|
1770
|
+
timeZone: 'America/Sao_Paulo',
|
|
1771
|
+
hour12: false,
|
|
1772
|
+
day: '2-digit',
|
|
1773
|
+
month: '2-digit',
|
|
1774
|
+
year: 'numeric',
|
|
1775
|
+
});
|
|
1776
|
+
return dateFormatted;
|
|
1777
|
+
};
|
|
1778
|
+
exports.timestampToDate = timestampToDate;
|
|
1779
|
+
function convertTime(hms) {
|
|
1780
|
+
if (hms.length < 3) {
|
|
1781
|
+
return hms;
|
|
1782
|
+
}
|
|
1783
|
+
else if (hms.length < 6) {
|
|
1784
|
+
const a = hms.split(':');
|
|
1785
|
+
return (hms = +a[0] * 60 + +a[1]);
|
|
1786
|
+
}
|
|
1787
|
+
else {
|
|
1788
|
+
const a = hms.split(':');
|
|
1789
|
+
return (hms = +a[0] * 60 * 60 + +a[1] * 60 + +a[2]);
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
function getLinkRegex(filter) {
|
|
1793
|
+
const regexMap = {
|
|
1794
|
+
youtube: /http(?::\/\/(?:www\.youtube\.com\/|youtu\.be)|s:\/\/(?:www\.youtube\.com|youtu\.be))/gi,
|
|
1795
|
+
whatsapp: /(?:https?:\/\/(?:chat\.whatsapp\.com|wa\.me)|chat\.whatsapp\.com|wa\.me)\//gi,
|
|
1796
|
+
twitter: /(?:https?:\/\/)?(?:www\.)?twitter\.com\/(?:(?:\w)*#!\/)?(?:pages\/)?(?:[\w\-]*\/)*([\w\-]*)/gi,
|
|
1797
|
+
facebook: /(?:https?:\/\/)?(?:www\.)?(mbasic.facebook|m\.facebook|facebook|fb)\.(com|me)\/(?:(?:\w\.)*#!\/)?(?:pages\/)?(?:[\w\-\.]*\/)*([\w\-\.]*)/gi,
|
|
1798
|
+
instagram: /(?:https?:\/\/)?(?:www\.)?(?:instagram\.com|instagr\.am)\/(?:(?:\w\.)*#!\/)?(?:pages\/)?(?:[\w\-\.]*\/)*([\w\-\.]*)/gi,
|
|
1799
|
+
tiktok: /(?:https?:\/\/)?(?:www\.)?(?:tiktok\.com)\/(?:(?:\w\.)*#!\/)?(?:pages\/)?(?:[\w\-\.]*\/)*([\w\-\.]*)/gi,
|
|
1800
|
+
twitch: /(?:https?:\/\/)?(?:www\.)?(?:twitch\.tv)\/(?:(?:\w\.)*#!\/)?(?:pages\/)?(?:[\w\-\.]*\/)*([\w\-\.]*)/gi,
|
|
1801
|
+
discord: /(?:https?:\/\/)?(?:www\.)?(?:discord\.gg)\/(?:(?:\w\.)*#!\/)?(?:pages\/)?(?:[\w\-\.]*\/)*([\w\-\.]*)/gi,
|
|
1802
|
+
spotify: /(?:https?:\/\/)?(?:www\.)?(?:open\.spotify\.com)\/(?:(?:\w\.)*#!\/)?(?:pages\/)?(?:[\w\-\.]*\/)*([\w\-\.]*)/gi,
|
|
1803
|
+
netflix: /(?:https?:\/\/)?(?:www\.)?(?:netflix\.com)\/(?:(?:\w\.)*#!\/)?(?:pages\/)?(?:[\w\-\.]*\/)*([\w\-\.]*)/gi,
|
|
1804
|
+
};
|
|
1805
|
+
return regexMap[filter] || / /;
|
|
1806
|
+
}
|
|
1807
|
+
function getCensuredText(text = '') {
|
|
1808
|
+
const pornWordsRegex = new RegExp(exports.pornWords.join('|'), 'gi');
|
|
1809
|
+
return text.replace(pornWordsRegex, '').trim();
|
|
1810
|
+
}
|
|
1811
|
+
function isOwnerGroup(chatId) {
|
|
1812
|
+
return (chatId === process.env.GRUPO_CHAT || chatId === process.env.GRUPO_FIGURINHAS);
|
|
1813
|
+
}
|
|
1814
|
+
function extrairIdsMencionados(texto) {
|
|
1815
|
+
if (!texto)
|
|
1816
|
+
return [];
|
|
1817
|
+
const regex = /<@(\d+)>/g;
|
|
1818
|
+
const ids = [];
|
|
1819
|
+
let match;
|
|
1820
|
+
while ((match = regex.exec(texto)) !== null) {
|
|
1821
|
+
ids.push(match[1]);
|
|
1822
|
+
}
|
|
1823
|
+
return ids;
|
|
1824
|
+
}
|
|
1825
|
+
function generateCode(length = 6) {
|
|
1826
|
+
const characters = 'ABCDEFGHIJKLMNPQRSTUVWXYZ123456789';
|
|
1827
|
+
let code = '';
|
|
1828
|
+
for (let i = 0; i < length; i++) {
|
|
1829
|
+
const randomIndex = Math.floor(Math.random() * characters.length);
|
|
1830
|
+
code += characters[randomIndex];
|
|
1831
|
+
}
|
|
1832
|
+
return code;
|
|
1833
|
+
}
|
|
1834
|
+
function drawHangman(erros, hidden, dica, letrasErradas = '') {
|
|
1835
|
+
hidden = hidden.toUpperCase(); /*?.replaceAll('_', '█');*/
|
|
1836
|
+
letrasErradas = letrasErradas.toUpperCase();
|
|
1837
|
+
switch (erros) {
|
|
1838
|
+
case 0:
|
|
1839
|
+
return (`ʢ_____ ${letrasErradas}` +
|
|
1840
|
+
`\n | |` +
|
|
1841
|
+
'\n |' +
|
|
1842
|
+
'\n |' +
|
|
1843
|
+
'\n |' +
|
|
1844
|
+
'\n |' +
|
|
1845
|
+
`\n | ${hidden}` +
|
|
1846
|
+
`\n\nDica: *${dica}*`);
|
|
1847
|
+
case 1:
|
|
1848
|
+
return (`ʢ_____ ${letrasErradas}` +
|
|
1849
|
+
`\n | |` +
|
|
1850
|
+
'\n | O' +
|
|
1851
|
+
'\n |' +
|
|
1852
|
+
'\n |' +
|
|
1853
|
+
'\n |' +
|
|
1854
|
+
`\n | ${hidden}` +
|
|
1855
|
+
`\n\nDica: *${dica}*`);
|
|
1856
|
+
case 2:
|
|
1857
|
+
return (`ʢ_____ ${letrasErradas}` +
|
|
1858
|
+
`\n | |` +
|
|
1859
|
+
'\n | O' +
|
|
1860
|
+
'\n | |' +
|
|
1861
|
+
'\n |' +
|
|
1862
|
+
'\n |' +
|
|
1863
|
+
`\n | ${hidden}` +
|
|
1864
|
+
`\n\nDica: *${dica}*`);
|
|
1865
|
+
case 3:
|
|
1866
|
+
return (`ʢ_____ ${letrasErradas}` +
|
|
1867
|
+
`\n | |` +
|
|
1868
|
+
'\n | O' +
|
|
1869
|
+
'\n | /|' +
|
|
1870
|
+
'\n |' +
|
|
1871
|
+
'\n |' +
|
|
1872
|
+
`\n | ${hidden}` +
|
|
1873
|
+
`\n\nDica: *${dica}*`);
|
|
1874
|
+
case 4:
|
|
1875
|
+
return (`ʢ_____ ${letrasErradas}` +
|
|
1876
|
+
`\n | |` +
|
|
1877
|
+
'\n | O' +
|
|
1878
|
+
'\n | /|\\' +
|
|
1879
|
+
'\n |' +
|
|
1880
|
+
'\n |' +
|
|
1881
|
+
`\n | ${hidden}` +
|
|
1882
|
+
`\n\nDica: *${dica}*`);
|
|
1883
|
+
case 5:
|
|
1884
|
+
return (`ʢ_____ ${letrasErradas}` +
|
|
1885
|
+
`\n | |` +
|
|
1886
|
+
'\n | O' +
|
|
1887
|
+
'\n | /|\\' +
|
|
1888
|
+
'\n | /' +
|
|
1889
|
+
'\n |' +
|
|
1890
|
+
`\n | ${hidden}` +
|
|
1891
|
+
`\n\nDica: *${dica}*`);
|
|
1892
|
+
case 6:
|
|
1893
|
+
return (` _____ ${letrasErradas}` +
|
|
1894
|
+
`\n | |` +
|
|
1895
|
+
'\n | O' +
|
|
1896
|
+
'\n | /|\\' +
|
|
1897
|
+
'\n | / \\' +
|
|
1898
|
+
'\n |' +
|
|
1899
|
+
`\n | ${hidden}` +
|
|
1900
|
+
`\nVocê perdeu!`);
|
|
1901
|
+
default:
|
|
1902
|
+
console.log('erros', erros);
|
|
1903
|
+
return 'Erro';
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
function clearObject(item, originalItem) {
|
|
1907
|
+
if (originalItem) {
|
|
1908
|
+
item = {
|
|
1909
|
+
...originalItem,
|
|
1910
|
+
...item,
|
|
1911
|
+
};
|
|
1912
|
+
}
|
|
1913
|
+
Object.keys(item).forEach((keyT) => {
|
|
1914
|
+
const key = keyT;
|
|
1915
|
+
if (!item[key] || (item[key] instanceof Array && item[key].length === 0)) {
|
|
1916
|
+
delete item[key];
|
|
1917
|
+
}
|
|
1918
|
+
if (Array.isArray(item[key])) {
|
|
1919
|
+
item[key].forEach((element) => {
|
|
1920
|
+
if (Array.isArray(element)) {
|
|
1921
|
+
element.forEach((el) => {
|
|
1922
|
+
Object.keys(el).forEach((attr) => {
|
|
1923
|
+
if (!el[attr] || el[attr]?.length === 0) {
|
|
1924
|
+
delete el[attr];
|
|
1925
|
+
}
|
|
1926
|
+
});
|
|
1927
|
+
});
|
|
1928
|
+
}
|
|
1929
|
+
else if (typeof element === 'object') {
|
|
1930
|
+
Object.keys(element).forEach((attr) => {
|
|
1931
|
+
if (!element[attr] || element[attr]?.length === 0) {
|
|
1932
|
+
delete element[attr];
|
|
1933
|
+
}
|
|
1934
|
+
});
|
|
1935
|
+
}
|
|
1936
|
+
});
|
|
1937
|
+
}
|
|
1938
|
+
});
|
|
1939
|
+
return item;
|
|
1940
|
+
}
|
|
1941
|
+
function getMonthId(offset) {
|
|
1942
|
+
const currentDate = new Date();
|
|
1943
|
+
const year = currentDate.getFullYear();
|
|
1944
|
+
const month = currentDate.getMonth();
|
|
1945
|
+
const totalMonths = year * 12 + month + offset;
|
|
1946
|
+
const newYear = Math.floor(totalMonths / 12);
|
|
1947
|
+
const newMonth = totalMonths % 12;
|
|
1948
|
+
return newYear.toString() + (newMonth + 1).toString().padStart(2, '0');
|
|
1949
|
+
}
|
|
1950
|
+
function isShiny(id) {
|
|
1951
|
+
return !!id?.toUpperCase().endsWith('S');
|
|
1952
|
+
}
|
|
1953
|
+
function compareCardsOrder(a, b, inverse = false) {
|
|
1954
|
+
const orderLetters = [
|
|
1955
|
+
'M',
|
|
1956
|
+
'W',
|
|
1957
|
+
'P',
|
|
1958
|
+
'X',
|
|
1959
|
+
'Y',
|
|
1960
|
+
'R',
|
|
1961
|
+
'G',
|
|
1962
|
+
'V',
|
|
1963
|
+
'N',
|
|
1964
|
+
'B',
|
|
1965
|
+
'H',
|
|
1966
|
+
'K',
|
|
1967
|
+
'T',
|
|
1968
|
+
'S',
|
|
1969
|
+
'D',
|
|
1970
|
+
];
|
|
1971
|
+
let idA = (a?.id?.toUpperCase() || a?.type?.toUpperCase()) ?? 'D00';
|
|
1972
|
+
let idB = (b?.id?.toUpperCase() || b?.type?.toUpperCase()) ?? 'D00';
|
|
1973
|
+
let aOrder = orderLetters.indexOf(idA[0]);
|
|
1974
|
+
let bOrder = orderLetters.indexOf(idB[0]);
|
|
1975
|
+
if (a.isNewCard) {
|
|
1976
|
+
aOrder += 10000;
|
|
1977
|
+
}
|
|
1978
|
+
if (b.isNewCard) {
|
|
1979
|
+
bOrder += 10000;
|
|
1980
|
+
}
|
|
1981
|
+
if (aOrder !== bOrder) {
|
|
1982
|
+
if (inverse) {
|
|
1983
|
+
return bOrder - aOrder;
|
|
1984
|
+
}
|
|
1985
|
+
return aOrder - bOrder;
|
|
1986
|
+
}
|
|
1987
|
+
const aNumber = parseInt(idA.slice(1), 10);
|
|
1988
|
+
const bNumber = parseInt(idB.slice(1), 10);
|
|
1989
|
+
return aNumber - bNumber;
|
|
1990
|
+
}
|
|
1991
|
+
function privateNumber(contactId) {
|
|
1992
|
+
const number = contactId?.replace('@c.us', '') ?? '';
|
|
1993
|
+
return number.replace(/(\d{4})(\d{5,7})(\d{3})/, '$1*****$3');
|
|
1994
|
+
}
|
|
1995
|
+
function limitDescription(description, limit = 50) {
|
|
1996
|
+
if (description.length > limit) {
|
|
1997
|
+
return description.substring(0, limit) + '...';
|
|
1998
|
+
}
|
|
1999
|
+
else {
|
|
2000
|
+
return description;
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
function convertToCurrency(value) {
|
|
2004
|
+
return value?.toLocaleString('pt-BR', {
|
|
2005
|
+
style: 'currency',
|
|
2006
|
+
currency: 'BRL',
|
|
2007
|
+
});
|
|
2008
|
+
}
|
|
2009
|
+
function getDateFormat(date) {
|
|
2010
|
+
const dateObj = new Date(date);
|
|
2011
|
+
return dateObj.toLocaleDateString('pt-BR', {
|
|
2012
|
+
timeZone: 'America/Sao_Paulo',
|
|
2013
|
+
hour12: false,
|
|
2014
|
+
day: '2-digit',
|
|
2015
|
+
month: '2-digit',
|
|
2016
|
+
year: 'numeric',
|
|
2017
|
+
hour: '2-digit',
|
|
2018
|
+
minute: '2-digit',
|
|
2019
|
+
});
|
|
2020
|
+
}
|
|
2021
|
+
async function getBlobFromPath(imagePath) {
|
|
2022
|
+
let blob = null;
|
|
2023
|
+
if (imagePath.startsWith('data:image')) {
|
|
2024
|
+
const byteString = atob(imagePath.split(',')[1]);
|
|
2025
|
+
const mimeString = imagePath.split(',')[0].split(':')[1].split(';')[0];
|
|
2026
|
+
const ab = new ArrayBuffer(byteString.length);
|
|
2027
|
+
const ia = new Uint8Array(ab);
|
|
2028
|
+
for (let i = 0; i < byteString.length; i++) {
|
|
2029
|
+
ia[i] = byteString.charCodeAt(i);
|
|
2030
|
+
}
|
|
2031
|
+
blob = new Blob([ab], { type: mimeString });
|
|
2032
|
+
}
|
|
2033
|
+
else {
|
|
2034
|
+
const result = await fetch(imagePath);
|
|
2035
|
+
if (!result.ok) {
|
|
2036
|
+
console.error('Erro ao baixar a imagem.', result);
|
|
2037
|
+
throw new Error('Erro ao baixar a imagem.');
|
|
2038
|
+
}
|
|
2039
|
+
blob = await result.blob();
|
|
2040
|
+
}
|
|
2041
|
+
return blob;
|
|
2042
|
+
}
|
|
2043
|
+
function base64ToBlob(base64) {
|
|
2044
|
+
const byteString = atob(base64.split(',')[1]);
|
|
2045
|
+
const mimeString = base64.split(',')[0].split(':')[1].split(';')[0];
|
|
2046
|
+
const ab = new ArrayBuffer(byteString.length);
|
|
2047
|
+
const ia = new Uint8Array(ab);
|
|
2048
|
+
for (let i = 0; i < byteString.length; i++) {
|
|
2049
|
+
ia[i] = byteString.charCodeAt(i);
|
|
2050
|
+
}
|
|
2051
|
+
return new Blob([ab], { type: mimeString });
|
|
2052
|
+
}
|
|
2053
|
+
async function loadImage(base64Str) {
|
|
2054
|
+
const img = new Image();
|
|
2055
|
+
img.src = base64Str;
|
|
2056
|
+
await new Promise((resolve) => (img.onload = resolve));
|
|
2057
|
+
return img;
|
|
2058
|
+
}
|
|
2059
|
+
async function blobToBase64(blob) {
|
|
2060
|
+
return new Promise((resolve, reject) => {
|
|
2061
|
+
const reader = new FileReader();
|
|
2062
|
+
reader.onload = () => {
|
|
2063
|
+
resolve(reader.result);
|
|
2064
|
+
};
|
|
2065
|
+
reader.onerror = reject;
|
|
2066
|
+
reader.readAsDataURL(blob);
|
|
2067
|
+
});
|
|
2068
|
+
}
|
|
2069
|
+
function formatTime(time) {
|
|
2070
|
+
let hours = Math.floor((time % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
|
2071
|
+
const minutes = Math.floor((time % (1000 * 60 * 60)) / (1000 * 60));
|
|
2072
|
+
const seconds = Math.floor((time % (1000 * 60)) / 1000);
|
|
2073
|
+
const days = Math.floor(time / (1000 * 60 * 60 * 24));
|
|
2074
|
+
return `${days}d ${hours}h ${minutes}m ${seconds}s`;
|
|
2075
|
+
}
|
|
2076
|
+
function raidComparator(a, b) {
|
|
2077
|
+
const now = Date.now();
|
|
2078
|
+
const weight = (r) => {
|
|
2079
|
+
if (r.finishedAt)
|
|
2080
|
+
return 2;
|
|
2081
|
+
return new Date(r.startTime).getTime() > now ? 1 : 0;
|
|
2082
|
+
};
|
|
2083
|
+
const wDiff = weight(a) - weight(b);
|
|
2084
|
+
if (wDiff !== 0)
|
|
2085
|
+
return wDiff;
|
|
2086
|
+
return new Date(a.startTime).getTime() - new Date(b.startTime).getTime();
|
|
2087
|
+
}
|
|
2088
|
+
function toISOStringWithOffset(date) {
|
|
2089
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
2090
|
+
const offsetMin = date.getTimezoneOffset();
|
|
2091
|
+
const sign = offsetMin > 0 ? '-' : '+';
|
|
2092
|
+
const absMin = Math.abs(offsetMin);
|
|
2093
|
+
const hoursOffset = pad(Math.floor(absMin / 60));
|
|
2094
|
+
const minsOffset = pad(absMin % 60);
|
|
2095
|
+
return (date.getFullYear() +
|
|
2096
|
+
'-' +
|
|
2097
|
+
pad(date.getMonth() + 1) +
|
|
2098
|
+
'-' +
|
|
2099
|
+
pad(date.getDate()) +
|
|
2100
|
+
'T' +
|
|
2101
|
+
pad(date.getHours()) +
|
|
2102
|
+
':' +
|
|
2103
|
+
pad(date.getMinutes()) +
|
|
2104
|
+
':' +
|
|
2105
|
+
pad(date.getSeconds()) +
|
|
2106
|
+
sign +
|
|
2107
|
+
hoursOffset +
|
|
2108
|
+
':' +
|
|
2109
|
+
minsOffset);
|
|
2110
|
+
}
|