Loading plugins after configuration

This commit is contained in:
David Muñoz 2014-11-05 13:21:56 +01:00
parent 88e0336227
commit c6b99bec64

View File

@ -4,8 +4,6 @@
-- lrexlib = require("rex_pcre")
VERSION = 'v0.6'
plugins = {}
-- taken from http://stackoverflow.com/a/11130774/3163199
function scandir(directory)
@ -16,16 +14,7 @@
end
return t
end
-- load all plugins in the plugins/ directory
for k, v in pairs(scandir("plugins")) do
if not (v:sub(0, 1) == ".") then
print("Loading plugin", v)
t = loadfile("plugins/" .. v)()
table.insert(plugins, t)
end
end
function on_msg_receive (msg)
if msg_valid(msg) == false then
return
@ -336,11 +325,6 @@
end
end
-- Start and load values
config = load_config()
our_id = 0
now = os.time()
function get_receiver(msg)
if msg.to.type == 'user' then
return 'user#id'..msg.from.id
@ -350,7 +334,6 @@
end
end
function on_our_id (id)
our_id = id
end
@ -373,3 +356,23 @@
function on_binlog_replay_end ()
started = 1
end
-- Start and load values
config = load_config()
our_id = 0
now = os.time()
-- load plugins
plugins = {}
-- load all plugins in the plugins/ directory
for k, v in pairs(scandir("plugins")) do
if not (v:sub(0, 1) == ".") then
print("Loading plugin", v)
t = loadfile("plugins/" .. v)()
table.insert(plugins, t)
end
end