]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Misc.pl
- $nuh{} fix up.
[infobot.git] / src / Misc.pl
index fe89197c18cb6a6e48cf614ffff09869f0eadc25..43c3f2ab1e263627e7b262e31eb9ac5dc93b3003 100644 (file)
@@ -249,6 +249,11 @@ sub fixPlural {
        return;
     }
 
+    if (!defined $int or $int =~ /^\D+$/) {
+       &WARN("fixPlural: int != defined or int");
+       return $str;
+    }
+
     if ($str eq "has") {
        $str = "have"   if ($int > 1);
     } elsif ($str eq "is") {
@@ -353,7 +358,7 @@ sub getRandomInt {
 
     srand();
 
-    if ($str =~ /^(\d+)$/) {
+    if ($str =~ /^(\d+(\.\d+)?)$/) {
        my $i = $1;
        my $fuzzy = int(rand 5);
        if ($i < 10) {
@@ -427,6 +432,11 @@ sub IsHostMatch {
 sub isStale {
     my ($file, $age) = @_;
 
+    if (!defined $age) {
+       &WARN("isStale: age == NULL.");
+       return 1;
+    }
+
     return 1 unless ( -f $file);
     return 1 if (time() - (stat($file))[9] > $age*60*60*24);
     my $delta = time() - (stat($file))[9];
@@ -606,10 +616,10 @@ sub hasProfanity {
 sub hasParam {
     my ($param) = @_;
 
-    ### TODO: specific reason why it failed.
     if (&IsChanConf($param)) {
        return 1;
     } else {
+       ### TODO: specific reason why it failed.
        &msg($who, "unfortunately, \002$param\002 is disabled in my configuration") unless ($addrchar);
        return 0;
     }