comparison mod_muc_bot/mod_muc_bot.lua @ 4565:3b2ae854842c

mod_muc_bot: Save occupant to room This has some side-effects: Firstly, the bot shows up in occupant list, which is nice. Secondly, the bot starts receiving messages from the room which might be wanted, but it would be better to join the room for real in this case.
author Kim Alvefur <zash@zash.se>
date Sat, 10 Apr 2021 19:23:25 +0200
parents d25f0fea270f
children 174c7a3c819b
comparison
equal deleted inserted replaced
4564:d25f0fea270f 4565:3b2ae854842c
26 26
27 local occupant = room:new_occupant(module.host, virtual_occupant_jid); 27 local occupant = room:new_occupant(module.host, virtual_occupant_jid);
28 local join = st.presence({from = event.from; to = virtual_occupant_jid}); 28 local join = st.presence({from = event.from; to = virtual_occupant_jid});
29 local dest_x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user"}); 29 local dest_x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user"});
30 occupant:set_session(event.from, join, true); 30 occupant:set_session(event.from, join, true);
31 room:save_occupant(occupant);
32 room:publicise_occupant_status(occupant, dest_x);
31 -- Inject virtual occupant to trick all the other hooks on this event that 33 -- Inject virtual occupant to trick all the other hooks on this event that
32 -- this is an actual legitimate participant. 34 -- this is an actual legitimate participant.
33 event.occupant = occupant; 35 event.occupant = occupant;
34 36
35 end 37 end