line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
83440
|
use strict; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
30
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
39
|
|
3
|
|
|
|
|
|
|
package Text::SlackEmoji 0.010; |
4
|
|
|
|
|
|
|
# ABSTRACT: data for mapping Slack :emoji_strings: into Unicode text |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use File::ShareDir (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
228
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
9
|
|
|
|
|
|
|
#pod |
10
|
|
|
|
|
|
|
#pod use Text::SlackEmoji; |
11
|
|
|
|
|
|
|
#pod |
12
|
|
|
|
|
|
|
#pod my $emoji = Text::SlackEmoji->emoji_map; |
13
|
|
|
|
|
|
|
#pod |
14
|
|
|
|
|
|
|
#pod $slack_message =~ s!:([-+a-z0-9_]+):!$emoji->{$1} // ":$1:"!ge; |
15
|
|
|
|
|
|
|
#pod |
16
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
17
|
|
|
|
|
|
|
#pod |
18
|
|
|
|
|
|
|
#pod This library is basically just a container around a hash mapping strings like |
19
|
|
|
|
|
|
|
#pod "disappointed_relieved" to Unicode text like 😥 . |
20
|
|
|
|
|
|
|
#pod |
21
|
|
|
|
|
|
|
#pod =head1 SECRET ORIGINS |
22
|
|
|
|
|
|
|
#pod |
23
|
|
|
|
|
|
|
#pod I made the first version of this lookup to power a little C plugin so |
24
|
|
|
|
|
|
|
#pod that when using the Slack IRC gateway, I'd see the same emoji as the people |
25
|
|
|
|
|
|
|
#pod using the Slack app, at least when possible. |
26
|
|
|
|
|
|
|
#pod |
27
|
|
|
|
|
|
|
#pod =cut |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our %Emoji; |
30
|
|
|
|
|
|
|
sub _initialize_emoji { |
31
|
2
|
100
|
|
2
|
|
9
|
$_[0]->load_emoji unless %Emoji; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#pod =method load_emoji |
35
|
|
|
|
|
|
|
#pod |
36
|
|
|
|
|
|
|
#pod This method reloads the emoji map from disk, allowing the mapping to be updated |
37
|
|
|
|
|
|
|
#pod in (say) your IRC client without forcing the reload of the module. |
38
|
|
|
|
|
|
|
#pod |
39
|
|
|
|
|
|
|
#pod =cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub load_emoji { |
42
|
1
|
|
|
1
|
1
|
6
|
my $emoji_file = File::ShareDir::dist_file('Text-SlackEmoji', 'emoji.pl'); |
43
|
1
|
|
|
|
|
157
|
%Emoji = %{ do $emoji_file }; |
|
1
|
|
|
|
|
34127
|
|
44
|
1
|
|
|
|
|
211
|
return; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__PACKAGE__->_initialize_emoji; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
#pod =method emoji_map |
50
|
|
|
|
|
|
|
#pod |
51
|
|
|
|
|
|
|
#pod This method takes no arguments and returns a hashref mapping Slack emoji names |
52
|
|
|
|
|
|
|
#pod to Unicode strings. The strings may be more than one character long. |
53
|
|
|
|
|
|
|
#pod |
54
|
|
|
|
|
|
|
#pod =cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub emoji_map { |
57
|
1
|
|
|
1
|
1
|
104
|
my ($self) = @_; |
58
|
1
|
|
|
|
|
4
|
$self->_initialize_emoji; |
59
|
1
|
|
|
|
|
1465
|
return { %Emoji }; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |