Mercurial > prosody-hg
comparison plugins/mod_motd.lua @ 9789:abd32bc33a9c 0.11
mod_motd: Remove redundant conditions
The stanza should always be like this in the presence/initial event
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 17 Jan 2019 01:05:47 +0100 |
| parents | e20c27e04ecc |
| children | ca0473cadd1c |
comparison
equal
deleted
inserted
replaced
| 9788:f47b2ab877d0 | 9789:abd32bc33a9c |
|---|---|
| 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/initial", 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 not stanza.attr.type and not stanza.attr.to then | 22 local motd_stanza = |
| 23 local motd_stanza = | 23 st.message({ to = session.full_jid, from = motd_jid }) |
| 24 st.message({ to = session.full_jid, from = motd_jid }) | 24 :tag("body"):text(motd_text); |
| 25 :tag("body"):text(motd_text); | 25 module:send(motd_stanza); |
| 26 module:send(motd_stanza); | 26 module:log("debug", "MOTD send to user %s", session.full_jid); |
| 27 module:log("debug", "MOTD send to user %s", session.full_jid); | |
| 28 end | |
| 29 end, 1); | 27 end, 1); |
