now must reload

This commit is contained in:
Er2 2022-01-18 19:48:06 +00:00
parent 8421b61a82
commit 1b498be1d6
2 changed files with 16 additions and 4 deletions

View File

@ -17,6 +17,14 @@ end
function events:on(n,f) self:_add('on', n,f) end
function events:once(n,f) self:_add('once', n,f) end
function events:off(f)
for k, v in pairs(self._ev_) do
if v.fn == f then
table.remove(self._ev_, k)
end
end
end
function events:_ev(t, i, name, ...)
local v = t[i]
if v.name == name then

View File

@ -9,9 +9,13 @@ return {
local path = 'src.'..cat..'.'..sub
package.loaded[path] = nil
local err, m = pcall(require, path)
C.api:reply(msg, ('Reloaded. %s (%s)'):format(
not err and 'Error:' or 'Result:',
m
))
if not err then return C.api:reply(msg, 'Reload failed. ' .. m)
elseif cat == 'events' then C.api:off(m); C.api:on(sub, m)
elseif cat == 'cmds' then C.cmds[sub] = m
elseif cat == 'parts' then m(C)
end
C.api:reply(msg, 'Reloaded. ' .. tostring(m))
end
}