Update most useful scripts
* new hooks interface
* connection state checking
-- ATTENTION (XEP-0224)
-- library
local lm = require 'lm'
--
local O = {
handler =
function ( mesg, from )
end,
}
local F = { }
function F.send ( conn, to, message )
local body = nil
if message then
body = { message }
end
conn:send (
lm.message.create { mtype = 'message-headline', to = to,
attention = { xmlns = 'urn:xmpp:attention:0' },
body = body,
} )
end
function F.handler ( handler )
O.handler = handler
end
function F.message_handler ( conn, mess )
local a = mess:child ( 'attention' )
if a and a:attribute ( 'xmlns' ) == 'urn:xmpp:attention:0' then
local body = mess:child ( 'body' )
if body then
body = body:value ()
end
O.handler ( body, mess:attribute ( "from" ) )
end
return false
end
return F
-- vim: se ts=4: --