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