Comparison

plugins/mod_watchregistrations.lua @ 8812:3d7fceaff230

mod_watchregistrations: Allow making the message type configurable
author Kim Alvefur <zash@zash.se>
date Sun, 20 May 2018 18:56:26 +0200
parent 8154:6300394bb713
child 12977:74b9e05af71e
comparison
equal deleted inserted replaced
8811:f2d35eee69c9 8812:3d7fceaff230
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_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"); 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");
16 17
17 local st = require "util.stanza"; 18 local st = require "util.stanza";
18 19
19 module:hook("user-registered", function (user) 20 module:hook("user-registered", function (user)
20 module:log("debug", "Notifying of new registration"); 21 module:log("debug", "Notifying of new registration");
21 local message = st.message{ type = "chat", from = registration_from } 22 local message = st.message{ type = msg_type, from = registration_from }
22 :tag("body") 23 :tag("body")
23 :text(registration_notification:gsub("%$(%w+)", function (v) 24 :text(registration_notification:gsub("%$(%w+)", function (v)
24 return user[v] or user.session and user.session[v] or nil; 25 return user[v] or user.session and user.session[v] or nil;
25 end)) 26 end))
26 :up(); 27 :up();