Reload ALL the plugins!

This commit is contained in:
David Muñoz 2014-12-16 15:05:42 +01:00
parent 61c7a05551
commit 6bfc5247bf
2 changed files with 29 additions and 10 deletions

View File

@ -28,9 +28,9 @@ function rmtmp_cb(file_path, success, result)
end end
function msg_valid(msg) function msg_valid(msg)
--if msg.from.id == our_id then if msg.from.id == our_id then
-- return false return true
--end end
if msg.out then if msg.out then
return false return false
end end
@ -194,10 +194,16 @@ now = os.time()
plugins = {} plugins = {}
-- load all plugins in the plugins/ directory -- load all plugins in the plugins/ directory
for k, v in pairs(scandir("plugins")) do function load_plugins()
if not (v:sub(0, 1) == ".") then plugins = {}
print("Loading plugin", v) for k, v in pairs(scandir("plugins")) do
t = loadfile("plugins/" .. v)() if not (v:sub(0, 1) == ".") then
table.insert(plugins, t) print("Loading plugin", v)
t = loadfile("plugins/" .. v)()
table.insert(plugins, t)
end
end end
end end
load_plugins()

13
plugins/reload.lua Normal file
View File

@ -0,0 +1,13 @@
function run(msg, matches)
load_plugins()
return 'Plugins reloaded'
end
return {
description = "Reloads bot plugins",
usage = "!reload",
patterns = {"^!reload$"},
run = run
}