Mercurial > prosody-modules
comparison mod_muc_require_tos/mod_muc_require_tos.lua @ 4691:1f1dbf652b37
mod_muc_require_tos: Send the message after the subject, once the client is fully joined
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Thu, 16 Sep 2021 22:32:59 +0200 |
parents | 82dabfffaddf |
children | 37232302dfb9 |
comparison
equal
deleted
inserted
replaced
4690:82dabfffaddf | 4691:1f1dbf652b37 |
---|---|
4 local quick_response_ns = "urn:xmpp:tmp:quick-response"; | 4 local quick_response_ns = "urn:xmpp:tmp:quick-response"; |
5 local welcome_message = module:get_option_string("tos_welcome_message"); | 5 local welcome_message = module:get_option_string("tos_welcome_message"); |
6 local yes_message = module:get_option_string("tos_yes_message"); | 6 local yes_message = module:get_option_string("tos_yes_message"); |
7 local no_message = module:get_option_string("tos_no_message"); | 7 local no_message = module:get_option_string("tos_no_message"); |
8 | 8 |
9 module:hook("muc-occupant-joined", function(event) | 9 module:hook("muc-occupant-session-new", function(event) |
10 local origin = event.origin; | 10 local origin = event.origin; |
11 local room = event.room; | 11 local room = event.room; |
12 local occupant = event.occupant; | 12 local occupant = event.occupant; |
13 local nick = occupant.nick; | 13 local nick = occupant.nick; |
14 module:log("debug", "%s joined %s (%s)", nick, room, origin); | 14 module:log("debug", "%s joined %s (%s)", nick, room, origin); |
22 }, welcome_message) | 22 }, welcome_message) |
23 :tag("response", { xmlns = quick_response_ns, value = "yes", label = "I accept." }):up() | 23 :tag("response", { xmlns = quick_response_ns, value = "yes", label = "I accept." }):up() |
24 :tag("response", { xmlns = quick_response_ns, value = "no", label = "I decline." }):up(); | 24 :tag("response", { xmlns = quick_response_ns, value = "no", label = "I decline." }):up(); |
25 origin.send(message); | 25 origin.send(message); |
26 end | 26 end |
27 end); | 27 end, 19); |
28 | 28 |
29 module:hook("muc-occupant-groupchat", function(event) | 29 module:hook("muc-occupant-groupchat", function(event) |
30 local occupant = event.occupant; | 30 local occupant = event.occupant; |
31 if occupant.role ~= "visitor" then | 31 if occupant.role ~= "visitor" then |
32 return; | 32 return; |