Software /
code /
prosody
Comparison
plugins/mod_welcome.lua @ 1185:c68ccb7faeaf
mod_welcome: New plugin to welcome users who register on the server
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 19 May 2009 11:56:52 +0100 |
child | 1252:350534579ba3 |
comparison
equal
deleted
inserted
replaced
1184:fa6df7e83fb3 | 1185:c68ccb7faeaf |
---|---|
1 -- Prosody IM v0.4 | |
2 -- Copyright (C) 2008-2009 Matthew Wild | |
3 -- Copyright (C) 2008-2009 Waqas Hussain | |
4 -- | |
5 -- This project is MIT/X11 licensed. Please see the | |
6 -- COPYING file in the source package for more information. | |
7 -- | |
8 | |
9 local config = require "core.configmanager"; | |
10 | |
11 local host = module:get_host(); | |
12 local welcome_text = config.get("*", "core", "welcome_message") or "Hello $user, welcome to the $host IM server!"; | |
13 | |
14 local st = require "util.stanza"; | |
15 | |
16 module:add_event_hook("user-registered", | |
17 function (user) | |
18 local welcome_stanza = | |
19 st.message({ to = user.username.."@"..user.host, from = host }) | |
20 :tag("body"):text(welcome_text:gsub("$(%w+)", user)); | |
21 core_route_stanza(hosts[host], welcome_stanza); | |
22 module:log("debug", "Welcomed user %s@%s", user.username, user.host); | |
23 end); |