examples/transports.lua
author Myhailo Danylenko <isbear@ukrpost.net>
Mon, 16 Mar 2009 05:31:24 +0200
changeset 31 54957980a83a
parent 9 c2517f8bf647
child 32 524fde5be49a
permissions -rw-r--r--
yesno in C, no config_file

-- TRANSPORTED BUDDIES AVAILABILITY INDICATION

-- XXX: to option?
transport_jids = { 'icq.jabber.kiev.ua', 'mrim.unixzone.org.ua' }

hooks_d['hook-status-change'].transports =
	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

hooks_d['hook-start'].transports =
	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

hooks_d['hook-post-connect'].transports = hooks_d['hook-start'].transports

hooks_d['hook-pre-disconnect'].transports =
	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: --