From 524bb4e7c57823a9683f600ef246dcb141134f53 Mon Sep 17 00:00:00 2001 From: dms Date: Wed, 20 Feb 2002 12:17:07 +0000 Subject: [PATCH] - findparam.pl now recognizes 'Identifier' conf settings. - gRLFF: cleaned up open() code to make sense. Morten :) git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk@553 c11ca15a-4712-0410-83d8-924469b57eb5 --- blootbot/scripts/findparam.pl | 8 ++++++++ blootbot/src/Misc.pl | 31 ++++++++++++++----------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/blootbot/scripts/findparam.pl b/blootbot/scripts/findparam.pl index 04f363a..8dd5408 100644 --- a/blootbot/scripts/findparam.pl +++ b/blootbot/scripts/findparam.pl @@ -41,6 +41,14 @@ foreach (`find -name "*.pl"`) { $conf{$1}++; next; } + + # command hooks => hasParam => both. + # note: this does not support multiple lines. + if (/\'Identifier\'[\s\t]=>[\s\t]+\'(\S+?)\'/) { +# print "File: $file: command hook: $1\n"; + $both{$1}++; + next; + } } close IN; } diff --git a/blootbot/src/Misc.pl b/blootbot/src/Misc.pl index d621ea6..b36ac96 100644 --- a/blootbot/src/Misc.pl +++ b/blootbot/src/Misc.pl @@ -295,30 +295,27 @@ sub fixPlural { 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 = ; + my @lines = ; + 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; } } -- 2.39.2