From: Ossi Hakkarainen Date: Tue, 28 Aug 2018 21:46:06 +0000 (+0300) Subject: Feature update for slack_complete.pl X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=f185a19fdba5f90a05e72832166a032de0e5b356;p=irssi-scripts.irssi.org.git Feature update for slack_complete.pl * Support for common mentions (@here, @channel, @everyone) * Use completion_char setting instead of hard coded colon * Option to not add completion_char when completing first word of current li --- diff --git a/scripts/slack_complete.pl b/scripts/slack_complete.pl index 37179fd..18d111b 100644 --- a/scripts/slack_complete.pl +++ b/scripts/slack_complete.pl @@ -3,6 +3,9 @@ # # Version history: +# 2.0: - Added support for common mentions (here, channel, everyone) +# - Completion uses completion_char setting instead of hard coded colon +# - Option to choose if completion_char is added in beginning of line # 1.1: - Added support for multiple networks: /set slack_network slack flowdock gitter # or all networks: /set slack_network * @@ -14,10 +17,10 @@ use Irssi::Irc; # ======[ Script Header ]=============================================== use vars qw{$VERSION %IRSSI}; -($VERSION) = '$Revision: 1.1 $' =~ / (\d+\.\d+) /; +($VERSION) = '$Revision: 2.0 $' =~ / (\d+\.\d+) /; %IRSSI = ( name => 'slack_complete', - authors => 'Morten Lied Johansen, Jonas Berlin', + authors => 'Morten Lied Johansen, Jonas Berlin, Ossi Hakkarainen', contact => 'mortenjo@ifi.uio.no', license => 'GPL', description => 'Prefix nicks with @ when completing nicks to match conventions on networks like Slack, Flowdock, Gitter etc', @@ -40,11 +43,21 @@ my ($complist, $window, $word, $linestart, $want_space) = @_; } foreach my $nick ($wi->nicks()) { if ($nick->{nick} =~ /^\Q$word\E/i) { - if ($linestart) { - push(@$complist, "\@$nick->{nick}"); - } else { - push(@$complist, "\@$nick->{nick}:"); - } + my $ignore_completion_char = Irssi::settings_get_bool('slack_ignore_completion_char'); + if ($linestart || $ignore_completion_char) { + push(@$complist, "\@$nick->{nick}"); + } else { + my $compchar = Irssi::settings_get_str('completion_char'); + push(@$complist, "\@$nick->{nick}$compchar"); + } + } + } + if (Irssi::settings_get_bool('slack_complete_commons')) { + my @common_mentions = ("here", "channel", "everyone"); + foreach my $mention (@common_mentions) { + if ($mention =~ /^\Q$word\E/i) { + push(@$complist, "\@$mention"); + } } } @@ -58,6 +71,8 @@ my ($complist, $window, $word, $linestart, $want_space) = @_; # --------[ Register settings ]----------------------------------------- Irssi::settings_add_str('slack_complete', 'slack_network', 'Slack'); +Irssi::settings_add_bool('slack_complete', 'slack_ignore_completion_char', 0); +Irssi::settings_add_bool('slack_complete', 'slack_complete_commons', 0); # --------[ Register signals ]------------------------------------------