Mercurial > prosody-hg
comparison plugins/mod_watchregistrations.lua @ 1251:302582b827ed
mod_watchregistrations: Use module:hook instead of module:add_event_hook
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Sun, 31 May 2009 01:14:57 +0500 |
| parents | 3ec37e678b46 |
| children | 569d58d21612 |
comparison
equal
deleted
inserted
replaced
| 1250:ef053ab86f5e | 1251:302582b827ed |
|---|---|
| 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)); |
