Mercurial > prosody-hg
comparison plugins/mod_motd.lua @ 8146:5c91fb62338e
Merge 0.10->trunk
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 17 May 2017 01:06:20 +0200 |
| parents | e20c27e04ecc |
| children | abd32bc33a9c |
comparison
equal
deleted
inserted
replaced
| 8133:102e1ec8bee1 | 8146:5c91fb62338e |
|---|---|
| 15 | 15 |
| 16 local st = require "util.stanza"; | 16 local st = require "util.stanza"; |
| 17 | 17 |
| 18 motd_text = motd_text:gsub("^%s*(.-)%s*$", "%1"):gsub("\n[ \t]+", "\n"); -- Strip indentation from the config | 18 motd_text = motd_text:gsub("^%s*(.-)%s*$", "%1"):gsub("\n[ \t]+", "\n"); -- Strip indentation from the config |
| 19 | 19 |
| 20 module:hook("presence/bare", function (event) | 20 module:hook("presence/initial", function (event) |
| 21 local session, stanza = event.origin, event.stanza; | 21 local session, stanza = event.origin, event.stanza; |
| 22 if session.username and not session.presence | 22 if not stanza.attr.type and not stanza.attr.to then |
| 23 and not stanza.attr.type and not stanza.attr.to then | |
| 24 local motd_stanza = | 23 local motd_stanza = |
| 25 st.message({ to = session.full_jid, from = motd_jid }) | 24 st.message({ to = session.full_jid, from = motd_jid }) |
| 26 :tag("body"):text(motd_text); | 25 :tag("body"):text(motd_text); |
| 27 module:send(motd_stanza); | 26 module:send(motd_stanza); |
| 28 module:log("debug", "MOTD send to user %s", session.full_jid); | 27 module:log("debug", "MOTD send to user %s", session.full_jid); |
