]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Modules/spell.pl
* Accidentally left in a debug output
[infobot.git] / src / Modules / spell.pl
index 705854dfdde8913266c9c61d6cd7e46697c665ec..dd508b3318e98d5764557402b1a436ed96bca5a0 100644 (file)
@@ -13,68 +13,71 @@ package spell;
 use strict;
 
 sub spell::spell {
-       my $query = shift;
-       if ($query =~ m/[^[:alpha:]]/) {
-               return('only one word of alphabetic characters supported');
-       }
-
-       my $binary;
-       my @binaries = (
-               '/usr/bin/aspell',
-               '/usr/bin/ispell',
-               '/usr/bin/spell'
-       );
-
-       foreach (@binaries) {
-               if (-x $_) {
-                       $binary=$_;
-                       last;
-               }
-       }
-
-       if (!$binary) {
-               return('no binary found.');
-       }
-
-       if (!&::validExec($query)) {
-               return('argument appears to be fuzzy.');
-       }
-
-       my $reply = "I can't find alternate spellings for '$query'";
-
-       foreach (`/bin/echo '$query' | $binary -a -S`) {
-               chop;
-               last if !length;                # end of query.
-
-               if (/^\@/) {            # intro line.
-                       next;
-               } elsif (/^\*/) {               # possibly correct.
-                       $reply = "'$query' may be spelled correctly";
-                       last;
-               } elsif (/^\&/) {               # possible correction(s).
-                       s/^\& (\S+) \d+ \d+: //;
-                       my @array = split(/,? /);
-
-                       $reply = "possible spellings for $query: @array";
-                       last;
-               } elsif (/^\+/) {
-                       &::DEBUG("spell: '+' found => '$_'.");
-                       last;
-               } elsif (/^# (.*?) 0$/) {
-                       # none found.
-                       last;
-               } else {
-                       &::DEBUG("spell: unknown: '$_'.");
-               }
-       }
-
-       return($reply);
+    my $query = shift;
+    if ( $query =~ m/[^[:alpha:]]/ ) {
+        return ('only one word of alphabetic characters supported');
+    }
+
+    my $binary;
+    my @binaries = ( '/usr/bin/aspell', '/usr/bin/ispell', '/usr/bin/spell' );
+
+    foreach (@binaries) {
+        if ( -x $_ ) {
+            $binary = $_;
+            last;
+        }
+    }
+
+    if ( !$binary ) {
+        return ('no binary found.');
+    }
+
+    if ( !&::validExec($query) ) {
+        return ('argument appears to be fuzzy.');
+    }
+
+    my $reply = "I can't find alternate spellings for '$query'";
+
+    foreach (`/bin/echo '$query' | $binary -a -S`) {
+        chop;
+        last if !length;    # end of query.
+
+        if (/^\@/) {        # intro line.
+            next;
+        }
+        elsif (/^\*/) {     # possibly correct.
+            $reply = "'$query' may be spelled correctly";
+            last;
+        }
+        elsif (/^\&/) {     # possible correction(s).
+            s/^\& (\S+) \d+ \d+: //;
+            my @array = split(/,? /);
+
+            $reply = "possible spellings for $query: @array";
+            last;
+        }
+        elsif (/^\+/) {
+            &::DEBUG("spell: '+' found => '$_'.");
+            last;
+        }
+        elsif (/^# (.*?) 0$/) {
+
+            # none found.
+            last;
+        }
+        else {
+            &::DEBUG("spell: unknown: '$_'.");
+        }
+    }
+
+    return ($reply);
 }
 
 sub spell::query {
-       &::performStrictReply(&spell(@_));
-       return;
+    &::performStrictReply( &spell(@_) );
+    return;
 }
 
 1;
-# vim: ts=2 sw=2
+
+# vim:ts=4:sw=4:expandtab:tw=80