Comparison

mod_muc_intercom/mod_muc_intercom.lua @ 285:108ac6f16d2d

mod_muc_intercom: Add a delay to the forwarded message.
author Kim Alvefur <zash@zash.se>
date Wed, 08 Dec 2010 19:01:13 +0100
parent 280:6d72c5172c74
child 1425:9c894b56b4e4
comparison
equal deleted inserted replaced
284:3b96bba9f7e5 285:108ac6f16d2d
2 -- By Kim Alvefur <zash@zash.se> 2 -- By Kim Alvefur <zash@zash.se>
3 3
4 local host_session = prosody.hosts[module.host]; 4 local host_session = prosody.hosts[module.host];
5 local st_msg = require "util.stanza".message; 5 local st_msg = require "util.stanza".message;
6 local jid = require "util.jid"; 6 local jid = require "util.jid";
7 local now = require "util.datetime".datetime;
7 8
8 function check_message(data) 9 function check_message(data)
9 local origin, stanza = data.origin, data.stanza; 10 local origin, stanza = data.origin, data.stanza;
10 local muc_rooms = host_session.muc and host_session.muc.rooms; 11 local muc_rooms = host_session.muc and host_session.muc.rooms;
11 if not muc_rooms then return; end 12 if not muc_rooms then return; end
31 if not muc_rooms[bare_room] then return; end -- TODO send a error 32 if not muc_rooms[bare_room] then return; end -- TODO send a error
32 module:log("info", "message from %s in %s to %s", from_nick, from_room, target_room); 33 module:log("info", "message from %s in %s to %s", from_nick, from_room, target_room);
33 34
34 local sender = jid.join(target_room, module.host, from_room .. "/" .. from_nick); 35 local sender = jid.join(target_room, module.host, from_room .. "/" .. from_nick);
35 local forward_stanza = st_msg({from = sender, to = bare_room, type = "groupchat"}, message); 36 local forward_stanza = st_msg({from = sender, to = bare_room, type = "groupchat"}, message);
37 forward_stanza:tag("delay", { xmlns = 'urn:xmpp:delay', from = from_room_jid, stamp = now() }):up();
36 38
37 module:log("debug", "broadcasting message to target room"); 39 module:log("debug", "broadcasting message to target room");
38 muc_rooms[bare_room]:broadcast_message(forward_stanza); 40 muc_rooms[bare_room]:broadcast_message(forward_stanza);
39 end 41 end
40 42