Changeset

215:f86e0b0a0be3

plugins.groupchat: Improve room subject handling, add event
author Kim Alvefur <zash@zash.se>
date Thu, 08 Sep 2011 17:51:11 +0200
parents 214:78ae20c875cd
children 216:3aac084855e6
files plugins/groupchat.lua
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/groupchat.lua	Tue Aug 30 19:26:53 2011 +0200
+++ b/plugins/groupchat.lua	Thu Sep 08 17:51:11 2011 +0200
@@ -92,11 +92,14 @@
 				end
 			end
 		end);
-		room:hook("message", function(msg)
-			local subject = msg.stanza:get_child("subject");
-			subject = subject and subject:get_text();
-			if subject then
-				room.subject = #subject > 0 and subject or nil;
+		room:hook("message", function(event)
+			local subject = event.stanza:get_child_text("subject");
+			if not subject then return end
+			subject = #subject > 0 and subject or nil;
+			if subject ~= room.subject then
+				local old_subject = room.subject;
+				room.subject = subject;
+				return room:event("subject-changed", { from = old_subject, to = subject, by = event.sender, event = event });
 			end
 		end, 2000);
 		local join_st = verse.presence():tag("x",{xmlns = xmlns_muc}):reset();