Skip to content

Instantly share code, notes, and snippets.

@rjbs
Last active October 9, 2015 15:34
Show Gist options
  • Save rjbs/15fe4f56fd3533c8fa02 to your computer and use it in GitHub Desktop.
Save rjbs/15fe4f56fd3533c8fa02 to your computer and use it in GitHub Desktop.
=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