]> git.donarmstrong.com Git - infobot.git/commitdiff
spell is now a forker
authortimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Thu, 17 Feb 2005 03:18:52 +0000 (03:18 +0000)
committertimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Thu, 17 Feb 2005 03:18:52 +0000 (03:18 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@1129 c11ca15a-4712-0410-83d8-924469b57eb5

files/sample/blootbot.chan
src/CommandStubs.pl
src/Modules/spell.pl [new file with mode: 0644]
src/UserExtra.pl

index e868c79adbf79743f8ba77e0b4db4a325ef9af4a..e7c92337fa412a5ca50de99b94be6b84e178b855 100644 (file)
@@ -1,4 +1,4 @@
-#v1: blootbot -- infobot -- written Thu Feb 17 02:56:42 2005
+#v1: blootbot -- infobot -- written Thu Feb 17 03:17:32 2005
 
 #botpark
     +RootWarn
index 92793e738d0b1bbf54df9ecc01400e620509fdb7..b007d36c6093c93b73e50d70dafdd5390f436cda 100644 (file)
@@ -277,6 +277,9 @@ sub parseCmdHook {
 &addCmdHook("extra", 'wtf', ('CODEREF' => 'wtf::query',
        'Identifier' => 'wtf', 'Cmdstats' => 'wtf',
        'Forker' => 1, 'Help' => 'wtf') );
+&addCmdHook("extra", '[ia]?spell', ('CODEREF' => 'spell::query',
+       'Identifier' => 'spell', 'Cmdstats' => 'spell',
+       'Forker' => 1, 'Help' => 'spell') );
 ###
 ### END OF ADDING HOOKS.
 ###
diff --git a/src/Modules/spell.pl b/src/Modules/spell.pl
new file mode 100644 (file)
index 0000000..b34b3e6
--- /dev/null
@@ -0,0 +1,76 @@
+#
+#   spell.pl: interface to aspell/ispell/spell
+#       Author: Tim Riker <Tim@Rikers.org>
+#       Source: extracted from UserExtra
+#  Licensing: Artistic License (as perl itself)
+#      Version: v0.1
+#
+#  Copyright (c) 2005 Tim Riker
+#
+
+package spell;
+
+use strict;
+
+sub spell::spell {
+       my $query = shift;
+       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 (!&main::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 (/^\+/) {
+                       &main::DEBUG("spell: '+' found => '$_'.");
+                       last;
+               } elsif (/^# (.*?) 0$/) {
+                       # none found.
+                       last;
+               } else {
+                       &main::DEBUG("spell: unknown: '$_'.");
+               }
+       }
+
+       return($reply);
+}
+
+sub spell::query {
+       &::performStrictReply(&spell(@_));
+       return;
+}
+
+1;
+# vim: ts=2 sw=2
index f3138ad2021d985b2b6389d083537b0f016916bb..584a43b40636aa9ba453c5707f60afa770581374 100644 (file)
@@ -26,8 +26,6 @@ use vars qw(%channels %chanstats %cmdstats %count %ircstats %param
 &addCmdHook("main", 'help', ('CODEREF' => 'help',
        'Cmdstats' => 'Help', ) );
 &addCmdHook("main", 'karma', ('CODEREF' => 'karma', ) );
-&addCmdHook("main", 'i?spell', ('CODEREF' => 'ispell',
-       Help => 'spell', Identifier => 'spell', ) );
 &addCmdHook("main", 'd?nslookup', ('CODEREF' => 'DNS',
        Help => 'nslookup', Identifier => 'allowDNS',
        Forker => "NULL", ) );
@@ -236,63 +234,6 @@ sub karma {
     }
 }
 
-sub ispell {
-    my $query = shift;
-    my $binary;
-    my @binaries = (
-       '/usr/bin/aspell',
-       '/usr/bin/ispell',
-       '/usr/bin/spell'
-    );
-
-    foreach (@binaries) {
-       if (-x $_) {
-           $binary=$_;
-           last;
-       }
-    }
-
-    if (!$binary) {
-       &msg($who, "no binary found.");
-       return;
-    }
-
-    if (!&validExec($query)) {
-       &msg($who,"argument appears to be fuzzy.");
-       return;
-    }
-
-    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: '$_'.");
-       }
-    }
-
-    &pSReply($reply);
-}
-
 sub nslookup {
     my $query = shift;
     &status("DNS Lookup: $query");