Spaces:
Paused
Paused
File size: 1,302 Bytes
b41d964 | 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 | /**
* adminAuth.js β ΩΨΈΨ§Ω
Ψ§ΩΨͺΨΩΩ Ω
Ω Ψ§ΩΨ£Ψ―Ω
Ω
* βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
* Ψ§ΩΨ£Ω
Ψ±: /admin 44 β ΩΩ
ΩΨ Ψ΅ΩΨ§ΨΩΨ§Ψͺ Ψ£Ψ―Ω
Ω ΩΨ§Ω
ΩΨ©
* Ψ§ΩΨ£Ω
Ψ±: /logout β ΩΩΨΊΩ Ψ΅ΩΨ§ΨΩΨ§Ψͺ Ψ§ΩΨ£Ψ―Ω
Ω
* βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
*/
const settings = require('../settings');
// Ψ§ΩΨ£Ψ―Ω
ΩΨ² Ψ§ΩΩ
ΨͺΨΩΩ Ω
ΩΩΩ
: senderId β true
const verifiedAdmins = new Set();
function isAdmin(senderId) {
return verifiedAdmins.has(senderId);
}
function grantAdmin(senderId) {
verifiedAdmins.add(senderId);
}
function revokeAdmin(senderId) {
verifiedAdmins.delete(senderId);
}
/**
* Ψ§ΩΨͺΨΩΩ Ω
Ω Ψ£Ω
Ψ± /admin <secret>
* ΩΩΨ¨Ω: /admin 44
*/
function isValidAdminCommand(text) {
const secret = settings.adminSecret || '';
const match = text.trim().match(/^\/admin\s+(.+)$/i);
if (!match) return false;
return match[1].trim() === secret;
}
module.exports = { isAdmin, grantAdmin, revokeAdmin, isValidAdminCommand };
|