]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
[oops] Refactoring
authorWieland Hoffmann <redacted>
Sat, 7 Jul 2018 10:04:46 +0000 (12:04 +0200)
committerWieland Hoffmann <redacted>
Sat, 7 Jul 2018 10:06:14 +0000 (12:06 +0200)
* Simplify the pattern

* Simplify the conditions

scripts/oops.pl

index 8b3c33aacec24b754d614eccfb729e943c7d357d..d84b35bf54ae525ddde0f2fcc8fde675663e3b40 100644 (file)
@@ -2,32 +2,32 @@ use strict;
 use vars qw($VERSION %IRSSI);\r
 \r
 use Irssi;\r
-$VERSION = '20071209';\r
+$VERSION = '20180707';\r
 %IRSSI = (\r
     authors     => '',\r
     contact     => '',\r
     name        => 'oops',\r
     description =>\r
-'turns \'ll\' and \'ls\' in the beginning of a sent line into the names or whois commands',\r
+    'turns \'ll\' and \'ls\' in the beginning of a sent line into the names or whois commands',\r
     license => 'Public Domain',\r
-);\r
+    );\r
 \r
 sub send_text {\r
-    my $pattern = qr/(^ll |^ll$|^ls |^ls$)/;\r
+    my $pattern = qr/(^(ll|ls)\s*$)/;\r
 \r
     #"send text", char *line, SERVER_REC, WI_ITEM_REC\r
     my ( $data, $server, $witem ) = @_;\r
-    if ( $witem\r
-        && ( $witem->{type} eq "CHANNEL" )\r
-        && ( $data =~ $pattern ) )\r
-    {\r
-        $witem->command("names $witem->{name}");\r
-        Irssi::signal_stop();\r
-    }\r
-    if ( $witem && ( $witem->{type} eq "QUERY" ) && ( $data =~ $pattern ) )\r
-    {\r
-        $witem->command("whois $witem->{name}");\r
-        Irssi::signal_stop();\r
+    if($data =~ $pattern) {\r
+        if($witem->{type} eq "CHANNEL")\r
+        {\r
+            $witem->command("names $witem->{name}");\r
+            Irssi::signal_stop();\r
+        }\r
+        elsif($witem->{type} eq "QUERY")\r
+        {\r
+            $witem->command("whois $witem->{name}");\r
+            Irssi::signal_stop();\r
+        }\r
     }\r
 }\r
 \r
git clone https://git.99rst.org/PROJECT