plugins/mod_welcome.lua
changeset 3540 bc139431830b
parent 2923 b7049746bd29
child 5014 b2006c1cfa85
equal deleted inserted replaced
3539:8bbd965267b2 3540:bc139431830b
     9 local host = module:get_host();
     9 local host = module:get_host();
    10 local welcome_text = module:get_option("welcome_message") or "Hello $username, welcome to the $host IM server!";
    10 local welcome_text = module:get_option("welcome_message") or "Hello $username, welcome to the $host IM server!";
    11 
    11 
    12 local st = require "util.stanza";
    12 local st = require "util.stanza";
    13 
    13 
    14 module:hook("user-registered", 
    14 module:hook("user-registered",
    15 	function (user)
    15 	function (user)
    16 		local welcome_stanza = 
    16 		local welcome_stanza =
    17 			st.message({ to = user.username.."@"..user.host, from = host })
    17 			st.message({ to = user.username.."@"..user.host, from = host })
    18 				:tag("body"):text(welcome_text:gsub("$(%w+)", user));
    18 				:tag("body"):text(welcome_text:gsub("$(%w+)", user));
    19 		core_route_stanza(hosts[host], welcome_stanza);
    19 		core_route_stanza(hosts[host], welcome_stanza);
    20 		module:log("debug", "Welcomed user %s@%s", user.username, user.host);
    20 		module:log("debug", "Welcomed user %s@%s", user.username, user.host);
    21 	end);
    21 	end);