mod_ping: Convert from Windows line endings
[prosody.git] / plugins / mod_watchregistrations.lua
1
2 local host = module:get_host();
3
4 local config = require "core.configmanager";
5
6 local registration_watchers = config.get(host, "core", "registration_watchers") 
7         or config.get(host, "core", "admins") or {};
8
9 local registration_alert = config.get(host, "core", "registration_notification") or "User $username just registered on $host from $ip";
10
11 local st = require "util.stanza";
12
13 module:hook("user-registered",
14         function (user)
15                 module:log("debug", "Notifying of new registration");
16                 local message = st.message{ type = "chat", from = host }
17                                         :tag("body")
18                                         :text(registration_alert:gsub("%$(%w+)", 
19                                                 function (v) return user[v] or user.session and user.session[v] or nil; end));
20                 
21                 for _, jid in ipairs(registration_watchers) do
22                         module:log("debug", "Notifying %s", jid);
23                         message.attr.to = jid;
24                         core_route_stanza(hosts[host], message);
25                 end
26         end);