File size: 1,516 Bytes
ee826ee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
 * state.js β€” Estado global compartido de Zelin
 * ===============================================
 * FIX: evita imports circulares entre index.js y admin_tools.js.
 * Ambos importan desde aquΓ­ en vez de importarse mutuamente.
 */

import * as db from './db.js';

// ── Silencio global ───────────────────────────────────────────────────────────
let _globalSilence = false;
export function isGlobalSilence()    { return _globalSilence; }
export function setGlobalSilence(v)  { _globalSilence = v; }

// ── Usuarios ignorados ────────────────────────────────────────────────────────
const _ignoredUsers = new Set();

export async function loadIgnoredUsers() {
  try {
    const v = await db.memGet('zelin.ignored_users');
    if (v && Array.isArray(v)) v.forEach(id => _ignoredUsers.add(id));
  } catch {}
}

async function _saveIgnoredUsers() {
  await db.memSet('zelin.ignored_users', [..._ignoredUsers], 'config');
}

export function isIgnored(userId) { return _ignoredUsers.has(userId); }

export async function ignoreUser(userId) {
  _ignoredUsers.add(userId);
  await _saveIgnoredUsers();
}

export async function unignoreUser(userId) {
  _ignoredUsers.delete(userId);
  await _saveIgnoredUsers();
}

export function getIgnoredUsers() { return [..._ignoredUsers]; }