# Created: 20010906
#
-if (&IsParam("useStrict")) { use strict; }
+# use strict; # TODO
+
+use vars qw(%param %cache %lang %cmdstats %bots);
+use vars qw($message $who $addressed $chan $h $nuh $ident $msgType
+ $correction_plausable);
# Usage: &validFactoid($lhs,$rhs);
sub validFactoid {
my $author = &getFactInfo($faqtoid, "created_by");
my $count = &getFactInfo($faqtoid, "requested_count") || 0;
+ # don't delete if requested $limit times
my $limit = &getChanConfDefault(
"factoidPreventForgetLimit", 100, $chan);
+ # don't delete if older than $limitage seconds (modified by requests below)
my $limitage = &getChanConfDefault(
- "factoidPreventForgetLimitTime", 180, $chan);
+ "factoidPreventForgetLimitTime", 7 * 24 * 60 * 60, $chan);
my $t = &getFactInfo($faqtoid, "created_time") || 0;
my $age = time() - $t;
my $isau = (defined $author and &IsHostMatch($author) == 2) ? 1 : 0;
my $isop = (&IsFlag("o") eq "o") ? 1 : 0;
- if (IsFlag("r") ne "r") {
+ if (IsFlag("r") ne "r" && !$isop) {
&msg($who, "you don't have access to remove factoids");
return;
}
# factoidPreventForgetLimitTime:
if (!($isop or $isau) and $age/(60*60*24) > $limitage) {
- &msg($who, "cannot remove factoid '$faqtoid' since it is protected by Time.");
+ &msg($who, "cannot remove factoid '$faqtoid', too old. (" .
+ $age/(60*60*24) . ">$limitage) use 'no,' instead");
return;
}
# factoidPreventForgetLimit:
if (!($isop or $isau) and $limit and $count > $limit) {
- &msg($who, "will not delete '$faqtoid', count > limit ($count > $limit)");
+ &msg($who, "will not delete '$faqtoid', count > limit ($count > $limit) use 'no, ' instead.");
return;
}
return;
}
- &status("forgot (safe delete): '$faqtoid' - ". scalar(localtime));
+ &status("forgot (safe delete): '$faqtoid' - ". scalar(gmtime));
### TODO: check if the "backup" exists and overwrite it
my $check = &getFactoid("$faqtoid #DEL#");
my $faqtoid = $message;
if ($faqtoid eq "") {
- &help("undelete");
+ &help("unforget");
return;
}
}
if ($message =~ /^'(.*)'\s+'(.*)'$/) {
- my($from,$to) = (lc $1, lc $2);
+ my ($from,$to) = (lc $1, lc $2);
my $result = &getFactoid($from);
if (defined $result) {
- my $author = &getFactInfo($from, "created_by");
-
- if (0 and !&IsFlag("m") or $author !~ /^\Q$who\E\!/i) {
- &msg($who, "It's not yours to modify.");
- return;
- }
+ &performReply("i didn't have anything called '$from'");
+ return;
+ }
- if ($_ = &getFactoid($to)) {
- &performReply("destination factoid already exists.");
- return;
- }
+ my $author = &getFactInfo($from, "created_by");
- &setFactInfo($from,"factoid_key",$to);
+ # who == nick!user@host.
+ if (&IsFlag("m") ne "m" and $author !~ /^\Q$who\E\!/i) {
+ &msg($who, "factoid '$form' is not yours to modify.");
+ return;
+ }
- &status("rename: <$who> '$from' is now '$to'");
- &performReply("i renamed '$from' to '$to'");
- } else {
- &performReply("i didn't have anything called '$from'");
+ if ($_ = &getFactoid($to)) {
+ &performReply("destination factoid already exists.");
+ return;
}
+
+ &setFactInfo($from,"factoid_key",$to);
+
+ &status("rename: <$who> '$from' is now '$to'");
+ &performReply("i renamed '$from' to '$to'");
} else {
&msg($who,"error: wrong format. ask me about 'help rename'.");
}
return;
}
- return unless ($addressed);
+ return unless ($addressed and !$addrchar);
if (length $message > 64) {
&status("unparseable-moron: $message");