Software /
code /
prosody
Diff
plugins/mod_motd.lua @ 8135:e20c27e04ecc
mod_motd: Use initial presence event (saves some checking)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 27 Apr 2017 10:17:54 +0200 |
parent | 6010:fad7084a0b35 |
child | 9789:abd32bc33a9c |
line wrap: on
line diff
--- a/plugins/mod_motd.lua Wed Apr 26 16:54:58 2017 +0200 +++ b/plugins/mod_motd.lua Thu Apr 27 10:17:54 2017 +0200 @@ -17,10 +17,9 @@ motd_text = motd_text:gsub("^%s*(.-)%s*$", "%1"):gsub("\n[ \t]+", "\n"); -- Strip indentation from the config -module:hook("presence/bare", function (event) +module:hook("presence/initial", function (event) local session, stanza = event.origin, event.stanza; - if session.username and not session.presence - and not stanza.attr.type and not stanza.attr.to then + if not stanza.attr.type and not stanza.attr.to then local motd_stanza = st.message({ to = session.full_jid, from = motd_jid }) :tag("body"):text(motd_text);