Software /
code /
prosody
Comparison
plugins/mod_watchregistrations.lua @ 3540:bc139431830b
Monster whitespace commit (beware the whitespace monster).
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sat, 16 Oct 2010 23:00:42 +0500 |
parent | 2923:b7049746bd29 |
child | 4391:71083327f608 |
comparison
equal
deleted
inserted
replaced
3539:8bbd965267b2 | 3540:bc139431830b |
---|---|
7 -- | 7 -- |
8 | 8 |
9 | 9 |
10 local host = module:get_host(); | 10 local host = module:get_host(); |
11 | 11 |
12 local registration_watchers = module:get_option("registration_watchers") | 12 local registration_watchers = module:get_option("registration_watchers") |
13 or module:get_option("admins") or {}; | 13 or module:get_option("admins") or {}; |
14 | 14 |
15 local registration_alert = module:get_option("registration_notification") or "User $username just registered on $host from $ip"; | 15 local registration_alert = module:get_option("registration_notification") or "User $username just registered on $host from $ip"; |
16 | 16 |
17 local st = require "util.stanza"; | 17 local st = require "util.stanza"; |
19 module:hook("user-registered", | 19 module:hook("user-registered", |
20 function (user) | 20 function (user) |
21 module:log("debug", "Notifying of new registration"); | 21 module:log("debug", "Notifying of new registration"); |
22 local message = st.message{ type = "chat", from = host } | 22 local message = st.message{ type = "chat", from = host } |
23 :tag("body") | 23 :tag("body") |
24 :text(registration_alert:gsub("%$(%w+)", | 24 :text(registration_alert:gsub("%$(%w+)", |
25 function (v) return user[v] or user.session and user.session[v] or nil; end)); | 25 function (v) return user[v] or user.session and user.session[v] or nil; end)); |
26 | 26 |
27 for _, jid in ipairs(registration_watchers) do | 27 for _, jid in ipairs(registration_watchers) do |
28 module:log("debug", "Notifying %s", jid); | 28 module:log("debug", "Notifying %s", jid); |
29 message.attr.to = jid; | 29 message.attr.to = jid; |