|
|
|
|
@ -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 <group_id@g.us> (alias: allow)',
|
|
|
|
|
'- /admin block-group <group_id@g.us> (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 <jid>
|
|
|
|
|
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' }];
|
|
|
|
|
|