Skip to content

Instantly share code, notes, and snippets.

@cmatheson
Last active December 14, 2015 06:49
Show Gist options
  • Save cmatheson/5045459 to your computer and use it in GitHub Desktop.
Save cmatheson/5045459 to your computer and use it in GitHub Desktop.
handy substitutions for irc
use strict;
Irssi::signal_add('message public', 'event_substitute_text');
Irssi::signal_add('message private', 'event_substitute_text');
sub event_substitute_text {
my ($server, $text, $nick, $address, $target) = @_;
my %substitions = (
':\+1:' => '👍',
':-1:' => '👎',
':poop:' => '💩',
':persevere:' => '😣'
);
my %evaled_substitutions = (
'(^|[()\s])g/(\d+)' => '$1"https://gerrit.instructure.com/#/c/".$2."/"',
'(^|[^/])(CNVS-\d+)' => '$1"https://https://instructure.atlassian.net/browse/".$2',
);
for my $re (keys %substitions) {
$text =~ s/$re/$substitions{$re}/g;
}
for my $re (keys %evaled_substitutions) {
$text =~ s/$re/$evaled_substitutions{$re}/eeg;
}
Irssi::signal_continue($server, $text, $nick, $address, $target);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment