66 |
66 |
67 function load(name) |
67 function load(name) |
68 local mod, err = loadfile("plugins/mod_"..name..".lua"); |
68 local mod, err = loadfile("plugins/mod_"..name..".lua"); |
69 if not mod then |
69 if not mod then |
70 log("error", "Unable to load module '%s': %s", name or "nil", err or "nil"); |
70 log("error", "Unable to load module '%s': %s", name or "nil", err or "nil"); |
71 return; |
71 return nil, err; |
72 end |
72 end |
73 |
73 |
74 local pluginenv = setmetatable({ module = { name = name } }, { __index = modulehelpers }); |
74 local pluginenv = setmetatable({ module = { name = name } }, { __index = modulehelpers }); |
75 |
75 |
76 setfenv(mod, pluginenv); |
76 setfenv(mod, pluginenv); |
77 local success, ret = pcall(mod); |
77 local success, ret = pcall(mod); |
78 if not success then |
78 if not success then |
79 log("error", "Error initialising module '%s': %s", name or "nil", ret or "nil"); |
79 log("error", "Error initialising module '%s': %s", name or "nil", ret or "nil"); |
80 return; |
80 return nil, err; |
81 end |
81 end |
|
82 return true; |
82 end |
83 end |
83 |
84 |
84 function handle_stanza(origin, stanza) |
85 function handle_stanza(origin, stanza) |
85 local name, xmlns, origin_type = stanza.name, stanza.attr.xmlns, origin.type; |
86 local name, xmlns, origin_type = stanza.name, stanza.attr.xmlns, origin.type; |
86 |
87 |