-- Copyright (c) 2023-2026 Egor
-- SPDX-License-Identifier: GPL-2.0-or-later
-if not commands then
- commands = {}
-end
+function global_once(name, init) if not _G[name] then _G[name] = init or {} end end
+global_once "commands"
+global_once "authcommands"
function dispatch_command(client, source, command, ...)
- if client.regstate ~= 2 then -- REG_REGISTERED
- err_notregistered(client)
- return
- end
- if client.umode & 2 == 0 then -- UMODE_OPER
- err_noprivileges(client)
- return
+ if not authcommands[command] then
+ if client.regstate ~= 2 then -- REG_REGISTERED
+ err_notregistered(client)
+ return
+ end
+ if client.umode & 2 == 0 then -- UMODE_OPER
+ err_noprivileges(client)
+ return
+ end
end
commands[command](client, source, command, table.pack(...))
end
client_notice(client, "done")
end
setmetatable(_G, getmetatable(ircd))
-if not hooks then
- hooks = {}
-end
+global_once "hooks"
function dispatch_hook(hook, cl1, cl2, chan, txt)
return hooks[hook](hook, cl1, cl2, chan, txt)
end
-if not managed_hooks then
- managed_hooks = {}
-end
+global_once "managed_hooks"
function hook_setfold(name, fn)
if not managed_hooks[name] then
managed_hooks[name] = {n=0,fns={}}
hook_setfold("privmsgtoservice", fold_sendtox)
hook_setfold("noticetoservice", fold_sendtox)
hook_setfold("whois", fold_sendtox)
-if not client_data then
- client_data = {}
-end
+global_once "client_data"
hook_add("nickadd", "clientdata_add", function(hook, cl1, cl2, chan, txt)
client_data[txt] = {}
end)