- add more configuration checks (search:maxresults and search:maxwrap)
authorAndreas Scherbaum <andreas@scherbaum.biz>
Mon, 27 Feb 2012 13:29:34 +0000 (14:29 +0100)
committerAndreas Scherbaum <andreas@scherbaum.biz>
Mon, 27 Feb 2012 13:29:34 +0000 (14:29 +0100)
docbot.pl

index 30aafae21e5bc615d60852ace6f5f0ed87e7e34c..29da7a360558342aec5976d905fd0e23e883c5c4 100755 (executable)
--- a/docbot.pl
+++ b/docbot.pl
@@ -481,6 +481,21 @@ sub validate_config {
         die("Please set config value 'irc:server'\n");
     }
 
+    if (!config_get_key2('search', 'maxresults')) {
+        die("Please set config value 'search:maxresults'\n");
+    }
+    my $maxresults = config_get_key2('search', 'maxresults');
+    if ($maxresults !~ /^\d+$/ or $maxresults < 1) {
+        die("'search:maxresults' must be a positive integer\n");
+    }
+    if (!config_get_key2('search', 'maxwrap')) {
+        die("Please set config value 'search:maxwrap'\n");
+    }
+    my $maxwrap = config_get_key2('search', 'maxwrap');
+    if ($maxwrap !~ /^\d+$/ or $maxwrap < 1) {
+        die("'search:maxwrap' must be a positive integer\n");
+    }
+
     my @sessions = config_get_keys1('sessions');
     my %seen_nicknames = ();
     my %seen_sessions = ();