author | Myhailo Danylenko <isbear@ukrpost.net> |
Tue, 21 Aug 2012 15:47:07 +0300 | |
changeset 131 | d1d2754bbdaf |
parent 99 | ed4676536ed9 |
permissions | -rw-r--r-- |
58
aa3376776cf2
Cosmetic comment changes
Myhailo Danylenko <isbear@ukrpost.net>
parents:
32
diff
changeset
|
1 |
|
8 | 2 |
-- TRANSPORTED BUDDIES AVAILABILITY INDICATION |
3 |
||
9 | 4 |
-- XXX: to option? |
8 | 5 |
transport_jids = { 'icq.jabber.kiev.ua', 'mrim.unixzone.org.ua' } |
6 |
||
32 | 7 |
function online ( jid ) |
8 |
local info = main.buddy_info ( jid ) |
|
9 |
if not info then |
|
10 |
return false |
|
11 |
end |
|
12 |
for resource, params in pairs ( info.resources ) do |
|
13 |
if params.status ~= '_' then |
|
14 |
return true |
|
15 |
end |
|
16 |
end |
|
17 |
return false |
|
18 |
end |
|
19 |
||
99
ed4676536ed9
Update most useful scripts
Myhailo Danylenko <isbear@ukrpost.net>
parents:
58
diff
changeset
|
20 |
local transports_pc_handler = |
8 | 21 |
function ( args ) |
22 |
for k, jid in pairs ( transport_jids ) do |
|
23 |
if args.jid == jid then |
|
24 |
if args.new_status == '_' then |
|
25 |
main.run ( ("color roster * *@%s red"):format ( jid ) ) |
|
26 |
main.run ( ("color roster dn_? *@%s red"):format ( jid ) ) |
|
27 |
else |
|
28 |
main.run ( ("color roster * *@%s white"):format ( jid ) ) |
|
29 |
main.run ( ("color roster dn_? *@%s brightblack"):format ( jid ) ) |
|
30 |
end |
|
31 |
end |
|
32 |
end |
|
33 |
end |
|
34 |
||
99
ed4676536ed9
Update most useful scripts
Myhailo Danylenko <isbear@ukrpost.net>
parents:
58
diff
changeset
|
35 |
main.hook ( 'hook-lua-start', |
8 | 36 |
function ( args ) |
37 |
for k, jid in pairs ( transport_jids ) do |
|
38 |
if not online ( jid ) then |
|
39 |
main.run ( ("color roster * *@%s red"):format ( jid ) ) |
|
40 |
main.run ( ("color roster dn_? *@%s red"):format ( jid ) ) |
|
41 |
else |
|
42 |
main.run ( ("color roster * *@%s white"):format ( jid ) ) |
|
43 |
main.run ( ("color roster dn_? *@%s brightblack"):format ( jid ) ) |
|
44 |
end |
|
45 |
end |
|
99
ed4676536ed9
Update most useful scripts
Myhailo Danylenko <isbear@ukrpost.net>
parents:
58
diff
changeset
|
46 |
end ) |
ed4676536ed9
Update most useful scripts
Myhailo Danylenko <isbear@ukrpost.net>
parents:
58
diff
changeset
|
47 |
main.hook ( 'hook-status-change', transports_pc_handler ) |
ed4676536ed9
Update most useful scripts
Myhailo Danylenko <isbear@ukrpost.net>
parents:
58
diff
changeset
|
48 |
main.hook ( 'hook-post-connect', transports_pc_handler ) |
8 | 49 |
|
99
ed4676536ed9
Update most useful scripts
Myhailo Danylenko <isbear@ukrpost.net>
parents:
58
diff
changeset
|
50 |
main.hook ( 'hook-pre-disconnect', |
9 | 51 |
function ( args ) |
52 |
for k, jid in pairs ( transport_jids ) do |
|
53 |
-- when disconnected, all buddies are inaccessible, so, make them the same |
|
54 |
main.run ( ("color roster * *@%s white"):format ( jid ) ) |
|
55 |
main.run ( ("color roster dn_? *@%s brightblack"):format ( jid ) ) |
|
56 |
end |
|
99
ed4676536ed9
Update most useful scripts
Myhailo Danylenko <isbear@ukrpost.net>
parents:
58
diff
changeset
|
57 |
end ) |
9 | 58 |
|
99
ed4676536ed9
Update most useful scripts
Myhailo Danylenko <isbear@ukrpost.net>
parents:
58
diff
changeset
|
59 |
-- vim: se ts=4 sw=4: -- |