diff --git a/src/services/admin.ts b/src/services/admin.ts index 815354c..e8ce6aa 100644 --- a/src/services/admin.ts +++ b/src/services/admin.ts @@ -44,6 +44,7 @@ export class AdminService { '- /admin pendientes (alias: pending, pend)', '- /admin habilitar-aquí (alias: enable)', '- /admin deshabilitar-aquí (alias: disable)', + '- /admin allow all (alias: habilitar-todos, enable all)', '- /admin allow-group (alias: allow)', '- /admin block-group (alias: block)', '- /admin sync-grupos (alias: group-sync, syncgroups)', @@ -103,8 +104,29 @@ export class AdminService { return [{ recipient: sender, message: `✅ Grupo deshabilitado: ${ctx.groupId}` }]; } + // /admin allow all + if ( + rest === 'allow all' || + rest === 'allow-all' || + rest === 'habilitar-todos' || + rest === 'permitir todos' || + rest === 'enable all' + ) { + const pendings = AllowedGroups.listByStatus('pending'); + if (!pendings || pendings.length === 0) { + return [{ recipient: sender, message: '✅ No hay grupos pendientes.' }]; + } + let changed = 0; + for (const r of pendings) { + const didChange = AllowedGroups.setStatus(r.group_id, 'allowed', r.label ?? null); + if (didChange) changed++; + try { Metrics.inc('admin_actions_total_allow'); } catch {} + } + return [{ recipient: sender, message: `✅ Grupos habilitados: ${changed}` }]; + } + // /admin allow-group - if (rest.startsWith('allow-group ') || rest.startsWith('allow ')) { + if (rest.startsWith('allow-group ') || (rest.startsWith('allow ') && rest !== 'allow all' && rest !== 'allow-all')) { const arg = (rest.startsWith('allow-group ') ? rest.slice('allow-group '.length) : rest.slice('allow '.length)).trim(); if (!isGroupId(arg)) { return [{ recipient: sender, message: '⚠️ Debes indicar un group_id válido terminado en @g.us' }];