Software /
code /
prosody
Comparison
plugins/mod_motd.lua @ 4649:e07ce18c503e
mod_motd: Send only to resource coming online, not the user's bare JID (fixes #282)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 21 Apr 2012 21:16:53 +0100 |
parent | 4390:5e84fb3c4ba0 |
child | 4654:0975505f5a54 |
comparison
equal
deleted
inserted
replaced
4648:561ca78e0dec | 4649:e07ce18c503e |
---|---|
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("resource-bind", function (event) |
21 function (event) | |
22 local session = event.session; | 22 local session = event.session; |
23 local motd_stanza = | 23 local motd_stanza = |
24 st.message({ to = session.username..'@'..session.host, from = motd_jid }) | 24 st.message({ to = jid_join(session.username, session.host, session.resource), from = motd_jid }) |
25 :tag("body"):text(motd_text); | 25 :tag("body"):text(motd_text); |
26 core_route_stanza(hosts[host], motd_stanza); | 26 core_route_stanza(hosts[host], motd_stanza); |
27 module:log("debug", "MOTD send to user %s@%s", session.username, session.host); | 27 module:log("debug", "MOTD send to user %s@%s", session.username, session.host); |
28 | 28 |
29 end); | 29 end); |