Diff

plugins/muc/muc.lib.lua @ 6431:540f4e33394a

muc: Add 'occupant' to muc-occupant-{joined,left,session-new} events (thanks daurnimator/fippo)
author Matthew Wild <mwild1@gmail.com>
date Fri, 26 Sep 2014 17:34:15 +0100
parent 6429:675aea867574
child 6451:385932a83013
line wrap: on
line diff
--- a/plugins/muc/muc.lib.lua	Fri Sep 26 17:10:43 2014 +0100
+++ b/plugins/muc/muc.lib.lua	Fri Sep 26 17:34:15 2014 +0100
@@ -398,10 +398,14 @@
 		if orig_occupant == nil then
 			event_name = "muc-occupant-pre-join";
 			event.is_new_room = is_new_room;
+			event.occupant = dest_occupant;
 		elseif dest_occupant == nil then
 			event_name = "muc-occupant-pre-leave";
+			event.occupant = orig_occupant;
 		else
 			event_name = "muc-occupant-pre-change";
+			event.orig_occupant = orig_occupant;
+			event.dest_occupant = dest_occupant;
 		end
 		if module:fire_event(event_name, event) then return true; end
 
@@ -460,7 +464,7 @@
 			self:publicise_occupant_status(orig_occupant, orig_x, dest_nick);
 
 			if is_last_orig_session then
-				module:fire_event("muc-occupant-left", {room = self; nick = orig_occupant.nick;});
+				module:fire_event("muc-occupant-left", {room = self; nick = orig_occupant.nick; occupant = orig_occupant;});
 			end
 		end
 
@@ -498,9 +502,9 @@
 
 			if orig_occupant == nil then
 				if is_first_dest_session then
-					module:fire_event("muc-occupant-joined", {room = self; nick = dest_occupant.nick; stanza = stanza;});
+					module:fire_event("muc-occupant-joined", {room = self; nick = dest_occupant.nick; occupant = dest_occupant;});
 				end
-				module:fire_event("muc-occupant-session-new", {room = self; nick = dest_occupant.nick; stanza = stanza; jid = real_jid;});
+				module:fire_event("muc-occupant-session-new", {room = self; nick = dest_occupant.nick; occupant = dest_occupant; stanza = stanza; jid = real_jid;});
 			end
 		end
 	elseif type ~= 'result' then -- bad type
@@ -669,7 +673,7 @@
 	end
 	for occupant in pairs(occupants_updated) do
 		self:publicise_occupant_status(occupant, x);
-		module:fire_event("muc-occupant-left", { room = self; nick = occupant.nick; });
+		module:fire_event("muc-occupant-left", { room = self; nick = occupant.nick; occupant = occupant;});
 	end
 end