@kaikybrofc/omnizap-system 2.2.9 → 2.3.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/README.md +20 -18
- package/app/config/adminIdentity.js +1 -3
- package/app/connection/socketController.js +10 -20
- package/app/controllers/messageController.js +7 -28
- package/app/modules/aiModule/catCommand.js +29 -192
- package/app/modules/broadcastModule/noticeCommand.js +28 -97
- package/app/modules/gameModule/diceCommand.js +6 -32
- package/app/modules/playModule/playCommand.js +57 -258
- package/app/modules/quoteModule/quoteCommand.js +2 -4
- package/app/modules/rpgPokemonModule/rpgPokemonRepository.js +1 -13
- package/app/modules/statsModule/noMessageCommand.js +16 -84
- package/app/modules/statsModule/rankingCommand.js +5 -25
- package/app/modules/statsModule/rankingCommon.js +1 -9
- package/app/modules/stickerModule/convertToWebp.js +4 -27
- package/app/modules/stickerModule/stickerCommand.js +13 -24
- package/app/modules/stickerModule/stickerTextCommand.js +13 -25
- package/app/modules/stickerPackModule/autoPackCollectorService.js +16 -7
- package/app/modules/stickerPackModule/domainEventOutboxRepository.js +20 -36
- package/app/modules/stickerPackModule/domainEvents.js +2 -11
- package/app/modules/stickerPackModule/semanticReclassificationEngine.js +13 -50
- package/app/modules/stickerPackModule/semanticReclassificationEngine.test.js +2 -15
- package/app/modules/stickerPackModule/semanticThemeClusterService.js +14 -41
- package/app/modules/stickerPackModule/stickerAssetClassificationRepository.js +25 -95
- package/app/modules/stickerPackModule/stickerAssetRepository.js +12 -31
- package/app/modules/stickerPackModule/stickerAssetReprocessQueueRepository.js +13 -18
- package/app/modules/stickerPackModule/stickerAutoPackByTagsRuntime.js +284 -709
- package/app/modules/stickerPackModule/stickerClassificationBackgroundRuntime.js +27 -106
- package/app/modules/stickerPackModule/stickerClassificationService.js +46 -77
- package/app/modules/stickerPackModule/stickerDedicatedTaskWorkerRuntime.js +13 -53
- package/app/modules/stickerPackModule/stickerDomainEventBus.js +10 -16
- package/app/modules/stickerPackModule/stickerDomainEventConsumerRuntime.js +13 -34
- package/app/modules/stickerPackModule/stickerMarketplaceDriftService.js +1 -4
- package/app/modules/stickerPackModule/stickerObjectStorageService.js +26 -26
- package/app/modules/stickerPackModule/stickerPackCommandHandlers.js +32 -187
- package/app/modules/stickerPackModule/stickerPackInteractionEventRepository.js +6 -15
- package/app/modules/stickerPackModule/stickerPackItemRepository.js +6 -32
- package/app/modules/stickerPackModule/stickerPackMarketplaceService.js +12 -36
- package/app/modules/stickerPackModule/stickerPackMessageService.js +12 -40
- package/app/modules/stickerPackModule/stickerPackRepository.js +23 -66
- package/app/modules/stickerPackModule/stickerPackScoreSnapshotRepository.js +9 -21
- package/app/modules/stickerPackModule/stickerPackScoreSnapshotRuntime.js +10 -40
- package/app/modules/stickerPackModule/stickerPackService.js +50 -115
- package/app/modules/stickerPackModule/stickerPackServiceRuntime.js +2 -21
- package/app/modules/stickerPackModule/stickerPackUtils.js +13 -3
- package/app/modules/stickerPackModule/stickerStorageService.js +16 -65
- package/app/modules/stickerPackModule/stickerWorkerPipelineRuntime.js +4 -22
- package/app/modules/stickerPackModule/stickerWorkerTaskQueueRepository.js +14 -29
- package/app/modules/systemMetricsModule/pingCommand.js +9 -39
- package/app/modules/tiktokModule/tiktokCommand.js +17 -109
- package/app/modules/userModule/userCommand.js +2 -88
- package/app/observability/metrics.js +5 -16
- package/app/services/captchaService.js +1 -6
- package/app/services/dbWriteQueue.js +3 -18
- package/app/services/featureFlagService.js +2 -8
- package/app/services/newsBroadcastService.js +0 -1
- package/app/services/queueUtils.js +2 -4
- package/app/services/whatsappLoginLinkService.js +7 -9
- package/app/store/premiumUserStore.js +1 -2
- package/app/utils/antiLink/antiLinkModule.js +3 -233
- package/app/utils/logger/loggerModule.js +9 -34
- package/app/utils/systemMetrics/systemMetricsModule.js +1 -4
- package/database/init.js +1 -8
- package/docker-compose.yml +27 -27
- package/docs/seo/omnizap-seo-playbook-br-2026-02-28.md +220 -0
- package/docs/seo/satellite-page-template.md +91 -0
- package/docs/seo/satellite-pages-phase1.json +349 -0
- package/eslint.config.js +2 -15
- package/index.js +8 -36
- package/ml/clip_classifier/README.md +4 -6
- package/observability/alert-rules.yml +12 -12
- package/observability/grafana/provisioning/dashboards/dashboards.yml +1 -1
- package/package.json +8 -3
- package/public/api-docs/index.html +224 -141
- package/public/bot-whatsapp-para-grupo/index.html +306 -0
- package/public/bot-whatsapp-sem-programar/index.html +306 -0
- package/public/comandos/index.html +428 -0
- package/public/como-automatizar-avisos-no-whatsapp/index.html +306 -0
- package/public/como-criar-comandos-whatsapp/index.html +306 -0
- package/public/como-evitar-spam-no-whatsapp/index.html +306 -0
- package/public/como-moderar-grupo-whatsapp/index.html +306 -0
- package/public/como-organizar-comunidade-whatsapp/index.html +306 -0
- package/public/css/github-project-panel.css +20 -15
- package/public/css/stickers-admin.css +55 -39
- package/public/css/styles.css +37 -29
- package/public/index.html +1060 -1417
- package/public/js/apps/apiDocsApp.js +36 -153
- package/public/js/apps/createPackApp.js +69 -332
- package/public/js/apps/homeApp.js +201 -434
- package/public/js/apps/loginApp.js +3 -12
- package/public/js/apps/stickersAdminApp.js +190 -181
- package/public/js/apps/stickersApp.js +507 -1366
- package/public/js/catalog.js +11 -74
- package/public/js/github-panel/components/ErrorState.js +1 -8
- package/public/js/github-panel/components/GithubProjectPanel.js +2 -9
- package/public/js/github-panel/components/SkeletonPanel.js +1 -11
- package/public/js/github-panel/components/StatCard.js +1 -7
- package/public/js/github-panel/vendor/react.js +1 -9
- package/public/js/runtime/react-runtime.js +1 -9
- package/public/licenca/index.html +104 -86
- package/public/login/index.html +315 -321
- package/public/melhor-bot-whatsapp-para-grupos/index.html +306 -0
- package/public/sitemap.xml +45 -0
- package/public/stickers/admin/index.html +14 -19
- package/public/stickers/create/index.html +39 -43
- package/public/stickers/index.html +97 -41
- package/public/termos-de-uso/index.html +142 -115
- package/public/user/index.html +347 -346
- package/scripts/cache-bust.mjs +5 -24
- package/scripts/generate-seo-satellite-pages.mjs +431 -0
- package/scripts/run-prettier-all.mjs +25 -0
- package/scripts/sticker-catalog-loadtest.mjs +13 -11
- package/scripts/sticker-worker-task.mjs +1 -4
- package/scripts/sync-readme-snapshot.mjs +3 -2
- package/server/controllers/stickerCatalogController.js +407 -704
- package/server/http/httpServer.js +2 -10
- package/server/routes/stickerCatalog/catalogHandlers/catalogAdminHttp.js +1 -8
- package/server/routes/stickerCatalog/catalogHandlers/catalogAuthHttp.js +1 -9
- package/server/routes/stickerCatalog/catalogHandlers/catalogPublicHttp.js +10 -11
- package/server/routes/stickerCatalog/catalogHandlers/catalogUploadHttp.js +1 -10
- package/server/routes/stickerCatalog/catalogRouter.js +11 -13
- package/kaikybrofc-omnizap-system-2.2.9.tgz +0 -0
|
@@ -45,38 +45,21 @@ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
|
45
45
|
const jitter = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
|
|
46
46
|
|
|
47
47
|
const isRateLimitError = (error) => {
|
|
48
|
-
const status =
|
|
49
|
-
error?.status || error?.statusCode || error?.response?.status || error?.output?.statusCode;
|
|
48
|
+
const status = error?.status || error?.statusCode || error?.response?.status || error?.output?.statusCode;
|
|
50
49
|
if (status === 429) return true;
|
|
51
50
|
const message = String(error?.message || '').toLowerCase();
|
|
52
|
-
return (
|
|
53
|
-
message.includes('rate') ||
|
|
54
|
-
message.includes('flood') ||
|
|
55
|
-
message.includes('too many') ||
|
|
56
|
-
message.includes('spam') ||
|
|
57
|
-
message.includes('limit')
|
|
58
|
-
);
|
|
51
|
+
return message.includes('rate') || message.includes('flood') || message.includes('too many') || message.includes('spam') || message.includes('limit');
|
|
59
52
|
};
|
|
60
53
|
|
|
61
54
|
const isRetryableError = (error) => {
|
|
62
|
-
const status =
|
|
63
|
-
error?.status || error?.statusCode || error?.response?.status || error?.output?.statusCode;
|
|
55
|
+
const status = error?.status || error?.statusCode || error?.response?.status || error?.output?.statusCode;
|
|
64
56
|
if (status && status >= 500) return true;
|
|
65
57
|
if (isRateLimitError(error)) return true;
|
|
66
58
|
const message = String(error?.message || '').toLowerCase();
|
|
67
|
-
return (
|
|
68
|
-
message.includes('timed out') ||
|
|
69
|
-
message.includes('timeout') ||
|
|
70
|
-
message.includes('network') ||
|
|
71
|
-
message.includes('connection') ||
|
|
72
|
-
message.includes('socket')
|
|
73
|
-
);
|
|
59
|
+
return message.includes('timed out') || message.includes('timeout') || message.includes('network') || message.includes('connection') || message.includes('socket');
|
|
74
60
|
};
|
|
75
61
|
|
|
76
|
-
const withRetry = async (
|
|
77
|
-
fn,
|
|
78
|
-
{ retries = 2, baseDelayMs = 2000, jitterMin = 200, jitterMax = 800, onRateLimit } = {},
|
|
79
|
-
) => {
|
|
62
|
+
const withRetry = async (fn, { retries = 2, baseDelayMs = 2000, jitterMin = 200, jitterMax = 800, onRateLimit } = {}) => {
|
|
80
63
|
let attempt = 0;
|
|
81
64
|
while (true) {
|
|
82
65
|
try {
|
|
@@ -169,8 +152,7 @@ const normalizeWhatsAppText = (input = '') => {
|
|
|
169
152
|
if (!line) return '';
|
|
170
153
|
const spaceRuns = line.match(/ {2,}/g);
|
|
171
154
|
const hasMultipleSpaceRuns = spaceRuns && spaceRuns.length >= 2;
|
|
172
|
-
const isFormatted =
|
|
173
|
-
/^\s{2,}/.test(line) || /^\s*```/.test(line) || line.includes('|') || hasMultipleSpaceRuns;
|
|
155
|
+
const isFormatted = /^\s{2,}/.test(line) || /^\s*```/.test(line) || line.includes('|') || hasMultipleSpaceRuns;
|
|
174
156
|
if (isFormatted) {
|
|
175
157
|
return line.replace(/ {6,}/g, ' ');
|
|
176
158
|
}
|
|
@@ -207,22 +189,10 @@ const buildGroupList = (groups) =>
|
|
|
207
189
|
* @param {string} params.text
|
|
208
190
|
* @returns {Promise<void>}
|
|
209
191
|
*/
|
|
210
|
-
export async function handleNoticeCommand({
|
|
211
|
-
sock,
|
|
212
|
-
remoteJid,
|
|
213
|
-
messageInfo,
|
|
214
|
-
expirationMessage,
|
|
215
|
-
senderJid,
|
|
216
|
-
text,
|
|
217
|
-
commandPrefix = DEFAULT_COMMAND_PREFIX,
|
|
218
|
-
}) {
|
|
192
|
+
export async function handleNoticeCommand({ sock, remoteJid, messageInfo, expirationMessage, senderJid, text, commandPrefix = DEFAULT_COMMAND_PREFIX }) {
|
|
219
193
|
const ownerJid = getAdminJid();
|
|
220
194
|
if (!ownerJid) {
|
|
221
|
-
await sendAndStore(sock,
|
|
222
|
-
remoteJid,
|
|
223
|
-
{ text: '❌ USER_ADMIN não configurado no ambiente.' },
|
|
224
|
-
{ quoted: messageInfo, ephemeralExpiration: expirationMessage },
|
|
225
|
-
);
|
|
195
|
+
await sendAndStore(sock, remoteJid, { text: '❌ USER_ADMIN não configurado no ambiente.' }, { quoted: messageInfo, ephemeralExpiration: expirationMessage });
|
|
226
196
|
return;
|
|
227
197
|
}
|
|
228
198
|
|
|
@@ -233,55 +203,33 @@ export async function handleNoticeCommand({
|
|
|
233
203
|
participant: messageInfo?.key?.participant || null,
|
|
234
204
|
}))
|
|
235
205
|
) {
|
|
236
|
-
await sendAndStore(sock,
|
|
237
|
-
remoteJid,
|
|
238
|
-
{ text: '❌ Você não tem permissão para usar este comando.' },
|
|
239
|
-
{ quoted: messageInfo, ephemeralExpiration: expirationMessage },
|
|
240
|
-
);
|
|
206
|
+
await sendAndStore(sock, remoteJid, { text: '❌ Você não tem permissão para usar este comando.' }, { quoted: messageInfo, ephemeralExpiration: expirationMessage });
|
|
241
207
|
return;
|
|
242
208
|
}
|
|
243
209
|
|
|
244
210
|
const { mode, message: rawNoticeText } = parseNoticeArgs(text || '');
|
|
245
211
|
if (!rawNoticeText || !rawNoticeText.replace(/\s/g, '')) {
|
|
246
|
-
await sendAndStore(sock,
|
|
247
|
-
remoteJid,
|
|
248
|
-
{ text: `Uso: ${commandPrefix}aviso [-fast|-safe] <mensagem>` },
|
|
249
|
-
{ quoted: messageInfo, ephemeralExpiration: expirationMessage },
|
|
250
|
-
);
|
|
212
|
+
await sendAndStore(sock, remoteJid, { text: `Uso: ${commandPrefix}aviso [-fast|-safe] <mensagem>` }, { quoted: messageInfo, ephemeralExpiration: expirationMessage });
|
|
251
213
|
return;
|
|
252
214
|
}
|
|
253
215
|
|
|
254
216
|
const noticeStatsBefore = getTextStats(rawNoticeText);
|
|
255
217
|
const unicodeSpaceCount = countMatches(rawNoticeText, UNICODE_SPACES_REGEX);
|
|
256
|
-
const invisibleCount =
|
|
257
|
-
countMatches(rawNoticeText, INVISIBLE_TO_SPACE_REGEX) +
|
|
258
|
-
countMatches(rawNoticeText, INVISIBLE_REMOVE_REGEX);
|
|
218
|
+
const invisibleCount = countMatches(rawNoticeText, INVISIBLE_TO_SPACE_REGEX) + countMatches(rawNoticeText, INVISIBLE_REMOVE_REGEX);
|
|
259
219
|
const normalizedNoticeText = normalizeWhatsAppText(rawNoticeText);
|
|
260
220
|
const noticeStatsAfter = getTextStats(normalizedNoticeText);
|
|
261
221
|
|
|
262
|
-
logger.info(
|
|
263
|
-
`handleNoticeCommand Normalizacao do aviso: tamanho ${noticeStatsBefore.length}->${noticeStatsAfter.length} | linhas ${noticeStatsBefore.lines}->${noticeStatsAfter.lines} | invisiveis ${invisibleCount} | espacosUnicode ${unicodeSpaceCount}`,
|
|
264
|
-
);
|
|
222
|
+
logger.info(`handleNoticeCommand Normalizacao do aviso: tamanho ${noticeStatsBefore.length}->${noticeStatsAfter.length} | linhas ${noticeStatsBefore.lines}->${noticeStatsAfter.lines} | invisiveis ${invisibleCount} | espacosUnicode ${unicodeSpaceCount}`);
|
|
265
223
|
|
|
266
224
|
if (!normalizedNoticeText) {
|
|
267
|
-
logger.warn(
|
|
268
|
-
|
|
269
|
-
);
|
|
270
|
-
await sendAndStore(sock,
|
|
271
|
-
remoteJid,
|
|
272
|
-
{ text: '❌ A mensagem do aviso ficou vazia após a normalização.' },
|
|
273
|
-
{ quoted: messageInfo, ephemeralExpiration: expirationMessage },
|
|
274
|
-
);
|
|
225
|
+
logger.warn(`handleNoticeCommand Aviso vazio apos normalizacao: tamanho ${noticeStatsBefore.length} | linhas ${noticeStatsBefore.lines}`);
|
|
226
|
+
await sendAndStore(sock, remoteJid, { text: '❌ A mensagem do aviso ficou vazia após a normalização.' }, { quoted: messageInfo, ephemeralExpiration: expirationMessage });
|
|
275
227
|
return;
|
|
276
228
|
}
|
|
277
229
|
|
|
278
230
|
const imageUrl = process.env[MENU_IMAGE_ENV];
|
|
279
231
|
if (!imageUrl) {
|
|
280
|
-
await sendAndStore(sock,
|
|
281
|
-
remoteJid,
|
|
282
|
-
{ text: '❌ IMAGE_MENU não configurado no ambiente.' },
|
|
283
|
-
{ quoted: messageInfo, ephemeralExpiration: expirationMessage },
|
|
284
|
-
);
|
|
232
|
+
await sendAndStore(sock, remoteJid, { text: '❌ IMAGE_MENU não configurado no ambiente.' }, { quoted: messageInfo, ephemeralExpiration: expirationMessage });
|
|
285
233
|
return;
|
|
286
234
|
}
|
|
287
235
|
|
|
@@ -290,27 +238,20 @@ export async function handleNoticeCommand({
|
|
|
290
238
|
groupsMap = await getAllParticipatingGroups(sock);
|
|
291
239
|
} catch (error) {
|
|
292
240
|
logger.error(`handleNoticeCommand Erro ao obter grupos: ${error.message}`);
|
|
293
|
-
await sendAndStore(sock,
|
|
294
|
-
remoteJid,
|
|
295
|
-
{ text: '❌ Não foi possível obter a lista de grupos.' },
|
|
296
|
-
{ quoted: messageInfo, ephemeralExpiration: expirationMessage },
|
|
297
|
-
);
|
|
241
|
+
await sendAndStore(sock, remoteJid, { text: '❌ Não foi possível obter a lista de grupos.' }, { quoted: messageInfo, ephemeralExpiration: expirationMessage });
|
|
298
242
|
return;
|
|
299
243
|
}
|
|
300
244
|
|
|
301
245
|
const groups = Object.values(groupsMap || {});
|
|
302
246
|
if (groups.length === 0) {
|
|
303
|
-
await sendAndStore(sock,
|
|
304
|
-
remoteJid,
|
|
305
|
-
{ text: '⚠️ O bot não está em nenhum grupo.' },
|
|
306
|
-
{ quoted: messageInfo, ephemeralExpiration: expirationMessage },
|
|
307
|
-
);
|
|
247
|
+
await sendAndStore(sock, remoteJid, { text: '⚠️ O bot não está em nenhum grupo.' }, { quoted: messageInfo, ephemeralExpiration: expirationMessage });
|
|
308
248
|
return;
|
|
309
249
|
}
|
|
310
250
|
|
|
311
251
|
const groupListText = buildGroupList(groups);
|
|
312
252
|
const config = MODE_CONFIG[mode] || MODE_CONFIG.default;
|
|
313
|
-
await sendAndStore(
|
|
253
|
+
await sendAndStore(
|
|
254
|
+
sock,
|
|
314
255
|
remoteJid,
|
|
315
256
|
{
|
|
316
257
|
text: `📋 Grupos (${groups.length}):\n${groupListText}\n\n📣 Aviso:\n${normalizedNoticeText}\n\n🚀 Iniciando envio (modo ${mode}).\nConcorrência: ${config.concurrency} | Jitter: ${config.jitterMin}-${config.jitterMax}ms | Retries: ${config.retries}`,
|
|
@@ -323,11 +264,7 @@ export async function handleNoticeCommand({
|
|
|
323
264
|
imageBuffer = await getImageBuffer(imageUrl);
|
|
324
265
|
} catch (error) {
|
|
325
266
|
logger.error(`handleNoticeCommand Erro ao baixar imagem do menu: ${error.message}`);
|
|
326
|
-
await sendAndStore(sock,
|
|
327
|
-
remoteJid,
|
|
328
|
-
{ text: '❌ Não foi possível baixar a imagem do menu.' },
|
|
329
|
-
{ quoted: messageInfo, ephemeralExpiration: expirationMessage },
|
|
330
|
-
);
|
|
267
|
+
await sendAndStore(sock, remoteJid, { text: '❌ Não foi possível baixar a imagem do menu.' }, { quoted: messageInfo, ephemeralExpiration: expirationMessage });
|
|
331
268
|
return;
|
|
332
269
|
}
|
|
333
270
|
|
|
@@ -373,18 +310,14 @@ export async function handleNoticeCommand({
|
|
|
373
310
|
if (failureIds.length < MAX_FAILURE_SAMPLE && result.id) {
|
|
374
311
|
failureIds.push(result.id);
|
|
375
312
|
}
|
|
376
|
-
logger.error(
|
|
377
|
-
`handleNoticeCommand Falha ao enviar aviso para ${result.id}: ${result.error?.message || result.error}`,
|
|
378
|
-
);
|
|
313
|
+
logger.error(`handleNoticeCommand Falha ao enviar aviso para ${result.id}: ${result.error?.message || result.error}`);
|
|
379
314
|
}
|
|
380
315
|
|
|
381
316
|
const now = Date.now();
|
|
382
|
-
if (
|
|
383
|
-
processed % PROGRESS_EVERY === 0 ||
|
|
384
|
-
(now - lastProgressAt >= PROGRESS_INTERVAL_MS && processed < groups.length)
|
|
385
|
-
) {
|
|
317
|
+
if (processed % PROGRESS_EVERY === 0 || (now - lastProgressAt >= PROGRESS_INTERVAL_MS && processed < groups.length)) {
|
|
386
318
|
lastProgressAt = now;
|
|
387
|
-
await sendAndStore(
|
|
319
|
+
await sendAndStore(
|
|
320
|
+
sock,
|
|
388
321
|
remoteJid,
|
|
389
322
|
{
|
|
390
323
|
text: `📣 Progresso: ${processed}/${groups.length}\n✅ Sucesso: ${successCount}\n❌ Falhas: ${failureCount}`,
|
|
@@ -396,14 +329,12 @@ export async function handleNoticeCommand({
|
|
|
396
329
|
|
|
397
330
|
await runWithConcurrency(groups, config.concurrency, worker, onProgress);
|
|
398
331
|
|
|
399
|
-
const extraFailures =
|
|
400
|
-
failureCount > failureIds.length ? ` … +${failureCount - failureIds.length}` : '';
|
|
332
|
+
const extraFailures = failureCount > failureIds.length ? ` … +${failureCount - failureIds.length}` : '';
|
|
401
333
|
const failureList = failureIds.length ? `\nFalhas: ${failureIds.join(', ')}${extraFailures}` : '';
|
|
402
|
-
const rateLimitText = rateLimitHits
|
|
403
|
-
? `\n⚠️ Rate limit detectado: ${rateLimitHits}x (backoff aplicado)`
|
|
404
|
-
: '';
|
|
334
|
+
const rateLimitText = rateLimitHits ? `\n⚠️ Rate limit detectado: ${rateLimitHits}x (backoff aplicado)` : '';
|
|
405
335
|
|
|
406
|
-
await sendAndStore(
|
|
336
|
+
await sendAndStore(
|
|
337
|
+
sock,
|
|
407
338
|
remoteJid,
|
|
408
339
|
{
|
|
409
340
|
text: `✅ Aviso finalizado.\nTotal: ${groups.length}\n✅ Sucesso: ${successCount}\n❌ Falhas: ${failureCount}${failureList}${rateLimitText}`,
|
|
@@ -14,42 +14,21 @@ const parseSidesArgument = (rawArg) => {
|
|
|
14
14
|
|
|
15
15
|
const rollDice = (sides) => Math.floor(Math.random() * sides) + 1;
|
|
16
16
|
|
|
17
|
-
const buildUsageText = (commandPrefix) =>
|
|
18
|
-
[`Formato de uso:`, `${commandPrefix}dado`, `${commandPrefix}dado <lados (2-${MAX_SIDES})>`, `${commandPrefix}dice <lados (2-${MAX_SIDES})>`].join('\n');
|
|
17
|
+
const buildUsageText = (commandPrefix) => [`Formato de uso:`, `${commandPrefix}dado`, `${commandPrefix}dado <lados (2-${MAX_SIDES})>`, `${commandPrefix}dice <lados (2-${MAX_SIDES})>`].join('\n');
|
|
19
18
|
|
|
20
|
-
export async function handleDiceCommand({
|
|
21
|
-
sock,
|
|
22
|
-
remoteJid,
|
|
23
|
-
messageInfo,
|
|
24
|
-
expirationMessage,
|
|
25
|
-
args = [],
|
|
26
|
-
commandPrefix = '/',
|
|
27
|
-
}) {
|
|
19
|
+
export async function handleDiceCommand({ sock, remoteJid, messageInfo, expirationMessage, args = [], commandPrefix = '/' }) {
|
|
28
20
|
const sides = parseSidesArgument(args[0]);
|
|
29
21
|
if (sides === null) {
|
|
30
|
-
await sendAndStore(
|
|
31
|
-
sock,
|
|
32
|
-
remoteJid,
|
|
33
|
-
{ text: `❌ Número de lados inválido.\n\n${buildUsageText(commandPrefix)}` },
|
|
34
|
-
{ quoted: messageInfo, ephemeralExpiration: expirationMessage },
|
|
35
|
-
);
|
|
22
|
+
await sendAndStore(sock, remoteJid, { text: `❌ Número de lados inválido.\n\n${buildUsageText(commandPrefix)}` }, { quoted: messageInfo, ephemeralExpiration: expirationMessage });
|
|
36
23
|
return;
|
|
37
24
|
}
|
|
38
25
|
|
|
39
26
|
const result = rollDice(sides);
|
|
40
27
|
const face = sides === 6 ? DICE_FACES[result - 1] : '🎲';
|
|
41
|
-
const messageText =
|
|
42
|
-
sides === 6
|
|
43
|
-
? `🎲 Você rolou o dado e caiu em *${result}* ${face}`
|
|
44
|
-
: `🎲 Você rolou um dado de *${sides}* lados e caiu em *${result}*`;
|
|
28
|
+
const messageText = sides === 6 ? `🎲 Você rolou o dado e caiu em *${result}* ${face}` : `🎲 Você rolou um dado de *${sides}* lados e caiu em *${result}*`;
|
|
45
29
|
|
|
46
30
|
try {
|
|
47
|
-
await sendAndStore(
|
|
48
|
-
sock,
|
|
49
|
-
remoteJid,
|
|
50
|
-
{ text: messageText },
|
|
51
|
-
{ quoted: messageInfo, ephemeralExpiration: expirationMessage },
|
|
52
|
-
);
|
|
31
|
+
await sendAndStore(sock, remoteJid, { text: messageText }, { quoted: messageInfo, ephemeralExpiration: expirationMessage });
|
|
53
32
|
} catch (error) {
|
|
54
33
|
logger.error('handleDiceCommand: erro ao enviar resultado do dado.', {
|
|
55
34
|
error: error.message,
|
|
@@ -57,11 +36,6 @@ export async function handleDiceCommand({
|
|
|
57
36
|
sides,
|
|
58
37
|
result,
|
|
59
38
|
});
|
|
60
|
-
await sendAndStore(
|
|
61
|
-
sock,
|
|
62
|
-
remoteJid,
|
|
63
|
-
{ text: '❌ Não foi possível rolar o dado agora. Tente novamente.' },
|
|
64
|
-
{ quoted: messageInfo, ephemeralExpiration: expirationMessage },
|
|
65
|
-
);
|
|
39
|
+
await sendAndStore(sock, remoteJid, { text: '❌ Não foi possível rolar o dado agora. Tente novamente.' }, { quoted: messageInfo, ephemeralExpiration: expirationMessage });
|
|
66
40
|
}
|
|
67
41
|
}
|