-#v1: blootbot -- infobot -- written Thu Feb 17 02:56:42 2005
+#v1: blootbot -- infobot -- written Thu Feb 17 03:17:32 2005
#botpark
+RootWarn
&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.
###
--- /dev/null
+#
+# 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
&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", ) );
}
}
-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");