Spaces:
Paused
Paused
Download src/state.js from TomatitoToho/zelin-bot: direct link, hf CLI and curl.
- Browser
- Download file 1.52 kB
-
https://huggingface.co/spaces/TomatitoToho/zelin-bot/resolve/main/src/state.js
- Command line
-
hf download hf://spaces/TomatitoToho/zelin-bot/src/state.js
-
curl -L -o state.js https://huggingface.co/spaces/TomatitoToho/zelin-bot/resolve/main/src/state.js
1.52 kB
| /** | |
| * 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]; } | |