Software /
code /
prosody
Comparison
plugins/mod_motd.lua @ 3170:bf83d75c961a
Add jid support for motd
author | Jeff Mitchell <jeff@jefferai.org> |
---|---|
date | Sat, 29 May 2010 18:52:27 -0400 |
parent | 3169:e37e83660114 |
child | 4083:4d0599e85411 |
comparison
equal
deleted
inserted
replaced
3169:e37e83660114 | 3170:bf83d75c961a |
---|---|
7 -- COPYING file in the source package for more information. | 7 -- COPYING file in the source package for more information. |
8 -- | 8 -- |
9 | 9 |
10 local host = module:get_host(); | 10 local host = module:get_host(); |
11 local motd_text = module:get_option("motd_text") or "MOTD: (blank)"; | 11 local motd_text = module:get_option("motd_text") or "MOTD: (blank)"; |
12 local motd_jid = module:get_option("motd_jid") or host; | |
12 | 13 |
13 local st = require "util.stanza"; | 14 local st = require "util.stanza"; |
14 | 15 |
15 module:hook("resource-bind", | 16 module:hook("resource-bind", |
16 function (event) | 17 function (event) |
17 local session = event.session; | 18 local session = event.session; |
18 local motd_stanza = | 19 local motd_stanza = |
19 st.message({ to = session.username..'@'..session.host, from = host }) | 20 st.message({ to = session.username..'@'..session.host, from = motd_jid }) |
20 :tag("body"):text(motd_text); | 21 :tag("body"):text(motd_text); |
21 core_route_stanza(hosts[host], motd_stanza); | 22 core_route_stanza(hosts[host], motd_stanza); |
22 module:log("debug", "MOTD send to user %s@%s", session.username, session.host); | 23 module:log("debug", "MOTD send to user %s@%s", session.username, session.host); |
23 | 24 |
24 end); | 25 end); |