Spaces:
Paused
Paused
| /** | |
| * 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]; } | |