2 -- Copyright (C) 2008-2010 Matthew Wild
3 -- Copyright (C) 2008-2010 Waqas Hussain
4 -- Copyright (C) 2010 Jeff Mitchell
6 -- This project is MIT/X11 licensed. Please see the
7 -- COPYING file in the source package for more information.
10 local host = module:get_host();
11 local motd_text = module:get_option("motd_text");
12 local motd_jid = module:get_option("motd_jid") or host;
14 if not motd_text then return; end
16 local st = require "util.stanza";
18 motd_text = motd_text:gsub("^%s*(.-)%s*$", "%1"):gsub("\n%s+", "\n"); -- Strip indentation from the config
20 module:hook("resource-bind",
22 local session = event.session;
24 st.message({ to = session.username..'@'..session.host, from = motd_jid })
25 :tag("body"):text(motd_text);
26 core_route_stanza(hosts[host], motd_stanza);
27 module:log("debug", "MOTD send to user %s@%s", session.username, session.host);