comparison plugins/mod_watchregistrations.lua @ 7861:58dbe5afeb4a

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Tue, 24 Jan 2017 21:24:03 +0100
parents 49ff363f3a3d
children 6300394bb713
comparison
equal deleted inserted replaced
7859:9eb13c14eaab 7861:58dbe5afeb4a
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