29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/lijab/commands/contacts.rb', line 29
def print_contacts(sort_by_status=false, online_only=false)
if sort_by_status
contacts = Main.contacts.sort { |a, b| -(a[1].presence <=> b[1].presence) }
else
contacts = Main.contacts.sort_by { |j,c| c.simple_name }
end
if Config.opts[:show_groups_in_contact_list]
grouped = group_contacts(contacts)
else
grouped = {nil => contacts.map { |j,c| c }}
end
s = []
grouped.each do |group, contactz|
if online_only
next unless contactz.any? { |c| c.online? }
end
s << " #{group} ".on_blue if group
contactz.each do |contact|
unless online_only && !contact.online?
main = contact.presence
s << "* #{contact.simple_name} #{main.pretty(true)} " \
"(#{main.priority || 0}) [#{main.from || contact.jid}]"
if online_only && contact.roster_item.presences.length > 1
contact.roster_item.presences.each do |p|
if p.from != main.from
s << " #{p.from} #{p.pretty(true)} (#{p.priority || 0})"
end
end
end
end
end
end
Out::put(s.join("\n")) unless s.empty?
end
|