]> git.donarmstrong.com Git - infobot.git/blobdiff - blootbot/src/Modules/Dict.pl
- forgot to delete hash key even if current pid == parent pid.
[infobot.git] / blootbot / src / Modules / Dict.pl
index 3212b6262b2f2dc6e9f80dd90df4ff7b64ea4672..b055299c8e63d9453e0bb28e7fcbdbc0b4b14cfa 100644 (file)
@@ -31,7 +31,7 @@ sub Dict {
     # connect.
     socket($socket, PF_INET, SOCK_STREAM, $proto) or return "error: socket: $!";
     eval {
-       alarm 15;
+       alarm 10;
        connect($socket, sockaddr_in($port, inet_aton($server))) or return "error: connect: $!";
        alarm 0;
     };
@@ -43,7 +43,7 @@ sub Dict {
        $socket->autoflush(1);  # required.
 
        my $num;
-       if ($query =~ /^(\d+)\s+/) {
+       if ($query =~ s/^(\d+)\s+//) {
            $num = $1;
        }
 
@@ -57,8 +57,12 @@ sub Dict {
 
        my $total = scalar @results;
 
+       if ($total == 0) {
+           $num = undef;
+       }
+
        if (defined $num and ($num > $total or $num < 1)) {
-           &msg($::who, "error: choice in definition is out of range.");
+           &::msg($::who, "error: choice in definition is out of range.");
            return;
        }