Comparison

plugins/mod_watchregistrations.lua @ 7860:49ff363f3a3d

mod_watchregistrations: add a "registration_from" option This option, if set, makes all registration notifications come from a single JID, regardless of which virtualhost it comes from.
author mathieui
date Tue, 24 Jan 2017 21:13:23 +0100
parent 7268:29861845e0e0
child 8154:6300394bb713
comparison
equal deleted inserted replaced
7858:14fe60a65c69 7860:49ff363f3a3d
9 9
10 local host = module:get_host(); 10 local host = module:get_host();
11 local jid_prep = require "util.jid".prep; 11 local jid_prep = require "util.jid".prep;
12 12
13 local registration_watchers = module:get_option_set("registration_watchers", module:get_option("admins", {})) / 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);
14 local registration_notification = module:get_option_string("registration_notification", "User $username just registered on $host from $ip"); 15 local registration_notification = module:get_option_string("registration_notification", "User $username just registered on $host from $ip");
15 16
16 local st = require "util.stanza"; 17 local st = require "util.stanza";
17 18
18 module:hook("user-registered", function (user) 19 module:hook("user-registered", function (user)
19 module:log("debug", "Notifying of new registration"); 20 module:log("debug", "Notifying of new registration");
20 local message = st.message{ type = "chat", from = host } 21 local message = st.message{ type = "chat", from = registration_from }
21 :tag("body") 22 :tag("body")
22 :text(registration_notification:gsub("%$(%w+)", function (v) 23 :text(registration_notification:gsub("%$(%w+)", function (v)
23 return user[v] or user.session and user.session[v] or nil; 24 return user[v] or user.session and user.session[v] or nil;
24 end)); 25 end));
25 for jid in registration_watchers do 26 for jid in registration_watchers do