Merge 0.7->trunk
[prosody.git] / plugins / mod_motd.lua
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 --
9
10 local host = module:get_host();
11 local motd_text = module:get_option("motd_text") or "MOTD: (blank)";
12 local motd_jid = module:get_option("motd_jid") or host;
13
14 local st = require "util.stanza";
15
16 module:hook("resource-bind",
17         function (event)
18                 local session = event.session;
19                 local motd_stanza =
20                         st.message({ to = session.username..'@'..session.host, from = motd_jid })
21                                 :tag("body"):text(motd_text);
22                 core_route_stanza(hosts[host], motd_stanza);
23                 module:log("debug", "MOTD send to user %s@%s", session.username, session.host);
24
25 end);