Skip to content

Commit

Permalink
modify regex to avoid blanking entire page (also add a failsafe)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ted Timmons committed Jun 1, 2010
1 parent eafe3e0 commit 0c7c791
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bin/current.pl
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,15 @@ sub checkRemoval {
sub removeCurrentTemplate {
my ($title, $content) = @_;

$content =~ s#{{current.*?}}##i;
my $oldlength = length $content;
$content =~ s#\{\{current([^{}]*?)\}\}##i;
my $newlength = length $content;

if (($oldlength - $newlength) > 100) {
_debug("eep! tried removing the current template and we must have done much more. We're scared, so we'll bail.\n");
return -100;
}

$tb->replacePage($title, $content, "[[User:TedderBot/CurrentPruneBot|remove stale current-event template]], please see [[WP:CET]]. (bot edit)");
_debug(":updated [[$title]]\n");
#print "updating $title\n";
Expand Down

0 comments on commit 0c7c791

Please sign in to comment.