Annotate

plugins/mod_welcome.lua @ 3540:bc139431830b

Monster whitespace commit (beware the whitespace monster).
author Waqas Hussain <waqas20@gmail.com>
date Sat, 16 Oct 2010 23:00:42 +0500
parent 2923:b7049746bd29
child 5014:b2006c1cfa85
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1523
841d61be198f Remove version number from copyright headers
Matthew Wild <mwild1@gmail.com>
parents: 1252
diff changeset
1 -- Prosody IM
2923
b7049746bd29 Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents: 2056
diff changeset
2 -- Copyright (C) 2008-2010 Matthew Wild
b7049746bd29 Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents: 2056
diff changeset
3 -- Copyright (C) 2008-2010 Waqas Hussain
1185
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 host = module:get_host();
2056
c781a949661d mod_welcome: Change $user to $username in default welcome message (thanks to chris for spotting)
Waqas Hussain <waqas20@gmail.com>
parents: 1816
diff changeset
10 local welcome_text = module:get_option("welcome_message") or "Hello $username, welcome to the $host IM server!";
1185
c68ccb7faeaf mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11
c68ccb7faeaf mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 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
13
3540
bc139431830b Monster whitespace commit (beware the whitespace monster).
Waqas Hussain <waqas20@gmail.com>
parents: 2923
diff changeset
14 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
15 function (user)
3540
bc139431830b Monster whitespace commit (beware the whitespace monster).
Waqas Hussain <waqas20@gmail.com>
parents: 2923
diff changeset
16 local welcome_stanza =
1185
c68ccb7faeaf mod_welcome: New plugin to welcome users who register on the server
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 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
18 :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
19 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
20 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
21 end);