# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1493281074 -7200
# Node ID e20c27e04eccfdcf9c4bd4bc85f5085d0748ee25
# Parent  b87e281a7d59ec64e3631fb11aba0c6f2f32a390
mod_motd: Use initial presence event (saves some checking)

diff -r b87e281a7d59 -r e20c27e04ecc plugins/mod_motd.lua
--- 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);