Merge pull request from voiser/master

Plugins reloading
This commit is contained in:
Yago 2014-12-16 19:14:13 +01:00
commit 2253dc712e
2 changed files with 29 additions and 10 deletions

@ -29,7 +29,7 @@ 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
@ -194,6 +194,8 @@ now = os.time()
plugins = {} plugins = {}
-- load all plugins in the plugins/ directory -- load all plugins in the plugins/ directory
function load_plugins()
plugins = {}
for k, v in pairs(scandir("plugins")) do for k, v in pairs(scandir("plugins")) do
if not (v:sub(0, 1) == ".") then if not (v:sub(0, 1) == ".") then
print("Loading plugin", v) print("Loading plugin", v)
@ -201,3 +203,7 @@ for k, v in pairs(scandir("plugins")) do
table.insert(plugins, t) table.insert(plugins, t)
end end
end end
end
load_plugins()

13
plugins/reload.lua Normal 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
}