Mercurial > prosody-hg
comparison plugins/mod_welcome.lua @ 1252:350534579ba3
mod_welcome: Use module:hook instead of module:add_event_hook
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Sun, 31 May 2009 01:15:15 +0500 |
| parents | c68ccb7faeaf |
| children | 841d61be198f |
comparison
equal
deleted
inserted
replaced
| 1251:302582b827ed | 1252:350534579ba3 |
|---|---|
| 11 local host = module:get_host(); | 11 local host = module:get_host(); |
| 12 local welcome_text = config.get("*", "core", "welcome_message") or "Hello $user, welcome to the $host IM server!"; | 12 local welcome_text = config.get("*", "core", "welcome_message") or "Hello $user, welcome to the $host IM server!"; |
| 13 | 13 |
| 14 local st = require "util.stanza"; | 14 local st = require "util.stanza"; |
| 15 | 15 |
| 16 module:add_event_hook("user-registered", | 16 module:hook("user-registered", |
| 17 function (user) | 17 function (user) |
| 18 local welcome_stanza = | 18 local welcome_stanza = |
| 19 st.message({ to = user.username.."@"..user.host, from = host }) | 19 st.message({ to = user.username.."@"..user.host, from = host }) |
| 20 :tag("body"):text(welcome_text:gsub("$(%w+)", user)); | 20 :tag("body"):text(welcome_text:gsub("$(%w+)", user)); |
| 21 core_route_stanza(hosts[host], welcome_stanza); | 21 core_route_stanza(hosts[host], welcome_stanza); |
