From: Christoffer Holmberg Date: Sat, 25 Nov 2017 08:40:23 +0000 (+0200) Subject: discord_unhilight.pl first version X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=dd2907ae3a798fee53be93bda99c4047db045bde;p=irssi-scripts.irssi.org.git discord_unhilight.pl first version --- diff --git a/scripts/discord_unhilight.pl b/scripts/discord_unhilight.pl new file mode 100644 index 0000000..c752849 --- /dev/null +++ b/scripts/discord_unhilight.pl @@ -0,0 +1,36 @@ +use strict; +use warnings; +use Irssi; + +our $VERSION = '0.1b'; +our %IRSSI = ( + authors => 'Christoffer Holmberg', + contact => 'skug+irssiscripts@skug.fi', + name => 'discord_unhilight.pl', + description => 'Strips the annoying mentions of your nickname via on irc<->discord bridge, will work for any bridge using botnick: ', + license => 'Public Domain', + url => 'http://scripts.irssi.org & https://github.com/mskug/scrips.irssi.org/blob/master/scripts/discord_unhilight.pl', +); + +# HOWTO: +# +# /load discord_unhilight.pl +# +# This should just automatically work +# +# NOTE: +# +# Based on slack_strip_auto_cc.pl by Ævar Arnfjörð Bjarmason. + +sub msg_strip_nick_from_discord_bridge { + my ($server, $data, $nick, $nick_and_address) = @_; + my ($target, $message) = split /:/, $data, 2; + + my $wanted_nick = $server->{wanted_nick}; + return unless $message =~ s/^<\Q$wanted_nick\E>/-You-:/; + + my $new_data = "$target:$message"; + Irssi::signal_continue($server, $new_data, $nick, $nick_and_address); +} + +Irssi::signal_add('event privmsg', 'msg_strip_nick_from_discord_bridge');