From: Wieland Hoffmann Date: Sat, 7 Jul 2018 10:04:46 +0000 (+0200) Subject: [oops] Refactoring X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=be1c5641fdcf1081f8a52b8cc7cf951d975e2630;p=irssi-scripts.irssi.org.git [oops] Refactoring * Simplify the pattern * Simplify the conditions --- diff --git a/scripts/oops.pl b/scripts/oops.pl index 8b3c33a..d84b35b 100644 --- a/scripts/oops.pl +++ b/scripts/oops.pl @@ -2,32 +2,32 @@ use strict; use vars qw($VERSION %IRSSI); use Irssi; -$VERSION = '20071209'; +$VERSION = '20180707'; %IRSSI = ( authors => '', contact => '', name => 'oops', description => -'turns \'ll\' and \'ls\' in the beginning of a sent line into the names or whois commands', + 'turns \'ll\' and \'ls\' in the beginning of a sent line into the names or whois commands', license => 'Public Domain', -); + ); sub send_text { - my $pattern = qr/(^ll |^ll$|^ls |^ls$)/; + my $pattern = qr/(^(ll|ls)\s*$)/; #"send text", char *line, SERVER_REC, WI_ITEM_REC my ( $data, $server, $witem ) = @_; - if ( $witem - && ( $witem->{type} eq "CHANNEL" ) - && ( $data =~ $pattern ) ) - { - $witem->command("names $witem->{name}"); - Irssi::signal_stop(); - } - if ( $witem && ( $witem->{type} eq "QUERY" ) && ( $data =~ $pattern ) ) - { - $witem->command("whois $witem->{name}"); - Irssi::signal_stop(); + if($data =~ $pattern) { + if($witem->{type} eq "CHANNEL") + { + $witem->command("names $witem->{name}"); + Irssi::signal_stop(); + } + elsif($witem->{type} eq "QUERY") + { + $witem->command("whois $witem->{name}"); + Irssi::signal_stop(); + } } }