comparison plugins/mod_motd.lua @ 4797:e239668aa6d2

Merge 0.9->trunk
author Matthew Wild <mwild1@gmail.com>
date Sun, 29 Apr 2012 02:10:55 +0100
parents 0975505f5a54
children b2006c1cfa85
comparison
equal deleted inserted replaced
4796:04a34287dc12 4797:e239668aa6d2
11 local motd_text = module:get_option_string("motd_text"); 11 local motd_text = module:get_option_string("motd_text");
12 local motd_jid = module:get_option_string("motd_jid", host); 12 local motd_jid = module:get_option_string("motd_jid", host);
13 13
14 if not motd_text then return; end 14 if not motd_text then return; end
15 15
16 local jid_join = require "util.jid".join;
16 local st = require "util.stanza"; 17 local st = require "util.stanza";
17 18
18 motd_text = motd_text:gsub("^%s*(.-)%s*$", "%1"):gsub("\n%s+", "\n"); -- Strip indentation from the config 19 motd_text = motd_text:gsub("^%s*(.-)%s*$", "%1"):gsub("\n%s+", "\n"); -- Strip indentation from the config
19 20
20 module:hook("resource-bind", 21 module:hook("presence/bare", function (event)
21 function (event) 22 local session, stanza = event.origin, event.stanza;
22 local session = event.session; 23 if not session.presence and not stanza.attr.type then
23 local motd_stanza = 24 local motd_stanza =
24 st.message({ to = session.username..'@'..session.host, from = motd_jid }) 25 st.message({ to = session.full_jid, from = motd_jid })
25 :tag("body"):text(motd_text); 26 :tag("body"):text(motd_text);
26 core_route_stanza(hosts[host], motd_stanza); 27 core_route_stanza(hosts[host], motd_stanza);
27 module:log("debug", "MOTD send to user %s@%s", session.username, session.host); 28 module:log("debug", "MOTD send to user %s", session.full_jid);
28 29 end
29 end); 30 end, 1);