# NOTE: Based on code by Kevin Lenzo & Patrick Cole (c) 1997
#
-if (&IsParam("useStrict")) { use strict; }
+#use strict;
sub help {
my $topic = shift;
- my $file = $bot_misc_dir."/blootbot.help";
+ my $file = $bot_data_dir."/blootbot.help";
my %help = ();
# crude hack for pSReply() to work as expected.
$msgType = "private" if ($msgType eq "public");
if (!open(FILE, $file)) {
- &ERROR("FAILED loadHelp ($file): $!");
+ &ERROR("Failed reading help file ($file): $!");
return;
}
if (exists $help{$topic}) {
foreach (split /\n/, $help{$topic}) {
- &performStrictReply($_);
+ &pSReply($_);
}
} else {
&pSReply("no help on $topic. Use 'help' without arguments.");
# generate a hash list.
foreach (@files) {
- if (/^(.*\/)(.*?)$/) {
- $files{$1}{$2} = 1;
- }
+ next unless /^(.*\/)(.*?)$/;
+
+ $files{$1}{$2} = 1;
}
@files = (); # reuse the array.
sub getRandomLineFromFile {
my($file) = @_;
- if (! -f $file) {
- &WARN("gRLfF: file '$file' does not exist.");
+ if (!open(IN, $file)) {
+ &WARN("gRLfF: could not open ($file): $!");
return;
}
- if (open(IN,$file)) {
- my @lines = <IN>;
+ my @lines = <IN>;
+ close IN;
- if (!scalar @lines) {
- &ERROR("GRLF: nothing loaded?");
- return;
- }
+ if (!scalar @lines) {
+ &ERROR("GRLF: nothing loaded?");
+ return;
+ }
- while (my $line = &getRandom(@lines)) {
- chop $line;
+ # could we use the filehandler instead and put it through getRandom?
+ while (my $line = &getRandom(@lines)) {
+ chop $line;
- next if ($line =~ /^\#/);
- next if ($line =~ /^\s*$/);
+ next if ($line =~ /^\#/);
+ next if ($line =~ /^\s*$/);
- return $line;
- }
- } else {
- &WARN("gRLfF: could not open file '$file'.");
- return;
+ return $line;
}
}
chop $line;
return $line;
} else {
- &ERROR("getLineFromFile: could not open file '$file'.");
+ &ERROR("gLFF: Could not open file ($file): $!");
return 0;
}
}
$local{'host'} = &makeHostMask(lc $3);
}
- if ($thisnuh =~ /^(\S+)!(\S+)@(\S+)/) {
+ if (!defined $thisnuh) {
+ &WARN("IHM: thisnuh == NULL.");
+ return 0;
+ } elsif ($thisnuh =~ /^(\S+)!(\S+)@(\S+)/) {
$this{'nick'} = lc $1;
$this{'user'} = lc $2;
$this{'host'} = &makeHostMask(lc $3);
if ($host =~ s/^(\S+!\S+\@)//) {
&DEBUG("mHM: detected nick!user\@ for host arg; fixing");
+ &DEBUG("nu => $nu");
$nu = $1;
}
);
$hash{time} = time() if ($z);
- &dbReplace("stats", %hash);
+ &dbReplace("stats", "nick", %hash);
}
}