]> git.donarmstrong.com Git - infobot.git/commitdiff
- findparam.pl now recognizes 'Identifier' conf settings.
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Wed, 20 Feb 2002 12:17:07 +0000 (12:17 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Wed, 20 Feb 2002 12:17:07 +0000 (12:17 +0000)
- gRLFF: cleaned up open() code to make sense. Morten :)

git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@553 c11ca15a-4712-0410-83d8-924469b57eb5

scripts/findparam.pl
src/Misc.pl

index 04f363ae96ffacf9db4dfc790013d75f6978b557..8dd54080b39dde15e9699f638f78fc396f978f33 100644 (file)
@@ -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;
 }
index d621ea6c9cf057f9ab93df1fdf4b611a16500a2a..b36ac963cf94f102fef971fa67441b42519ff22e 100644 (file)
@@ -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 = <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;
     }
 }