Last active
October 9, 2015 15:34
-
-
Save rjbs/15fe4f56fd3533c8fa02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=pod | |
_________________________________________ | |
/ moved to \ | |
| https://github.com/rjbs/rjbs-dots/blob/ | | |
\ master/.irssi/scripts/slack-emoji.pl / | |
----------------------------------------- | |
\ ^__^ | |
\ (oo)\_______ | |
(__)\ )\/\ | |
||----w | | |
|| || | |
=cut | |
use warnings; | |
use strict; | |
use charnames ':full'; | |
use Irssi (); | |
our $VERSION = '0.001'; | |
our %IRSSI = ( | |
authors => 'rjbs', | |
name => 'slack-emoji', | |
); | |
my %emoji = ( | |
'imp' => "\N{IMP}", | |
'heart' => "\N{BLUE HEART}", # Pobox, yo. | |
'poop' => "\N{PILE OF POO}", | |
'smile' => "\N{SMILING FACE WITH OPEN MOUTH AND SMILING EYES}", | |
'+1' => "\N{THUMBS UP SIGN}", | |
'-1' => "\N{THUMBS DOWN SIGN}", | |
); | |
sub munge_emoji { | |
my ($target, $text) = split / :/, $_[0], 2; | |
# make this :[^:]+: later --rjbs | |
$text =~ s/:$_:/$emoji{$_}/g for keys %emoji; | |
return "$target :$text"; | |
} | |
sub expand_emoji { | |
my ($server, $data, $nick, $address) = @_; | |
return unless $server->{chatnet} =~ /slack/; | |
Irssi::signal_stop(); | |
Irssi::signal_remove('event privmsg', 'expand_emoji'); | |
Irssi::signal_emit('event privmsg', | |
$server, | |
munge_emoji($data), | |
$nick, | |
$address, | |
); | |
Irssi::signal_add('event privmsg', 'expand_emoji'); | |
} | |
Irssi::signal_add('event privmsg' => 'expand_emoji'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/rjbs/rjbs-dots/blob/master/.irssi/scripts/slack-emoji.pl