my $time = shift;
my $retval;
- return("0s")
- if (!defined $time or $time !~ /\d+/ or $time <= 0);
+ return("NULL s") if (!defined $time or $time !~ /\d+/);
+
+ my $prefix = "";
+ if ($time < 0) {
+ $time = - $time;
+ $prefix = "- ";
+ }
my $s = int($time) % 60;
my $m = int($time / 60) % 60;
$retval .= sprintf(" \002%d\002m", $m) if ($m != 0);
$retval .= sprintf(" \002%d\002s", $s) if ($s != 0);
- return substr($retval, 1);
+ return $prefix.substr($retval, 1);
}
###
# sort the hash list appropriately.
foreach (sort keys %files) {
my $file = $_;
- my @keys = sort keys %{$files{$file}};
+ my @keys = sort keys %{ $files{$file} };
my $i = scalar(@keys);
if ($i > 1) {
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") {
srand();
- if ($str =~ /^(\d+)$/) {
+ if ($str =~ /^(\d+(\.\d+)?)$/) {
my $i = $1;
my $fuzzy = int(rand 5);
if ($i < 10) {
return 1;
}
+ if (!defined $file) {
+ &WARN("isStale: file == 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];
- my $hage = $age*60*60*24;
+ if ($file =~ /idx/) {
+ my $age2 = time() - (stat($file))[9];
+ &DEBUG("stale: $age2. (". &Time2String($age2) .")");
+ }
+ $age *= 60*60*24 if ($age >= 0 and $age < 30);
+
+ return 1 if (time() - (stat($file))[9] > $age);
return 0;
}
return $profanity;
}
-### rename to hasChanConf() ?
sub hasParam {
my ($param) = @_;
- ### TODO: specific reason why it failed.
- if (&IsChanConf($param)) {
+ if (&IsChanConf($param) or &IsParam($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;
}
return 0 if ( -f $file{PID});
}
+sub mkcrypt {
+ my($str) = @_;
+ my $salt = join '',('.','/',0..9,'A'..'Z','a'..'z')[rand 64, rand 64];
+
+ return crypt($str, $salt);
+}
+
1;