mod_bosh: Store time to destroy session in inactive_sessions, removing dependency...
[prosody.git] / plugins / mod_motd.lua
index 500b4a4612f6847b059e38623e4f6bf255ce19d8..d567288b8b985ed0fbb371294f5b591892c08329 100644 (file)
@@ -8,15 +8,20 @@
 --
 
 local host = module:get_host();
-local motd_text = module:get_option("motd_text") or "MOTD: (blank)";
+local motd_text = module:get_option_string("motd_text");
+local motd_jid = module:get_option_string("motd_jid", host);
+
+if not motd_text then return; end
 
 local st = require "util.stanza";
 
+motd_text = motd_text:gsub("^%s*(.-)%s*$", "%1"):gsub("\n%s+", "\n"); -- Strip indentation from the config
+
 module:hook("resource-bind",
        function (event)
                local session = event.session;
                local motd_stanza =
-                       st.message({ to = session.username..'@'..session.host, from = host })
+                       st.message({ to = session.username..'@'..session.host, from = motd_jid })
                                :tag("body"):text(motd_text);
                core_route_stanza(hosts[host], motd_stanza);
                module:log("debug", "MOTD send to user %s@%s", session.username, session.host);