diff options
| author | Ævar Arnfjörð Bjarmason | 2016-03-15 17:52:13 +0000 | 
|---|---|---|
| committer | Ævar Arnfjörð Bjarmason | 2016-03-16 11:07:11 +0000 | 
| commit | a098b519551471f4ef84f4c942b57fe9e640ab5d (patch) | |
| tree | bbf9abca036bdd37664b67284c8a7b40628034b2 /scripts/slack_strip_auto_cc.pl | |
| parent | 5dbfd9f54b6dbc114458ea02bbb1a75e1f447302 (diff) | |
| download | scripts.irssi.org-a098b519551471f4ef84f4c942b57fe9e640ab5d.tar.bz2 | |
Submit my collection of scripts from my dotfiles.git
These are all irssi scripts that I maintain & use myself that I think
are useful for general use, none of this has anything hardcoded related
to me and when applicable has a configurable interface.
Diffstat (limited to 'scripts/slack_strip_auto_cc.pl')
| -rw-r--r-- | scripts/slack_strip_auto_cc.pl | 35 | 
1 files changed, 35 insertions, 0 deletions
| diff --git a/scripts/slack_strip_auto_cc.pl b/scripts/slack_strip_auto_cc.pl new file mode 100644 index 0000000..b4fac4e --- /dev/null +++ b/scripts/slack_strip_auto_cc.pl @@ -0,0 +1,35 @@ +use strict; +use warnings; +use Irssi; + +our $VERSION = '1.0'; +our %IRSSI = ( +    authors     => 'Ævar Arnfjörð Bjarmason', +    contact     => 'avarab@gmail.com', +    name        => 'slack_strip_auto_cc.pl', +    description => 'Strips the annoying mentions of your nickname on Slack via [cc: <you>]', +    license     => 'Public Domain', +    url         => 'http://scripts.irssi.org & https://github.com/avar/dotfiles/blob/master/.irssi/scripts/slack_strip_auto_cc.pl', +); + +# HOWTO: +# +#   /load slack_strip_auto_cc.pl +# +# This should just automatically work, it'll detect if you're using +# the slack IRC gateway and auto-detect the nick it should be +# stripping as well. + +sub privmsg_slack_strip_auto_cc { +    my ($server, $data, $nick, $nick_and_address) = @_; +    my ($target, $message) = split /:/, $data, 2; + +    return unless $server->{address} =~ /irc\.slack\.com$/s; +    my $wanted_nick = $server->{wanted_nick}; +    return unless $message =~ s/ \[cc: \Q$wanted_nick\E\]$//s; + +    my $new_data = "$target:$message"; +    Irssi::signal_continue($server, $new_data, $nick, $nick_and_address); +} + +Irssi::signal_add('event privmsg', 'privmsg_slack_strip_auto_cc'); | 
