mod_csi_simple: Consider messages encrypted payload as important (fixes part of ...
[prosody.git] / plugins / mod_watchregistrations.lua
blob825b8a735c0170de038a8aa708a3d399c9aa1be6
1 -- Prosody IM
2 -- Copyright (C) 2008-2010 Matthew Wild
3 -- Copyright (C) 2008-2010 Waqas Hussain
4 --
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
7 --
10 local host = module:get_host();
11 local jid_prep = require "util.jid".prep;
13 local registration_watchers = module:get_option_set("registration_watchers", module:get_option("admins", {})) / jid_prep;
14 local registration_from = module:get_option_string("registration_from", host);
15 local registration_notification = module:get_option_string("registration_notification", "User $username just registered on $host from $ip");
16 local msg_type = module:get_option_string("registration_notification_type", "chat");
18 local st = require "util.stanza";
20 module:hook("user-registered", function (user)
21 module:log("debug", "Notifying of new registration");
22 local message = st.message{ type = msg_type, from = registration_from }
23 :tag("body")
24 :text(registration_notification:gsub("%$(%w+)", function (v)
25 return user[v] or user.session and user.session[v] or nil;
26 end))
27 :up();
28 for jid in registration_watchers do
29 module:log("debug", "Notifying %s", jid);
30 message.attr.to = jid;
31 module:send(message);
32 end
33 end);