ejabberdsql2prosody: Display a warning if a row has more columns than expected
[prosody.git] / plugins / mod_watchregistrations.lua
1 -- Prosody IM
2 -- Copyright (C) 2008-2009 Matthew Wild
3 -- Copyright (C) 2008-2009 Waqas Hussain
4 -- 
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
7 --
8
9
10 local host = module:get_host();
11
12 local config = require "core.configmanager";
13
14 local registration_watchers = config.get(host, "core", "registration_watchers") 
15         or config.get(host, "core", "admins") or {};
16
17 local registration_alert = config.get(host, "core", "registration_notification") or "User $username just registered on $host from $ip";
18
19 local st = require "util.stanza";
20
21 module:hook("user-registered",
22         function (user)
23                 module:log("debug", "Notifying of new registration");
24                 local message = st.message{ type = "chat", from = host }
25                                         :tag("body")
26                                         :text(registration_alert:gsub("%$(%w+)", 
27                                                 function (v) return user[v] or user.session and user.session[v] or nil; end));
28                 
29                 for _, jid in ipairs(registration_watchers) do
30                         module:log("debug", "Notifying %s", jid);
31                         message.attr.to = jid;
32                         core_route_stanza(hosts[host], message);
33                 end
34         end);