examples/lm/muc.lua
changeset 77 8a7f7829f4df
child 111 5bcdb71ef2f2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/lm/muc.lua	Sun Jul 26 15:15:20 2009 +0300
@@ -0,0 +1,41 @@
+
+-- MULTI-USER CHAT (XEP-0045)
+-- only owner room configuration
+
+-- library
+
+local iq     = require 'lm.iq'
+local x_data = require 'lm.x_data'
+
+--
+
+local F = { }
+
+function F.owner_config ( conn, to, success, fail )
+	iq.send ( conn, to, 'get',
+		{
+			query = { xmlns = 'http://jabber.org/protocol/muc#owner' },
+		},
+		function ( mess )
+			local x = mess:path ( 'query', 'x' )
+			if x then
+				success ( x_data.parse ( x ),
+					function ( form, success, fail )
+						iq.send ( conn, to, 'set',
+							{
+								command = form:format ( { xmlns = 'http://jabber.org/protocol/muc#owner' }, 'submit' ),
+							}, success, fail )
+					end,
+					function ( form, success, fail )
+						iq.send ( conn, to, 'set',
+							{
+								command = form:format ( { xmlns = 'http://jabber.org/protocol/muc#owner' }, 'cancel' ),
+							}, success, fail )
+					end )
+			end
+		end, fail )
+end
+
+return F
+
+-- vim: se ts=4: --