-- TRANSPORTED BUDDIES AVAILABILITY INDICATION
-- XXX: to option?
transport_jids = { 'icq.jabber.kiev.ua', 'mrim.unixzone.org.ua' }
function online ( jid )
local info = main.buddy_info ( jid )
if not info then
return false
end
for resource, params in pairs ( info.resources ) do
if params.status ~= '_' then
return true
end
end
return false
end
local transports_pc_handler =
function ( args )
for k, jid in pairs ( transport_jids ) do
if args.jid == jid then
if args.new_status == '_' then
main.run ( ("color roster * *@%s red"):format ( jid ) )
main.run ( ("color roster dn_? *@%s red"):format ( jid ) )
else
main.run ( ("color roster * *@%s white"):format ( jid ) )
main.run ( ("color roster dn_? *@%s brightblack"):format ( jid ) )
end
end
end
end
main.hook ( 'hook-lua-start',
function ( args )
for k, jid in pairs ( transport_jids ) do
if not online ( jid ) then
main.run ( ("color roster * *@%s red"):format ( jid ) )
main.run ( ("color roster dn_? *@%s red"):format ( jid ) )
else
main.run ( ("color roster * *@%s white"):format ( jid ) )
main.run ( ("color roster dn_? *@%s brightblack"):format ( jid ) )
end
end
end )
main.hook ( 'hook-status-change', transports_pc_handler )
main.hook ( 'hook-post-connect', transports_pc_handler )
main.hook ( 'hook-pre-disconnect',
function ( args )
for k, jid in pairs ( transport_jids ) do
-- when disconnected, all buddies are inaccessible, so, make them the same
main.run ( ("color roster * *@%s white"):format ( jid ) )
main.run ( ("color roster dn_? *@%s brightblack"):format ( jid ) )
end
end )
-- vim: se ts=4 sw=4: --