Software /
code /
prosody
Comparison
plugins/mod_motd.lua @ 4654:0975505f5a54
mod_motd: Use presence/bare to catch a client's initial presence and send the MOTD then (fixes #282)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 22 Apr 2012 14:54:36 +0100 |
parent | 4649:e07ce18c503e |
child | 5014:b2006c1cfa85 |
comparison
equal
deleted
inserted
replaced
4653:0b055b588f75 | 4654:0975505f5a54 |
---|---|
16 local jid_join = require "util.jid".join; | 16 local jid_join = require "util.jid".join; |
17 local st = require "util.stanza"; | 17 local st = require "util.stanza"; |
18 | 18 |
19 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 |
20 | 20 |
21 module:hook("resource-bind", function (event) | 21 module:hook("presence/bare", function (event) |
22 local session = event.session; | 22 local session, stanza = event.origin, event.stanza; |
23 local motd_stanza = | 23 if not session.presence and not stanza.attr.type then |
24 st.message({ to = jid_join(session.username, session.host, session.resource), from = motd_jid }) | 24 local motd_stanza = |
25 :tag("body"):text(motd_text); | 25 st.message({ to = session.full_jid, from = motd_jid }) |
26 core_route_stanza(hosts[host], motd_stanza); | 26 :tag("body"):text(motd_text); |
27 module:log("debug", "MOTD send to user %s@%s", session.username, session.host); | 27 core_route_stanza(hosts[host], motd_stanza); |
28 | 28 module:log("debug", "MOTD send to user %s", session.full_jid); |
29 end); | 29 end |
30 end, 1); |