8 |
8 |
9 local registration_alert = config.get(host, "core", "registration_notification") or "User $username just registered on $host from $ip"; |
9 local registration_alert = config.get(host, "core", "registration_notification") or "User $username just registered on $host from $ip"; |
10 |
10 |
11 local st = require "util.stanza"; |
11 local st = require "util.stanza"; |
12 |
12 |
13 module:add_event_hook("user-registered", function (user) |
13 module:hook("user-registered", |
|
14 function (user) |
14 module:log("debug", "Notifying of new registration"); |
15 module:log("debug", "Notifying of new registration"); |
15 local message = st.message{ type = "chat", from = host } |
16 local message = st.message{ type = "chat", from = host } |
16 :tag("body") |
17 :tag("body") |
17 :text(registration_alert:gsub("%$(%w+)", |
18 :text(registration_alert:gsub("%$(%w+)", |
18 function (v) return user[v] or user.session and user.session[v] or nil; end)); |
19 function (v) return user[v] or user.session and user.session[v] or nil; end)); |