mod_s2s: Handle authentication of s2sin and s2sout the same way
[prosody.git] / plugins / mod_motd.lua
blob47e64be34e670d7060168ff9f6b0d662c4b1797d
1 -- Prosody IM
2 -- Copyright (C) 2008-2010 Matthew Wild
3 -- Copyright (C) 2008-2010 Waqas Hussain
4 -- Copyright (C) 2010 Jeff Mitchell
5 --
6 -- This project is MIT/X11 licensed. Please see the
7 -- COPYING file in the source package for more information.
8 --
10 local host = module:get_host();
11 local motd_text = module:get_option_string("motd_text");
12 local motd_jid = module:get_option_string("motd_jid", 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[ \t]+", "\n"); -- Strip indentation from the config
20 module:hook("presence/initial", function (event)
21 local session = event.origin;
22 local motd_stanza =
23 st.message({ to = session.full_jid, from = motd_jid })
24 :tag("body"):text(motd_text);
25 module:send(motd_stanza);
26 module:log("debug", "MOTD send to user %s", session.full_jid);
27 end, 1);