-- Required to be able to find packages installed with luarocks
pcall(require, "luarocks.require")
-
config = require "core.configmanager"
do
["no-password"] = "No password was supplied";
["no-such-user"] = "The given user does not exist on the server";
["unable-to-save-data"] = "Unable to store, perhaps you don't have permission?";
- ["no-pidfile"] = "There is no pidfile option in the configuration file, see http://prosody.im/doc/prosodyctl#pidfile for help";
+ ["no-pidfile"] = "There is no 'pidfile' option in the configuration file, see http://prosody.im/doc/prosodyctl#pidfile for help";
["no-such-method"] = "This module has no commands";
["not-running"] = "Prosody is not running";
}, { __index = function (t,k) return "Error: "..(tostring(k):gsub("%-", " "):gsub("^.", string.upper)); end });
+local events = require "util.events".new();
+
hosts = {};
+prosody = { hosts = hosts, events = events };
-require "core.hostmanager"
-require "core.eventmanager".fire_event("server-starting");
+for hostname, config in pairs(config.getconfig()) do
+ hosts[hostname] = { events = events };
+end
+
require "core.modulemanager"
require "util.prosodyctl"
return 1;
end
+function commands.addplugin(arg)
+ local url = arg[1];
+ if url:match("^http://") then
+ local http = require "socket.http";
+ show_message("Fetching...");
+ local code, err = http.request(url);
+ if not code then
+ show_message("Failed: "..err);
+ return 1;
+ end
+ if url:match("%.lua$") then
+ local ok, err = datamanager.store(url:match("/mod_([^/]+)$"), "*", "plugins", {code});
+ if not ok then
+ show_message("Failed to save to data store: "..err);
+ return 1;
+ end
+ end
+ show_message("Saved. Don't forget to load the module using the config file or admin console!");
+ else
+ show_message("Sorry, I don't understand how to fetch plugins from there.");
+ end
+end
---------------------