Software /
code /
prosody
Annotate
plugins/mod_welcome.lua @ 1730:f4170bc82969
modulemanager: Fixed: Internally generated stanzas could be missing namespaces, which causes tracebacks in logging (e.g., auto-generated offline presence)
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sun, 06 Sep 2009 01:31:18 +0500 |
parent | 1523:841d61be198f |
child | 1650:b010d6711527 |
child | 1814:846224d7a377 |
rev | line source |
---|---|
1523
841d61be198f
Remove version number from copyright headers
Matthew Wild <mwild1@gmail.com>
parents:
1252
diff
changeset
|
1 -- Prosody IM |
1185
c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 -- Copyright (C) 2008-2009 Matthew Wild |
c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 -- Copyright (C) 2008-2009 Waqas Hussain |
c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 -- |
c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 -- This project is MIT/X11 licensed. Please see the |
c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 -- COPYING file in the source package for more information. |
c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 -- |
c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 |
c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 local config = require "core.configmanager"; |
c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 |
c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 local host = module:get_host(); |
c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 local welcome_text = config.get("*", "core", "welcome_message") or "Hello $user, welcome to the $host IM server!"; |
c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 |
c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 local st = require "util.stanza"; |
c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 |
1252
350534579ba3
mod_welcome: Use module:hook instead of module:add_event_hook
Waqas Hussain <waqas20@gmail.com>
parents:
1185
diff
changeset
|
16 module:hook("user-registered", |
1185
c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 function (user) |
c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 local welcome_stanza = |
c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 st.message({ to = user.username.."@"..user.host, from = host }) |
c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 :tag("body"):text(welcome_text:gsub("$(%w+)", user)); |
c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 core_route_stanza(hosts[host], welcome_stanza); |
c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 module:log("debug", "Welcomed user %s@%s", user.username, user.host); |
c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 end); |