8
|
1 |
-- TRANSPORTED BUDDIES AVAILABILITY INDICATION |
|
2 |
|
9
|
3 |
-- XXX: to option? |
8
|
4 |
transport_jids = { 'icq.jabber.kiev.ua', 'mrim.unixzone.org.ua' } |
|
5 |
|
32
|
6 |
function online ( jid ) |
|
7 |
local info = main.buddy_info ( jid ) |
|
8 |
if not info then |
|
9 |
return false |
|
10 |
end |
|
11 |
for resource, params in pairs ( info.resources ) do |
|
12 |
if params.status ~= '_' then |
|
13 |
return true |
|
14 |
end |
|
15 |
end |
|
16 |
return false |
|
17 |
end |
|
18 |
|
8
|
19 |
hooks_d['hook-status-change'].transports = |
|
20 |
function ( args ) |
|
21 |
for k, jid in pairs ( transport_jids ) do |
|
22 |
if args.jid == jid then |
|
23 |
if args.new_status == '_' then |
|
24 |
main.run ( ("color roster * *@%s red"):format ( jid ) ) |
|
25 |
main.run ( ("color roster dn_? *@%s red"):format ( jid ) ) |
|
26 |
else |
|
27 |
main.run ( ("color roster * *@%s white"):format ( jid ) ) |
|
28 |
main.run ( ("color roster dn_? *@%s brightblack"):format ( jid ) ) |
|
29 |
end |
|
30 |
end |
|
31 |
end |
|
32 |
end |
|
33 |
|
|
34 |
hooks_d['hook-start'].transports = |
|
35 |
function ( args ) |
|
36 |
for k, jid in pairs ( transport_jids ) do |
|
37 |
if not online ( jid ) then |
|
38 |
main.run ( ("color roster * *@%s red"):format ( jid ) ) |
|
39 |
main.run ( ("color roster dn_? *@%s red"):format ( jid ) ) |
|
40 |
else |
|
41 |
main.run ( ("color roster * *@%s white"):format ( jid ) ) |
|
42 |
main.run ( ("color roster dn_? *@%s brightblack"):format ( jid ) ) |
|
43 |
end |
|
44 |
end |
|
45 |
end |
|
46 |
|
9
|
47 |
hooks_d['hook-post-connect'].transports = hooks_d['hook-start'].transports |
|
48 |
|
|
49 |
hooks_d['hook-pre-disconnect'].transports = |
|
50 |
function ( args ) |
|
51 |
for k, jid in pairs ( transport_jids ) do |
|
52 |
-- when disconnected, all buddies are inaccessible, so, make them the same |
|
53 |
main.run ( ("color roster * *@%s white"):format ( jid ) ) |
|
54 |
main.run ( ("color roster dn_? *@%s brightblack"):format ( jid ) ) |
|
55 |
end |
|
56 |
end |
|
57 |
|
8
|
58 |
-- vim: se ts=4: -- |