|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
  
 
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Slack::RTM::Bot::Information;
  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
  | 
| 
3
 | 
8
 | 
 
 | 
 
 | 
  
8
  
 | 
 
 | 
58
 | 
 use strict;
  | 
| 
 
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
22
 | 
    | 
| 
 
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
252
 | 
    | 
| 
4
 | 
8
 | 
 
 | 
 
 | 
  
8
  
 | 
 
 | 
45
 | 
 use warnings;
  | 
| 
 
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
17
 | 
    | 
| 
 
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3181
 | 
    | 
| 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
  | 
| 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub new {
  | 
| 
7
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
  
0
  
 | 
128
 | 
 	my $pkg = shift;
  | 
| 
8
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
8
 | 
 	my ($args) = {@_};
  | 
| 
9
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
 	my $self = {
  | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 		@_,
  | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	};
  | 
| 
12
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
8
 | 
 	$self->{users}    = &_parse_users($args);
  | 
| 
13
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
 	$self->{channels} = &_parse_conversations($args);
  | 
| 
14
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
11
 | 
 	return bless $self, $pkg;
  | 
| 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }
  | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
  | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _parse_users {
  | 
| 
18
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
4
 | 
 	my $args = shift;
  | 
| 
19
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
 	my $users = {};
  | 
| 
20
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
 	for my $user (@{$args->{users}}){
  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
    | 
| 
21
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
 		$users->{$user->{id}} = $user;
  | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	}
  | 
| 
23
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
 	return $users;
  | 
| 
24
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }
  | 
| 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _parse_conversations {
  | 
| 
27
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
4
 | 
 	my $args = shift;
  | 
| 
28
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
 	my $conversations = {};
  | 
| 
29
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
 	for my $conversation (@{$args->{channels}}){
  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
    | 
| 
30
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
 		$conversations->{$conversation->{id}} = $conversation;
  | 
| 
31
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	}
  | 
| 
32
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
 	return $conversations;
  | 
| 
33
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }
  | 
| 
34
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
  | 
| 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _find_conversation_id {
  | 
| 
36
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
1114
 | 
 	my $self = shift;
  | 
| 
37
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
 	my ($name) = @_;
  | 
| 
38
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
 	my $conversations = $self->{channels};
  | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
  | 
| 
40
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2
 | 
 	for my $key (keys %{$conversations}){
  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
    | 
| 
41
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
5
 | 
 		if($name eq $conversations->{$key}->{name}){
  | 
| 
42
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
 			return $conversations->{$key}->{id};
  | 
| 
43
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 		}
  | 
| 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	}
  | 
| 
45
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
 	return undef;
  | 
| 
46
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }
  | 
| 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
  | 
| 
48
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _find_conversation_name {
  | 
| 
49
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
4
 | 
 	my $self = shift;
  | 
| 
50
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
 	my ($id) = @_;
  | 
| 
51
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
 	my $conversations = $self->{channels};
  | 
| 
52
 | 
2
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
11
 | 
 	return $conversations->{$id}->{name} if $conversations->{$id};
  | 
| 
53
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }
  | 
| 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
  | 
| 
55
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _find_user_name {
  | 
| 
56
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
 
 | 
2686
 | 
 	my $self = shift;
  | 
| 
57
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
 	my ($id) = @_;
  | 
| 
58
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
8
 | 
 	my $users = $self->{users};
  | 
| 
59
 | 
3
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
18
 | 
 	return $users->{$id}->{name} if $users->{$id};
  | 
| 
60
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }
  | 
| 
61
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
  | 
| 
62
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;
  |