Software / code / prosody
Annotate
plugins/mod_watchregistrations.lua @ 1828:48cb27e2716e
core.s2smanager: Always use last record in the DNS cache
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sun, 27 Sep 2009 11:59:11 +0100 |
| parent | 1522:569d58d21612 |
| child | 1654:0ae73e3d306f |
| rev | line source |
|---|---|
|
1522
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
1251
diff
changeset
|
1 -- Prosody IM |
|
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
1251
diff
changeset
|
2 -- Copyright (C) 2008-2009 Matthew Wild |
|
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
1251
diff
changeset
|
3 -- Copyright (C) 2008-2009 Waqas Hussain |
|
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
1251
diff
changeset
|
4 -- |
|
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
1251
diff
changeset
|
5 -- This project is MIT/X11 licensed. Please see the |
|
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
1251
diff
changeset
|
6 -- COPYING file in the source package for more information. |
|
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
1251
diff
changeset
|
7 -- |
|
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
1251
diff
changeset
|
8 |
|
1201
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 |
|
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 local host = module:get_host(); |
|
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 |
|
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 local config = require "core.configmanager"; |
|
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 |
|
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 local registration_watchers = config.get(host, "core", "registration_watchers") |
|
1206
3ec37e678b46
mod_watchregistrations: admin -> admins
Matthew Wild <mwild1@gmail.com>
parents:
1201
diff
changeset
|
15 or config.get(host, "core", "admins") or {}; |
|
1201
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 |
|
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 local registration_alert = config.get(host, "core", "registration_notification") or "User $username just registered on $host from $ip"; |
|
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 |
|
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 local st = require "util.stanza"; |
|
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 |
|
1251
302582b827ed
mod_watchregistrations: Use module:hook instead of module:add_event_hook
Waqas Hussain <waqas20@gmail.com>
parents:
1206
diff
changeset
|
21 module:hook("user-registered", |
|
302582b827ed
mod_watchregistrations: Use module:hook instead of module:add_event_hook
Waqas Hussain <waqas20@gmail.com>
parents:
1206
diff
changeset
|
22 function (user) |
|
1201
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 module:log("debug", "Notifying of new registration"); |
|
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 local message = st.message{ type = "chat", from = host } |
|
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 :tag("body") |
|
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 :text(registration_alert:gsub("%$(%w+)", |
|
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 function (v) return user[v] or user.session and user.session[v] or nil; end)); |
|
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 |
|
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 for _, jid in ipairs(registration_watchers) do |
|
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 module:log("debug", "Notifying %s", jid); |
|
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 message.attr.to = jid; |
|
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 core_route_stanza(hosts[host], message); |
|
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 end |
|
9d5c1b2cf89c
mod_watchregistrations: New plugin to send a message to admins when a new user registers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 end); |